diff --git a/package.json b/package.json index 226b708a3..16468a5e9 100644 --- a/package.json +++ b/package.json @@ -18,19 +18,19 @@ "docs": "pnpm --filter @browserbasehq/stagehand-docs run dev", "evals": "tsx scripts/run-evals.ts", "evals:legacy": "tsx scripts/run-evals.ts", - "e2e": "pnpm run build && cd evals/deterministic && playwright test --config=e2e.playwright.config.ts", - "e2e:bb": "pnpm run build && cd evals/deterministic && playwright test --config=bb.playwright.config.ts", - "e2e:local": "pnpm run build && cd evals/deterministic && playwright test --config=local.playwright.config.ts", + "e2e": "pnpm run build && node scripts/build-e2e.mjs && node scripts/run-playwright.mjs --config=dist/playwright/evals/deterministic/e2e.playwright.config.js", + "e2e:bb": "pnpm run build && node scripts/build-e2e.mjs && node scripts/run-playwright.mjs --config=dist/playwright/evals/deterministic/bb.playwright.config.js", + "e2e:local": "pnpm run build && node scripts/build-e2e.mjs && node scripts/run-playwright.mjs --config=dist/playwright/evals/deterministic/local.playwright.config.js", "build-dom-scripts": "tsx lib/dom/genDomScripts.ts", - "build-types": "tsc --emitDeclarationOnly --outDir dist", - "build-js": "tsup lib/index.ts --dts", - "build:cli": "tsup evals/cli.ts --outDir dist/evals --format cjs && cp evals/evals.config.json dist/evals/ && chmod +x dist/evals/cli.js && npm link", - "build": "pnpm run lint && pnpm run gen-version && pnpm run build-dom-scripts && pnpm run build-js && pnpm run build-types", + "build-types": "tsc --project tsconfig.build.json", + "build:cli": "node scripts/build-cli.mjs", + "build": "pnpm run lint && pnpm run gen-version && pnpm run build-dom-scripts && pnpm run build:lib && pnpm run build-types", "gen-version": "tsx scripts/gen-version.ts", "prepare": "pnpm run build", "lint": "pnpm run prettier:fix && pnpm run eslint", "release": "pnpm run build && changeset publish", - "release-canary": "pnpm run build && changeset version --snapshot && changeset publish --tag alpha" + "release-canary": "pnpm run build && changeset version --snapshot && changeset publish --tag alpha", + "build:lib": "node scripts/build-lib.mjs" }, "files": [ "dist/**" @@ -63,7 +63,6 @@ "multer": "^1.4.5-lts.1", "prettier": "^3.2.5", "string-comparison": "^1.3.0", - "tsup": "^8.2.1", "tsx": "^4.10.5", "typescript": "^5.2.2", "typescript-eslint": "^8.17.0" @@ -86,7 +85,8 @@ "pino-pretty": "^13.0.0", "playwright": "^1.52.0", "ws": "^8.18.0", - "zod-to-json-schema": "^3.23.5" + "zod-to-json-schema": "^3.23.5", + "playwright-core": "^1.52.0" }, "optionalDependencies": { "@ai-sdk/anthropic": "^1.2.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cbd994598..01c915bf7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -46,7 +46,14 @@ importers: version: 13.1.1 playwright: specifier: ^1.52.0 + + version: 1.52.0 + playwright-core: + specifier: ^1.52.0 + version: 1.52.0 + version: 1.55.0 + ws: specifier: ^8.18.0 version: 8.18.3 @@ -166,9 +173,12 @@ importers: string-comparison: specifier: ^1.3.0 version: 1.3.0 + + tsup: specifier: ^8.2.1 version: 8.5.0(jiti@1.21.7)(postcss@8.5.6)(tsx@4.20.5)(typescript@5.9.2)(yaml@2.8.1) + tsx: specifier: ^4.10.5 version: 4.20.5 @@ -1411,6 +1421,10 @@ packages: engines: {node: '>=18'} hasBin: true + + '@shikijs/core@3.11.0': + resolution: {integrity: sha512-oJwU+DxGqp6lUZpvtQgVOXNZcVsirN76tihOLBmwILkKuRuwHteApP8oTXmL4tF5vS5FbOY0+8seXmiCoslk4g==} + '@radix-ui/primitive@1.1.3': resolution: {integrity: sha512-JTF99U/6XIjCBo0wqkU5sK10glYe27MRRsfwoiq5zzOEZLHU3A3KCMa5X/azekYRCJ0HlwI0crAXS/5dEHTzDg==} @@ -1745,6 +1759,7 @@ packages: '@shikijs/engine-javascript@3.13.0': resolution: {integrity: sha512-Ty7xv32XCp8u0eQt8rItpMs6rU9Ki6LJ1dQOW3V/56PKDcpvfHPnYFbsx5FFUP2Yim34m/UkazidamMNVR4vKg==} + '@shikijs/engine-oniguruma@3.13.0': resolution: {integrity: sha512-O42rBGr4UDSlhT2ZFMxqM7QzIU+IcpoTMzb3W7AlziI1ZF7R8eS2M0yt5Ry35nnnTX/LTLXFPUjRFCIW+Operg==} @@ -2429,12 +2444,6 @@ packages: buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} - bundle-require@5.1.0: - resolution: {integrity: sha512-3WrrOuZiyaaZPWiEt4G3+IffISVC9HYlWueJEBWED4ZH4aIAC2PnkdnuRrR94M+w6yGWn4AglWtJtBI8YqvgoA==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - peerDependencies: - esbuild: '>=0.18' - busboy@1.6.0: resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} engines: {node: '>=10.16.0'} @@ -2443,10 +2452,6 @@ packages: resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} engines: {node: '>= 0.8'} - cac@6.7.14: - resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} - engines: {node: '>=8'} - cacheable-lookup@7.0.0: resolution: {integrity: sha512-+qJyx4xiKra8mZrcwhjMRMUhD5NR1R8esPkzIYxX96JiecFoxAXFuz/GpR3+ev4PE1WamHip78wV0vcmPQtp8w==} engines: {node: '>=14.16'} @@ -2522,10 +2527,6 @@ packages: resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} - chokidar@4.0.3: - resolution: {integrity: sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==} - engines: {node: '>= 14.16.0'} - chownr@2.0.0: resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} engines: {node: '>=10'} @@ -2635,6 +2636,10 @@ packages: resolution: {integrity: sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==} engines: {'0': node >= 0.8} + + console-table-printer@2.12.1: + resolution: {integrity: sha512-wKGOQRRvdnd89pCeH96e2Fn4wkbenSP6LMHfjfyNLMbGuHEFbMqQNuxXqd0oXG9caIOQ1FTvc5Uijp9/4jujnQ==} + confbox@0.1.8: resolution: {integrity: sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==} @@ -2645,6 +2650,7 @@ packages: console-table-printer@2.14.6: resolution: {integrity: sha512-MCBl5HNVaFuuHW6FGbL/4fB7N/ormCy+tQ+sxTrF6QtSbSNETvPuOVbkJBhzDgYhvjWGrTma4eYJa37ZuoQsPw==} + content-disposition@0.5.4: resolution: {integrity: sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==} engines: {node: '>= 0.6'} @@ -3207,6 +3213,8 @@ packages: fd-slicer@1.1.0: resolution: {integrity: sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==} + + fdir@6.5.0: resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} engines: {node: '>=12.0.0'} @@ -3216,6 +3224,7 @@ packages: picomatch: optional: true + fetch-cookie@3.1.0: resolution: {integrity: sha512-s/XhhreJpqH0ftkGVcQt8JE9bqk+zRn4jF5mPJXWZeQMCI5odV9K+wEWYbnzFPHgQZlvPSMjS4n4yawWE8RINw==} @@ -4006,10 +4015,6 @@ packages: lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - load-tsconfig@0.2.5: - resolution: {integrity: sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - locate-character@3.0.0: resolution: {integrity: sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==} @@ -4024,9 +4029,6 @@ packages: lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} - lodash.sortby@4.7.0: - resolution: {integrity: sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==} - lodash.startcase@4.4.0: resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} @@ -4701,10 +4703,12 @@ packages: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} + picomatch@4.0.3: resolution: {integrity: sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==} engines: {node: '>=12'} + pify@2.3.0: resolution: {integrity: sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==} engines: {node: '>=0.10.0'} @@ -4784,24 +4788,6 @@ packages: ts-node: optional: true - postcss-load-config@6.0.1: - resolution: {integrity: sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g==} - engines: {node: '>= 18'} - peerDependencies: - jiti: '>=1.21.0' - postcss: '>=8.0.9' - tsx: ^4.8.1 - yaml: ^2.4.2 - peerDependenciesMeta: - jiti: - optional: true - postcss: - optional: true - tsx: - optional: true - yaml: - optional: true - postcss-nested@6.2.0: resolution: {integrity: sha512-HQbt28KulC5AJzG+cZtj9kvKB93CFCdLvog1WFLf1D+xmMvPGlBstkpTEZfK5+AN9hfJocyBFCNiqyS48bpgzQ==} engines: {node: '>=12.0'} @@ -4970,10 +4956,6 @@ packages: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} - readdirp@4.1.2: - resolution: {integrity: sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==} - engines: {node: '>= 14.18.0'} - real-require@0.2.0: resolution: {integrity: sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==} engines: {node: '>= 12.13.0'} @@ -5109,11 +5091,14 @@ packages: resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + + rollup@4.52.0: resolution: {integrity: sha512-+IuescNkTJQgX7AkIDtITipZdIGcWF0pnVvZTWStiazUmcGA2ag8dfg0urest2XlXUi9kuhfQ+qmdc5Stc3z7g==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true + router@2.2.0: resolution: {integrity: sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==} engines: {node: '>= 18'} @@ -5326,11 +5311,6 @@ packages: resolution: {integrity: sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==} engines: {node: '>= 12'} - source-map@0.8.0-beta.0: - resolution: {integrity: sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==} - engines: {node: '>= 8'} - deprecated: The work that was done in this beta branch won't be included in future versions - space-separated-tokens@2.0.2: resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==} @@ -5505,6 +5485,8 @@ packages: through@2.3.8: resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} + + tinyexec@0.3.2: resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==} @@ -5512,6 +5494,7 @@ packages: resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} engines: {node: '>=12.0.0'} + tldts-core@6.1.86: resolution: {integrity: sha512-Je6p7pkk+KMzMv2XXKmAE3McmolOQFdxkKw0R8EYNr7sELW46JqnNeTX8ybPiQgvg1ymCoF8LXs5fzFaZvJPTA==} @@ -5534,13 +5517,6 @@ packages: tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} - tr46@1.0.1: - resolution: {integrity: sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==} - - tree-kill@1.2.2: - resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==} - hasBin: true - trim-lines@3.0.1: resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==} @@ -5565,6 +5541,10 @@ packages: tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + + tsx@4.19.4: + resolution: {integrity: sha512-gK5GVzDkJK1SI1zwHf32Mqxf2tSJkNx+eYcNly5+nHvWqXUJYUkWBQtKauoESz3ymezAI++ZwT855x5p5eop+Q==} + tsup@8.5.0: resolution: {integrity: sha512-VmBp77lWNQq6PfuMqCHD3xWl22vEoWsKajkF8t+yMBawlUS8JzEI+vOVMeuNZIuMML8qXRizFKi9oD5glKQVcQ==} engines: {node: '>=18'} @@ -5586,6 +5566,7 @@ packages: tsx@4.20.5: resolution: {integrity: sha512-+wKjMNU9w/EaQayHXb7WA7ZaHY6hN8WgfvHNQ3t1PnU91/7O8TcTnIhCDYTZwnt8JsO9IBqZ30Ln1r7pPF52Aw==} + engines: {node: '>=18.0.0'} hasBin: true @@ -5824,9 +5805,6 @@ packages: webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} - webidl-conversions@4.0.2: - resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==} - whatwg-encoding@3.1.1: resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==} engines: {node: '>=18'} @@ -5838,9 +5816,6 @@ packages: whatwg-url@5.0.0: resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} - whatwg-url@7.1.0: - resolution: {integrity: sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==} - which-boxed-primitive@1.1.1: resolution: {integrity: sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==} engines: {node: '>= 0.4'} @@ -7384,6 +7359,9 @@ snapshots: - react-native-b4a - supports-color + + '@shikijs/core@3.11.0': + '@radix-ui/primitive@1.1.3': {} '@radix-ui/react-arrow@1.1.7(@types/react@19.1.13)(react-dom@18.3.1(react@19.1.1))(react@19.1.1)': @@ -7630,6 +7608,7 @@ snapshots: optional: true '@shikijs/core@3.13.0': + dependencies: '@shikijs/types': 3.13.0 '@shikijs/vscode-textmate': 10.0.2 @@ -8501,19 +8480,20 @@ snapshots: base64-js: 1.5.1 ieee754: 1.2.1 + + bundle-require@5.1.0(esbuild@0.25.10): dependencies: esbuild: 0.25.10 load-tsconfig: 0.2.5 + busboy@1.6.0: dependencies: streamsearch: 1.1.0 bytes@3.1.2: {} - cac@6.7.14: {} - cacheable-lookup@7.0.0: {} cacheable-request@10.2.14: @@ -8607,10 +8587,6 @@ snapshots: optionalDependencies: fsevents: 2.3.3 - chokidar@4.0.3: - dependencies: - readdirp: 4.1.2 - chownr@2.0.0: {} chromium-bidi@0.10.2(devtools-protocol@0.0.1464554): @@ -8719,11 +8695,15 @@ snapshots: readable-stream: 2.3.8 typedarray: 0.0.6 + + console-table-printer@2.12.1: + confbox@0.1.8: {} consola@3.4.2: {} console-table-printer@2.14.6: + dependencies: simple-wcswidth: 1.1.2 @@ -9464,10 +9444,13 @@ snapshots: dependencies: pend: 1.2.0 + + fdir@6.5.0(picomatch@4.0.3): optionalDependencies: picomatch: 4.0.3 + fetch-cookie@3.1.0: dependencies: set-cookie-parser: 2.7.1 @@ -10427,8 +10410,6 @@ snapshots: lines-and-columns@1.2.4: {} - load-tsconfig@0.2.5: {} - locate-character@3.0.0: {} locate-path@5.0.0: @@ -10441,8 +10422,6 @@ snapshots: lodash.merge@4.6.2: {} - lodash.sortby@4.7.0: {} - lodash.startcase@4.4.0: {} lodash.topath@4.5.2: {} @@ -11419,8 +11398,11 @@ snapshots: picomatch@2.3.1: {} + + picomatch@4.0.3: {} + pify@2.3.0: {} pify@4.0.1: {} @@ -11504,6 +11486,7 @@ snapshots: optionalDependencies: postcss: 8.5.6 + postcss-load-config@6.0.1(jiti@1.21.7)(postcss@8.5.6)(tsx@4.20.5)(yaml@2.8.1): dependencies: lilconfig: 3.1.3 @@ -11513,6 +11496,7 @@ snapshots: tsx: 4.20.5 yaml: 2.8.1 + postcss-nested@6.2.0(postcss@8.5.6): dependencies: postcss: 8.5.6 @@ -11703,8 +11687,6 @@ snapshots: dependencies: picomatch: 2.3.1 - readdirp@4.1.2: {} - real-require@0.2.0: {} recma-build-jsx@1.0.0: @@ -11935,6 +11917,8 @@ snapshots: reusify@1.1.0: {} + + rollup@4.52.0: dependencies: '@types/estree': 1.0.8 @@ -11963,6 +11947,7 @@ snapshots: '@rollup/rollup-win32-x64-msvc': 4.52.0 fsevents: 2.3.3 + router@2.2.0: dependencies: debug: 4.4.3 @@ -12278,10 +12263,6 @@ snapshots: source-map@0.7.6: {} - source-map@0.8.0-beta.0: - dependencies: - whatwg-url: 7.1.0 - space-separated-tokens@2.0.2: {} spawndamnit@3.0.1: @@ -12522,6 +12503,8 @@ snapshots: through@2.3.8: {} + + tinyexec@0.3.2: {} tinyglobby@0.2.15: @@ -12529,6 +12512,7 @@ snapshots: fdir: 6.5.0(picomatch@4.0.3) picomatch: 4.0.3 + tldts-core@6.1.86: {} tldts@6.1.86: @@ -12547,12 +12531,6 @@ snapshots: tr46@0.0.3: {} - tr46@1.0.1: - dependencies: - punycode: 2.3.1 - - tree-kill@1.2.2: {} - trim-lines@3.0.1: {} trim-trailing-lines@2.1.0: {} @@ -12569,6 +12547,9 @@ snapshots: tslib@2.8.1: {} + + tsx@4.19.4: + tsup@8.5.0(jiti@1.21.7)(postcss@8.5.6)(tsx@4.20.5)(typescript@5.9.2)(yaml@2.8.1): dependencies: bundle-require: 5.1.0(esbuild@0.25.10) @@ -12598,6 +12579,7 @@ snapshots: - yaml tsx@4.20.5: + dependencies: esbuild: 0.25.10 get-tsconfig: 4.10.1 @@ -12871,8 +12853,6 @@ snapshots: webidl-conversions@3.0.1: {} - webidl-conversions@4.0.2: {} - whatwg-encoding@3.1.1: dependencies: iconv-lite: 0.6.3 @@ -12884,12 +12864,6 @@ snapshots: tr46: 0.0.3 webidl-conversions: 3.0.1 - whatwg-url@7.1.0: - dependencies: - lodash.sortby: 4.7.0 - tr46: 1.0.1 - webidl-conversions: 4.0.2 - which-boxed-primitive@1.1.1: dependencies: is-bigint: 1.1.0 diff --git a/scripts/build-cli.mjs b/scripts/build-cli.mjs new file mode 100644 index 000000000..d7b1e43fb --- /dev/null +++ b/scripts/build-cli.mjs @@ -0,0 +1,82 @@ +import process from "node:process"; +import { build } from "esbuild"; +import { chmodSync, copyFileSync, mkdirSync, readFileSync } from "node:fs"; +import { spawnSync } from "node:child_process"; +import path from "node:path"; + +const pkgJson = JSON.parse( + readFileSync(new URL("../package.json", import.meta.url)), +); +const externalDeps = Array.from( + new Set([ + ...Object.keys(pkgJson.dependencies ?? {}), + ...Object.keys(pkgJson.peerDependencies ?? {}), + ...Object.keys(pkgJson.optionalDependencies ?? {}), + ]), +); + +const distDir = path.join("dist", "evals"); +const cliOutfile = path.join(distDir, "cli.js"); +const configSource = path.join("evals", "evals.config.json"); +const configDestination = path.join(distDir, "evals.config.json"); + +const commonOptions = { + bundle: true, + platform: "node", + target: "es2022", + sourcemap: true, + packages: "external", + external: externalDeps, +}; + +const shouldLink = (() => { + const flag = process.env.STAGEHAND_SKIP_NPM_LINK ?? ""; + return flag !== "1" && flag.toLowerCase() !== "true"; +})(); + +async function main() { + mkdirSync(distDir, { recursive: true }); + + await build({ + entryPoints: ["evals/cli.ts"], + format: "cjs", + outfile: cliOutfile, + banner: { js: "#!/usr/bin/env node" }, + ...commonOptions, + }); + + copyFileSync(configSource, configDestination); + + try { + chmodSync(cliOutfile, 0o755); + } catch (error) { + const maybeSystemError = error; + if ( + !maybeSystemError || + typeof maybeSystemError !== "object" || + !("code" in maybeSystemError) || + (maybeSystemError.code !== "ENOSYS" && maybeSystemError.code !== "EPERM") + ) { + throw error; + } + } + + if (!shouldLink) { + console.warn("Skipping npm link because STAGEHAND_SKIP_NPM_LINK is set."); + return; + } + + const linkResult = spawnSync("npm", ["link"], { + stdio: "inherit", + shell: process.platform === "win32", + }); + + if (linkResult.status !== 0) { + process.exit(linkResult.status ?? 1); + } +} + +main().catch((error) => { + console.error(error); + process.exit(1); +}); diff --git a/scripts/build-e2e.mjs b/scripts/build-e2e.mjs new file mode 100644 index 000000000..4c2899781 --- /dev/null +++ b/scripts/build-e2e.mjs @@ -0,0 +1,149 @@ +import fs from "node:fs"; +import path from "node:path"; +import process from "node:process"; +import { spawnSync } from "node:child_process"; +import { fileURLToPath } from "node:url"; +import { build } from "esbuild"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const ROOT = path.resolve(__dirname, ".."); +const SRC_DIR = path.join(ROOT, "evals", "deterministic"); +const OUT_BASE = path.join(ROOT, "dist", "playwright"); +const OUT_DIR = path.join(OUT_BASE, "evals", "deterministic"); +const STAGEHAND_ENTRY = path.join(ROOT, "dist", "index.js"); +const IMPORT_META_DECL = + 'var import_meta = { url: require("node:url").pathToFileURL(__filename).href };'; + +const shouldLink = (() => { + const flag = process.env.STAGEHAND_SKIP_NPM_LINK ?? ""; + return flag !== "1" && flag.toLowerCase() !== "true"; +})(); + +function ensureDir(dir) { + fs.mkdirSync(dir, { recursive: true }); +} + +function copyDir(src, dest) { + if (!fs.existsSync(src)) return; + ensureDir(dest); + for (const entry of fs.readdirSync(src, { withFileTypes: true })) { + const source = path.join(src, entry.name); + const target = path.join(dest, entry.name); + if (entry.isDirectory()) copyDir(source, target); + else fs.copyFileSync(source, target); + } +} + +function patchImportMeta(filePath) { + let content = fs.readFileSync(filePath, "utf8"); + if (!content.includes("var import_meta = {}")) { + return; + } + + const importMetaPattern = /var import_meta = \{\};/g; + if (importMetaPattern.test(content)) { + content = content.replace(importMetaPattern, IMPORT_META_DECL); + } + fs.writeFileSync(filePath, content, "utf8"); +} + +function rewriteStagehandImports(filePath) { + let content = fs.readFileSync(filePath, "utf8"); + if (!content.includes("@browserbasehq/stagehand")) { + return; + } + + const relative = path.relative(path.dirname(filePath), STAGEHAND_ENTRY); + const basePath = relative.startsWith(".") ? relative : "./" + relative; + const importPath = basePath.split(path.sep).join("/"); + + content = content.replaceAll( + 'require("@browserbasehq/stagehand")', + 'require("' + importPath + '")', + ); + content = content.replaceAll( + 'from "@browserbasehq/stagehand"', + 'from "' + importPath + '"', + ); + + fs.writeFileSync(filePath, content, "utf8"); +} + +function traverseOutputs(dir) { + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const entryPath = path.join(dir, entry.name); + if (entry.isDirectory()) { + traverseOutputs(entryPath); + } else if (entry.isFile() && entry.name.endsWith(".js")) { + patchImportMeta(entryPath); + rewriteStagehandImports(entryPath); + } + } +} + +async function main() { + ensureDir(OUT_DIR); + + const entryPoints = []; + const collectEntryPoints = (dir) => { + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const entryPath = path.join(dir, entry.name); + if (entry.isDirectory()) collectEntryPoints(entryPath); + else if (entry.isFile() && entryPath.endsWith(".ts")) { + entryPoints.push(entryPath); + } + } + }; + collectEntryPoints(SRC_DIR); + + const pkgJson = JSON.parse( + fs.readFileSync(path.join(ROOT, "package.json"), "utf8"), + ); + const externalDeps = Array.from( + new Set([ + ...Object.keys(pkgJson.dependencies ?? {}), + ...Object.keys(pkgJson.peerDependencies ?? {}), + ...Object.keys(pkgJson.optionalDependencies ?? {}), + "@playwright/test", + "playwright", + ]), + ); + + await build({ + entryPoints, + outbase: ROOT, + outdir: OUT_BASE, + platform: "node", + target: "es2022", + format: "cjs", + bundle: true, + sourcemap: true, + tsconfig: path.join(SRC_DIR, "tsconfig.playwright.json"), + packages: "external", + external: externalDeps, + banner: { + js: "var __name = (target, value) => { try { Object.defineProperty(target, 'name', { value, configurable: true }); } catch {} return target; };", + }, + logLevel: "silent", + }); + + traverseOutputs(OUT_BASE); + + copyDir(path.join(SRC_DIR, "auxiliary"), path.join(OUT_DIR, "auxiliary")); + + if (shouldLink) { + const linkResult = spawnSync("npm", ["link"], { + stdio: "inherit", + shell: process.platform === "win32", + }); + + if ((linkResult.status ?? 0) !== 0) { + process.exit(linkResult.status ?? 1); + } + } +} + +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/scripts/build-lib.mjs b/scripts/build-lib.mjs new file mode 100644 index 000000000..72f29035d --- /dev/null +++ b/scripts/build-lib.mjs @@ -0,0 +1,40 @@ +import fs from "node:fs"; +import process from "node:process"; +import { build } from "esbuild"; + +const pkgJson = JSON.parse( + fs.readFileSync(new URL("../package.json", import.meta.url)), +); +const externalDeps = Array.from( + new Set([ + ...Object.keys(pkgJson.dependencies ?? {}), + ...Object.keys(pkgJson.peerDependencies ?? {}), + ...Object.keys(pkgJson.optionalDependencies ?? {}), + ]), +); + +const commonOptions = { + bundle: true, + platform: "node", + target: "es2022", + sourcemap: true, + banner: { + js: "var __name = (target, value) => { try { Object.defineProperty(target, 'name', { value, configurable: true }); } catch {} return target; };", + }, + packages: "external", + external: externalDeps, +}; + +async function main() { + await build({ + entryPoints: ["lib/index.ts"], + format: "esm", + outfile: "dist/index.js", + ...commonOptions, + }); +} + +main().catch((error) => { + console.error(error); + process.exit(1); +}); diff --git a/scripts/run-playwright.mjs b/scripts/run-playwright.mjs new file mode 100644 index 000000000..10566db8f --- /dev/null +++ b/scripts/run-playwright.mjs @@ -0,0 +1,23 @@ +import { spawnSync } from "node:child_process"; +import { createRequire } from "node:module"; +import process from "node:process"; + +// Pass-through runner that executes the compiled Playwright config. +// We intentionally avoid tsx/ts-node to sidestep worker loader timing issues. + +const args = process.argv.slice(2); +const cliArgs = args[0] === "test" ? args : ["test", ...args]; +const require = createRequire(import.meta.url); +const playwrightCli = require.resolve("@playwright/test/cli"); + +const result = spawnSync(process.execPath, [playwrightCli, ...cliArgs], { + stdio: "inherit", + env: { ...process.env }, +}); + +if (result.error) { + console.error(result.error); + process.exit(1); +} + +process.exit(result.status ?? 0); diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 000000000..ff5b5220f --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,21 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "dist", + "noEmit": false, + "stripInternal": false + }, + "include": [ + "lib/**/*.ts", + "lib/**/*.tsx", + "types/**/*.ts" + ], + "exclude": [ + "node_modules", + "dist", + "types/evals.ts", + "evals/**" + ] +}