tabwright 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (599) hide show
  1. package/LICENSE +21 -0
  2. package/bin.js +4 -0
  3. package/dist/a11y-client.js +204 -0
  4. package/dist/agent-skills/tabwright/SKILL.md +119 -0
  5. package/dist/aria-snapshot.d.ts +262 -0
  6. package/dist/aria-snapshot.d.ts.map +1 -0
  7. package/dist/aria-snapshot.js +1256 -0
  8. package/dist/aria-snapshot.js.map +1 -0
  9. package/dist/aria-snapshot.test.d.ts +2 -0
  10. package/dist/aria-snapshot.test.d.ts.map +1 -0
  11. package/dist/aria-snapshot.test.js +270 -0
  12. package/dist/aria-snapshot.test.js.map +1 -0
  13. package/dist/aria-snapshot.unit.test.d.ts +2 -0
  14. package/dist/aria-snapshot.unit.test.d.ts.map +1 -0
  15. package/dist/aria-snapshot.unit.test.js +542 -0
  16. package/dist/aria-snapshot.unit.test.js.map +1 -0
  17. package/dist/assets/cursors/screen-studio/pointer-macos-tahoe-data-url.d.ts +5 -0
  18. package/dist/assets/cursors/screen-studio/pointer-macos-tahoe-data-url.d.ts.map +1 -0
  19. package/dist/assets/cursors/screen-studio/pointer-macos-tahoe-data-url.js +5 -0
  20. package/dist/assets/cursors/screen-studio/pointer-macos-tahoe-data-url.js.map +1 -0
  21. package/dist/bippy.js +894 -0
  22. package/dist/browser-config.d.ts +13 -0
  23. package/dist/browser-config.d.ts.map +1 -0
  24. package/dist/browser-config.js +126 -0
  25. package/dist/browser-config.js.map +1 -0
  26. package/dist/browser-install.d.ts +16 -0
  27. package/dist/browser-install.d.ts.map +1 -0
  28. package/dist/browser-install.js +238 -0
  29. package/dist/browser-install.js.map +1 -0
  30. package/dist/browser-launch.d.ts +17 -0
  31. package/dist/browser-launch.d.ts.map +1 -0
  32. package/dist/browser-launch.js +44 -0
  33. package/dist/browser-launch.js.map +1 -0
  34. package/dist/builtin-capabilities.d.ts +28 -0
  35. package/dist/builtin-capabilities.d.ts.map +1 -0
  36. package/dist/builtin-capabilities.js +2673 -0
  37. package/dist/builtin-capabilities.js.map +1 -0
  38. package/dist/capability-agent-skill.d.ts +60 -0
  39. package/dist/capability-agent-skill.d.ts.map +1 -0
  40. package/dist/capability-agent-skill.js +225 -0
  41. package/dist/capability-agent-skill.js.map +1 -0
  42. package/dist/capability-auth-state.d.ts +34 -0
  43. package/dist/capability-auth-state.d.ts.map +1 -0
  44. package/dist/capability-auth-state.js +157 -0
  45. package/dist/capability-auth-state.js.map +1 -0
  46. package/dist/capability-auth.d.ts +36 -0
  47. package/dist/capability-auth.d.ts.map +1 -0
  48. package/dist/capability-auth.js +198 -0
  49. package/dist/capability-auth.js.map +1 -0
  50. package/dist/capability-cli-confirmation.test.d.ts +2 -0
  51. package/dist/capability-cli-confirmation.test.d.ts.map +1 -0
  52. package/dist/capability-cli-confirmation.test.js +79 -0
  53. package/dist/capability-cli-confirmation.test.js.map +1 -0
  54. package/dist/capability-options.d.ts +20 -0
  55. package/dist/capability-options.d.ts.map +1 -0
  56. package/dist/capability-options.js +31 -0
  57. package/dist/capability-options.js.map +1 -0
  58. package/dist/capability-options.test.d.ts +2 -0
  59. package/dist/capability-options.test.d.ts.map +1 -0
  60. package/dist/capability-options.test.js +81 -0
  61. package/dist/capability-options.test.js.map +1 -0
  62. package/dist/capability-package.d.ts +27 -0
  63. package/dist/capability-package.d.ts.map +1 -0
  64. package/dist/capability-package.js +444 -0
  65. package/dist/capability-package.js.map +1 -0
  66. package/dist/capability-package.test.d.ts +2 -0
  67. package/dist/capability-package.test.d.ts.map +1 -0
  68. package/dist/capability-package.test.js +179 -0
  69. package/dist/capability-package.test.js.map +1 -0
  70. package/dist/capability-registry.d.ts +262 -0
  71. package/dist/capability-registry.d.ts.map +1 -0
  72. package/dist/capability-registry.js +931 -0
  73. package/dist/capability-registry.js.map +1 -0
  74. package/dist/capability-registry.test.d.ts +2 -0
  75. package/dist/capability-registry.test.d.ts.map +1 -0
  76. package/dist/capability-registry.test.js +1683 -0
  77. package/dist/capability-registry.test.js.map +1 -0
  78. package/dist/capability-runner.d.ts +99 -0
  79. package/dist/capability-runner.d.ts.map +1 -0
  80. package/dist/capability-runner.js +608 -0
  81. package/dist/capability-runner.js.map +1 -0
  82. package/dist/capability-search-relevance.test.d.ts +2 -0
  83. package/dist/capability-search-relevance.test.d.ts.map +1 -0
  84. package/dist/capability-search-relevance.test.js +67 -0
  85. package/dist/capability-search-relevance.test.js.map +1 -0
  86. package/dist/capability-studio.d.ts +11 -0
  87. package/dist/capability-studio.d.ts.map +1 -0
  88. package/dist/capability-studio.js +593 -0
  89. package/dist/capability-studio.js.map +1 -0
  90. package/dist/capability-studio.test.d.ts +2 -0
  91. package/dist/capability-studio.test.d.ts.map +1 -0
  92. package/dist/capability-studio.test.js +41 -0
  93. package/dist/capability-studio.test.js.map +1 -0
  94. package/dist/cdp-log.d.ts +19 -0
  95. package/dist/cdp-log.d.ts.map +1 -0
  96. package/dist/cdp-log.js +83 -0
  97. package/dist/cdp-log.js.map +1 -0
  98. package/dist/cdp-log.test.d.ts +2 -0
  99. package/dist/cdp-log.test.d.ts.map +1 -0
  100. package/dist/cdp-log.test.js +109 -0
  101. package/dist/cdp-log.test.js.map +1 -0
  102. package/dist/cdp-relay.d.ts +19 -0
  103. package/dist/cdp-relay.d.ts.map +1 -0
  104. package/dist/cdp-relay.js +2375 -0
  105. package/dist/cdp-relay.js.map +1 -0
  106. package/dist/cdp-session.d.ts +37 -0
  107. package/dist/cdp-session.d.ts.map +1 -0
  108. package/dist/cdp-session.js +36 -0
  109. package/dist/cdp-session.js.map +1 -0
  110. package/dist/cdp-types.d.ts +65 -0
  111. package/dist/cdp-types.d.ts.map +1 -0
  112. package/dist/cdp-types.js +91 -0
  113. package/dist/cdp-types.js.map +1 -0
  114. package/dist/channel-owner-inspect.test.d.ts +2 -0
  115. package/dist/channel-owner-inspect.test.d.ts.map +1 -0
  116. package/dist/channel-owner-inspect.test.js +75 -0
  117. package/dist/channel-owner-inspect.test.js.map +1 -0
  118. package/dist/chrome-discovery.d.ts +65 -0
  119. package/dist/chrome-discovery.d.ts.map +1 -0
  120. package/dist/chrome-discovery.js +173 -0
  121. package/dist/chrome-discovery.js.map +1 -0
  122. package/dist/chrome-discovery.test.d.ts +2 -0
  123. package/dist/chrome-discovery.test.d.ts.map +1 -0
  124. package/dist/chrome-discovery.test.js +41 -0
  125. package/dist/chrome-discovery.test.js.map +1 -0
  126. package/dist/clean-html.d.ts +11 -0
  127. package/dist/clean-html.d.ts.map +1 -0
  128. package/dist/clean-html.js +106 -0
  129. package/dist/clean-html.js.map +1 -0
  130. package/dist/cli-help.test.d.ts +2 -0
  131. package/dist/cli-help.test.d.ts.map +1 -0
  132. package/dist/cli-help.test.js +98 -0
  133. package/dist/cli-help.test.js.map +1 -0
  134. package/dist/cli.d.ts +3 -0
  135. package/dist/cli.d.ts.map +1 -0
  136. package/dist/cli.js +2709 -0
  137. package/dist/cli.js.map +1 -0
  138. package/dist/cloud-client.d.ts +56 -0
  139. package/dist/cloud-client.d.ts.map +1 -0
  140. package/dist/cloud-client.js +127 -0
  141. package/dist/cloud-client.js.map +1 -0
  142. package/dist/create-logger.d.ts +9 -0
  143. package/dist/create-logger.d.ts.map +1 -0
  144. package/dist/create-logger.js +27 -0
  145. package/dist/create-logger.js.map +1 -0
  146. package/dist/debugger-api.md +458 -0
  147. package/dist/debugger-examples-types.d.ts +24 -0
  148. package/dist/debugger-examples-types.d.ts.map +1 -0
  149. package/dist/debugger-examples-types.js +2 -0
  150. package/dist/debugger-examples-types.js.map +1 -0
  151. package/dist/debugger-examples.d.ts +6 -0
  152. package/dist/debugger-examples.d.ts.map +1 -0
  153. package/dist/debugger-examples.js +53 -0
  154. package/dist/debugger-examples.js.map +1 -0
  155. package/dist/debugger.d.ts +381 -0
  156. package/dist/debugger.d.ts.map +1 -0
  157. package/dist/debugger.js +630 -0
  158. package/dist/debugger.js.map +1 -0
  159. package/dist/diff-utils.d.ts +20 -0
  160. package/dist/diff-utils.d.ts.map +1 -0
  161. package/dist/diff-utils.js +50 -0
  162. package/dist/diff-utils.js.map +1 -0
  163. package/dist/diff-utils.test.d.ts +2 -0
  164. package/dist/diff-utils.test.d.ts.map +1 -0
  165. package/dist/diff-utils.test.js +137 -0
  166. package/dist/diff-utils.test.js.map +1 -0
  167. package/dist/doctor.d.ts +44 -0
  168. package/dist/doctor.d.ts.map +1 -0
  169. package/dist/doctor.js +246 -0
  170. package/dist/doctor.js.map +1 -0
  171. package/dist/doctor.test.d.ts +2 -0
  172. package/dist/doctor.test.d.ts.map +1 -0
  173. package/dist/doctor.test.js +208 -0
  174. package/dist/doctor.test.js.map +1 -0
  175. package/dist/editor-api.md +374 -0
  176. package/dist/editor-examples.d.ts +11 -0
  177. package/dist/editor-examples.d.ts.map +1 -0
  178. package/dist/editor-examples.js +124 -0
  179. package/dist/editor-examples.js.map +1 -0
  180. package/dist/editor.d.ts +203 -0
  181. package/dist/editor.d.ts.map +1 -0
  182. package/dist/editor.js +363 -0
  183. package/dist/editor.js.map +1 -0
  184. package/dist/env-compat.d.ts +2 -0
  185. package/dist/env-compat.d.ts.map +1 -0
  186. package/dist/env-compat.js +27 -0
  187. package/dist/env-compat.js.map +1 -0
  188. package/dist/executor.d.ts +229 -0
  189. package/dist/executor.d.ts.map +1 -0
  190. package/dist/executor.js +1465 -0
  191. package/dist/executor.js.map +1 -0
  192. package/dist/executor.unit.test.d.ts +2 -0
  193. package/dist/executor.unit.test.d.ts.map +1 -0
  194. package/dist/executor.unit.test.js +143 -0
  195. package/dist/executor.unit.test.js.map +1 -0
  196. package/dist/extension/_locales/en/messages.json +278 -0
  197. package/dist/extension/_locales/zh_CN/messages.json +256 -0
  198. package/dist/extension/assets/options-CYH96Lcx.css +1349 -0
  199. package/dist/extension/background.js +3994 -0
  200. package/dist/extension/icons/SolarCursorSquareBold.png +0 -0
  201. package/dist/extension/icons/icon-black-128.png +0 -0
  202. package/dist/extension/icons/icon-black-16.png +0 -0
  203. package/dist/extension/icons/icon-black-32.png +0 -0
  204. package/dist/extension/icons/icon-black-48.png +0 -0
  205. package/dist/extension/icons/icon-gray-128.png +0 -0
  206. package/dist/extension/icons/icon-gray-16.png +0 -0
  207. package/dist/extension/icons/icon-gray-32.png +0 -0
  208. package/dist/extension/icons/icon-gray-48.png +0 -0
  209. package/dist/extension/icons/icon-green-128.png +0 -0
  210. package/dist/extension/icons/icon-green-16.png +0 -0
  211. package/dist/extension/icons/icon-green-32.png +0 -0
  212. package/dist/extension/icons/icon-green-48.png +0 -0
  213. package/dist/extension/icons/tabwright-icon-black.png +0 -0
  214. package/dist/extension/icons/tabwright-icon-gray-disabled.png +0 -0
  215. package/dist/extension/icons/tabwright-icon-gray-disabled.svg +1 -0
  216. package/dist/extension/manifest.json +54 -0
  217. package/dist/extension/options.js +16145 -0
  218. package/dist/extension/rrweb-recorder.js +12952 -0
  219. package/dist/extension/src/options.html +165 -0
  220. package/dist/extension/src/prism-bash.min.js +1 -0
  221. package/dist/extension/src/prism.min.js +1 -0
  222. package/dist/extension/src/welcome.html +396 -0
  223. package/dist/extension-connection.test.d.ts +2 -0
  224. package/dist/extension-connection.test.d.ts.map +1 -0
  225. package/dist/extension-connection.test.js +708 -0
  226. package/dist/extension-connection.test.js.map +1 -0
  227. package/dist/extension-icon-warning.test.d.ts +2 -0
  228. package/dist/extension-icon-warning.test.d.ts.map +1 -0
  229. package/dist/extension-icon-warning.test.js +33 -0
  230. package/dist/extension-icon-warning.test.js.map +1 -0
  231. package/dist/ghost-browser.d.ts +62 -0
  232. package/dist/ghost-browser.d.ts.map +1 -0
  233. package/dist/ghost-browser.js +107 -0
  234. package/dist/ghost-browser.js.map +1 -0
  235. package/dist/ghost-cursor-client.js +374 -0
  236. package/dist/ghost-cursor-controller.d.ts +46 -0
  237. package/dist/ghost-cursor-controller.d.ts.map +1 -0
  238. package/dist/ghost-cursor-controller.js +98 -0
  239. package/dist/ghost-cursor-controller.js.map +1 -0
  240. package/dist/ghost-cursor.d.ts +27 -0
  241. package/dist/ghost-cursor.d.ts.map +1 -0
  242. package/dist/ghost-cursor.js +79 -0
  243. package/dist/ghost-cursor.js.map +1 -0
  244. package/dist/htmlrewrite.d.ts +8 -0
  245. package/dist/htmlrewrite.d.ts.map +1 -0
  246. package/dist/htmlrewrite.js +339 -0
  247. package/dist/htmlrewrite.js.map +1 -0
  248. package/dist/htmlrewrite.test.d.ts +2 -0
  249. package/dist/htmlrewrite.test.d.ts.map +1 -0
  250. package/dist/htmlrewrite.test.js +7975 -0
  251. package/dist/htmlrewrite.test.js.map +1 -0
  252. package/dist/index.d.ts +20 -0
  253. package/dist/index.d.ts.map +1 -0
  254. package/dist/index.js +11 -0
  255. package/dist/index.js.map +1 -0
  256. package/dist/kill-port.d.ts +29 -0
  257. package/dist/kill-port.d.ts.map +1 -0
  258. package/dist/kill-port.js +190 -0
  259. package/dist/kill-port.js.map +1 -0
  260. package/dist/kitty-graphics.d.ts +22 -0
  261. package/dist/kitty-graphics.d.ts.map +1 -0
  262. package/dist/kitty-graphics.js +71 -0
  263. package/dist/kitty-graphics.js.map +1 -0
  264. package/dist/kitty-graphics.test.d.ts +2 -0
  265. package/dist/kitty-graphics.test.d.ts.map +1 -0
  266. package/dist/kitty-graphics.test.js +125 -0
  267. package/dist/kitty-graphics.test.js.map +1 -0
  268. package/dist/locator-selector.test.d.ts +2 -0
  269. package/dist/locator-selector.test.d.ts.map +1 -0
  270. package/dist/locator-selector.test.js +98 -0
  271. package/dist/locator-selector.test.js.map +1 -0
  272. package/dist/mcp-client.d.ts +20 -0
  273. package/dist/mcp-client.d.ts.map +1 -0
  274. package/dist/mcp-client.js +56 -0
  275. package/dist/mcp-client.js.map +1 -0
  276. package/dist/mcp.d.ts +6 -0
  277. package/dist/mcp.d.ts.map +1 -0
  278. package/dist/mcp.js +511 -0
  279. package/dist/mcp.js.map +1 -0
  280. package/dist/on-mouse-action.test.d.ts +2 -0
  281. package/dist/on-mouse-action.test.d.ts.map +1 -0
  282. package/dist/on-mouse-action.test.js +180 -0
  283. package/dist/on-mouse-action.test.js.map +1 -0
  284. package/dist/options-page.test.d.ts +2 -0
  285. package/dist/options-page.test.d.ts.map +1 -0
  286. package/dist/options-page.test.js +773 -0
  287. package/dist/options-page.test.js.map +1 -0
  288. package/dist/package-paths.d.ts +4 -0
  289. package/dist/package-paths.d.ts.map +1 -0
  290. package/dist/package-paths.js +30 -0
  291. package/dist/package-paths.js.map +1 -0
  292. package/dist/page-markdown.d.ts +40 -0
  293. package/dist/page-markdown.d.ts.map +1 -0
  294. package/dist/page-markdown.js +181 -0
  295. package/dist/page-markdown.js.map +1 -0
  296. package/dist/performance-examples.d.ts +5 -0
  297. package/dist/performance-examples.d.ts.map +1 -0
  298. package/dist/performance-examples.js +112 -0
  299. package/dist/performance-examples.js.map +1 -0
  300. package/dist/performance-profiling.md +417 -0
  301. package/dist/playwright-import.d.ts +19 -0
  302. package/dist/playwright-import.d.ts.map +1 -0
  303. package/dist/playwright-import.js +40 -0
  304. package/dist/playwright-import.js.map +1 -0
  305. package/dist/popup-relocation.test.d.ts +7 -0
  306. package/dist/popup-relocation.test.d.ts.map +1 -0
  307. package/dist/popup-relocation.test.js +139 -0
  308. package/dist/popup-relocation.test.js.map +1 -0
  309. package/dist/product-paths.d.ts +9 -0
  310. package/dist/product-paths.d.ts.map +1 -0
  311. package/dist/product-paths.js +24 -0
  312. package/dist/product-paths.js.map +1 -0
  313. package/dist/product-paths.test.d.ts +2 -0
  314. package/dist/product-paths.test.d.ts.map +1 -0
  315. package/dist/product-paths.test.js +39 -0
  316. package/dist/product-paths.test.js.map +1 -0
  317. package/dist/prompt.md +1004 -0
  318. package/dist/protocol.d.ts +248 -0
  319. package/dist/protocol.d.ts.map +1 -0
  320. package/dist/protocol.js +59 -0
  321. package/dist/protocol.js.map +1 -0
  322. package/dist/protocol.test.d.ts +2 -0
  323. package/dist/protocol.test.d.ts.map +1 -0
  324. package/dist/protocol.test.js +31 -0
  325. package/dist/protocol.test.js.map +1 -0
  326. package/dist/react-source.d.ts +57 -0
  327. package/dist/react-source.d.ts.map +1 -0
  328. package/dist/react-source.js +254 -0
  329. package/dist/react-source.js.map +1 -0
  330. package/dist/readability.js +1674 -0
  331. package/dist/relay-client.d.ts +104 -0
  332. package/dist/relay-client.d.ts.map +1 -0
  333. package/dist/relay-client.js +426 -0
  334. package/dist/relay-client.js.map +1 -0
  335. package/dist/relay-client.test.d.ts +2 -0
  336. package/dist/relay-client.test.d.ts.map +1 -0
  337. package/dist/relay-client.test.js +305 -0
  338. package/dist/relay-client.test.js.map +1 -0
  339. package/dist/relay-core.test.d.ts +2 -0
  340. package/dist/relay-core.test.d.ts.map +1 -0
  341. package/dist/relay-core.test.js +1427 -0
  342. package/dist/relay-core.test.js.map +1 -0
  343. package/dist/relay-navigation.test.d.ts +2 -0
  344. package/dist/relay-navigation.test.d.ts.map +1 -0
  345. package/dist/relay-navigation.test.js +661 -0
  346. package/dist/relay-navigation.test.js.map +1 -0
  347. package/dist/relay-session.test.d.ts +2 -0
  348. package/dist/relay-session.test.d.ts.map +1 -0
  349. package/dist/relay-session.test.js +1121 -0
  350. package/dist/relay-session.test.js.map +1 -0
  351. package/dist/relay-state.d.ts +178 -0
  352. package/dist/relay-state.d.ts.map +1 -0
  353. package/dist/relay-state.js +346 -0
  354. package/dist/relay-state.js.map +1 -0
  355. package/dist/relay-state.test.d.ts +2 -0
  356. package/dist/relay-state.test.d.ts.map +1 -0
  357. package/dist/relay-state.test.js +594 -0
  358. package/dist/relay-state.test.js.map +1 -0
  359. package/dist/replay-ai-index.d.ts +99 -0
  360. package/dist/replay-ai-index.d.ts.map +1 -0
  361. package/dist/replay-ai-index.js +677 -0
  362. package/dist/replay-ai-index.js.map +1 -0
  363. package/dist/replay-ai-index.test.d.ts +2 -0
  364. package/dist/replay-ai-index.test.d.ts.map +1 -0
  365. package/dist/replay-ai-index.test.js +255 -0
  366. package/dist/replay-ai-index.test.js.map +1 -0
  367. package/dist/replay-cli.test.d.ts +2 -0
  368. package/dist/replay-cli.test.d.ts.map +1 -0
  369. package/dist/replay-cli.test.js +275 -0
  370. package/dist/replay-cli.test.js.map +1 -0
  371. package/dist/replay-eval.d.ts +44 -0
  372. package/dist/replay-eval.d.ts.map +1 -0
  373. package/dist/replay-eval.js +902 -0
  374. package/dist/replay-eval.js.map +1 -0
  375. package/dist/replay-handoff.d.ts +29 -0
  376. package/dist/replay-handoff.d.ts.map +1 -0
  377. package/dist/replay-handoff.js +83 -0
  378. package/dist/replay-handoff.js.map +1 -0
  379. package/dist/replay-handoff.test.d.ts +2 -0
  380. package/dist/replay-handoff.test.d.ts.map +1 -0
  381. package/dist/replay-handoff.test.js +123 -0
  382. package/dist/replay-handoff.test.js.map +1 -0
  383. package/dist/replay-workflow-compiler.d.ts +44 -0
  384. package/dist/replay-workflow-compiler.d.ts.map +1 -0
  385. package/dist/replay-workflow-compiler.js +601 -0
  386. package/dist/replay-workflow-compiler.js.map +1 -0
  387. package/dist/replay-workflow-compiler.test.d.ts +2 -0
  388. package/dist/replay-workflow-compiler.test.d.ts.map +1 -0
  389. package/dist/replay-workflow-compiler.test.js +223 -0
  390. package/dist/replay-workflow-compiler.test.js.map +1 -0
  391. package/dist/rrweb-recording-relay.d.ts +56 -0
  392. package/dist/rrweb-recording-relay.d.ts.map +1 -0
  393. package/dist/rrweb-recording-relay.js +299 -0
  394. package/dist/rrweb-recording-relay.js.map +1 -0
  395. package/dist/rrweb-recording-relay.test.d.ts +2 -0
  396. package/dist/rrweb-recording-relay.test.d.ts.map +1 -0
  397. package/dist/rrweb-recording-relay.test.js +85 -0
  398. package/dist/rrweb-recording-relay.test.js.map +1 -0
  399. package/dist/rrweb-recording.d.ts +104 -0
  400. package/dist/rrweb-recording.d.ts.map +1 -0
  401. package/dist/rrweb-recording.js +180 -0
  402. package/dist/rrweb-recording.js.map +1 -0
  403. package/dist/scoped-fs.d.ts +95 -0
  404. package/dist/scoped-fs.d.ts.map +1 -0
  405. package/dist/scoped-fs.js +358 -0
  406. package/dist/scoped-fs.js.map +1 -0
  407. package/dist/scoped-fs.test.d.ts +5 -0
  408. package/dist/scoped-fs.test.d.ts.map +1 -0
  409. package/dist/scoped-fs.test.js +73 -0
  410. package/dist/scoped-fs.test.js.map +1 -0
  411. package/dist/selector-generator.js +7378 -0
  412. package/dist/skill-stub.test.d.ts +2 -0
  413. package/dist/skill-stub.test.d.ts.map +1 -0
  414. package/dist/skill-stub.test.js +22 -0
  415. package/dist/skill-stub.test.js.map +1 -0
  416. package/dist/snapshot-tools.test.d.ts +2 -0
  417. package/dist/snapshot-tools.test.d.ts.map +1 -0
  418. package/dist/snapshot-tools.test.js +856 -0
  419. package/dist/snapshot-tools.test.js.map +1 -0
  420. package/dist/start-relay-server.d.ts +6 -0
  421. package/dist/start-relay-server.d.ts.map +1 -0
  422. package/dist/start-relay-server.js +57 -0
  423. package/dist/start-relay-server.js.map +1 -0
  424. package/dist/styles-api.md +124 -0
  425. package/dist/styles-examples.d.ts +8 -0
  426. package/dist/styles-examples.d.ts.map +1 -0
  427. package/dist/styles-examples.js +64 -0
  428. package/dist/styles-examples.js.map +1 -0
  429. package/dist/styles.d.ts +27 -0
  430. package/dist/styles.d.ts.map +1 -0
  431. package/dist/styles.js +231 -0
  432. package/dist/styles.js.map +1 -0
  433. package/dist/tabwright-agent-skill.d.ts +30 -0
  434. package/dist/tabwright-agent-skill.d.ts.map +1 -0
  435. package/dist/tabwright-agent-skill.js +74 -0
  436. package/dist/tabwright-agent-skill.js.map +1 -0
  437. package/dist/tabwright-agent-skill.test.d.ts +2 -0
  438. package/dist/tabwright-agent-skill.test.d.ts.map +1 -0
  439. package/dist/tabwright-agent-skill.test.js +51 -0
  440. package/dist/tabwright-agent-skill.test.js.map +1 -0
  441. package/dist/test-declarations.d.ts +13 -0
  442. package/dist/test-declarations.d.ts.map +1 -0
  443. package/dist/test-declarations.js +2 -0
  444. package/dist/test-declarations.js.map +1 -0
  445. package/dist/test-utils.d.ts +69 -0
  446. package/dist/test-utils.d.ts.map +1 -0
  447. package/dist/test-utils.js +448 -0
  448. package/dist/test-utils.js.map +1 -0
  449. package/dist/test-utils.test.d.ts +2 -0
  450. package/dist/test-utils.test.d.ts.map +1 -0
  451. package/dist/test-utils.test.js +55 -0
  452. package/dist/test-utils.test.js.map +1 -0
  453. package/dist/utils.d.ts +26 -0
  454. package/dist/utils.d.ts.map +1 -0
  455. package/dist/utils.js +60 -0
  456. package/dist/utils.js.map +1 -0
  457. package/dist/wait-for-page-load.d.ts +16 -0
  458. package/dist/wait-for-page-load.d.ts.map +1 -0
  459. package/dist/wait-for-page-load.js +146 -0
  460. package/dist/wait-for-page-load.js.map +1 -0
  461. package/dist/workflow-capability.d.ts +72 -0
  462. package/dist/workflow-capability.d.ts.map +1 -0
  463. package/dist/workflow-capability.js +316 -0
  464. package/dist/workflow-capability.js.map +1 -0
  465. package/dist/workflow-script-flow.test.d.ts +2 -0
  466. package/dist/workflow-script-flow.test.d.ts.map +1 -0
  467. package/dist/workflow-script-flow.test.js +285 -0
  468. package/dist/workflow-script-flow.test.js.map +1 -0
  469. package/package.json +80 -0
  470. package/src/__snapshots__/x.com.processed.html +1003 -0
  471. package/src/__snapshots__/x.com.processed.withStyles.html +2720 -0
  472. package/src/a11y-client.ts +241 -0
  473. package/src/agent-skills/conan-config/SKILL.md +141 -0
  474. package/src/agent-skills/conan-config/agents/openai.yaml +4 -0
  475. package/src/aria-snapshot.test.ts +311 -0
  476. package/src/aria-snapshot.ts +1681 -0
  477. package/src/aria-snapshot.unit.test.ts +615 -0
  478. package/src/aria-snapshots/github-interactive.txt +193 -0
  479. package/src/aria-snapshots/github-raw.txt +309 -0
  480. package/src/aria-snapshots/hackernews-interactive.txt +477 -0
  481. package/src/aria-snapshots/hackernews-raw.txt +428 -0
  482. package/src/aria-snapshots/prosemirror-interactive.txt +66 -0
  483. package/src/aria-snapshots/prosemirror-raw.txt +145 -0
  484. package/src/assets/aria-labels-hacker-news.png +0 -0
  485. package/src/assets/aria-labels-old-reddit.png +0 -0
  486. package/src/assets/cursors/screen-studio/pointer-macos-tahoe-data-url.ts +5 -0
  487. package/src/assets/cursors/screen-studio/pointer-macos-tahoe.svg +18 -0
  488. package/src/assets/x.com.html +32946 -0
  489. package/src/browser-config.ts +179 -0
  490. package/src/browser-install.ts +284 -0
  491. package/src/browser-launch.ts +75 -0
  492. package/src/builtin-capabilities.ts +2765 -0
  493. package/src/capability-agent-skill.ts +305 -0
  494. package/src/capability-auth-state.ts +197 -0
  495. package/src/capability-auth.ts +249 -0
  496. package/src/capability-cli-confirmation.test.ts +90 -0
  497. package/src/capability-options.test.ts +89 -0
  498. package/src/capability-options.ts +57 -0
  499. package/src/capability-package.test.ts +204 -0
  500. package/src/capability-package.ts +555 -0
  501. package/src/capability-registry.test.ts +1905 -0
  502. package/src/capability-registry.ts +1234 -0
  503. package/src/capability-runner.ts +801 -0
  504. package/src/capability-search-relevance.test.ts +73 -0
  505. package/src/capability-studio.test.ts +45 -0
  506. package/src/capability-studio.ts +641 -0
  507. package/src/cdp-log.test.ts +131 -0
  508. package/src/cdp-log.ts +112 -0
  509. package/src/cdp-relay.ts +2944 -0
  510. package/src/cdp-session.ts +77 -0
  511. package/src/cdp-types.ts +158 -0
  512. package/src/channel-owner-inspect.test.ts +94 -0
  513. package/src/chrome-discovery.test.ts +50 -0
  514. package/src/chrome-discovery.ts +220 -0
  515. package/src/clean-html.ts +141 -0
  516. package/src/cli-help.test.ts +123 -0
  517. package/src/cli.ts +3181 -0
  518. package/src/cloud-client.ts +179 -0
  519. package/src/create-logger.ts +38 -0
  520. package/src/debugger-examples-types.ts +16 -0
  521. package/src/debugger-examples.ts +66 -0
  522. package/src/debugger.ts +708 -0
  523. package/src/diff-utils.test.ts +152 -0
  524. package/src/diff-utils.ts +70 -0
  525. package/src/doctor.test.ts +244 -0
  526. package/src/doctor.ts +321 -0
  527. package/src/editor-examples.ts +158 -0
  528. package/src/editor.ts +426 -0
  529. package/src/env-compat.ts +28 -0
  530. package/src/executor.ts +1824 -0
  531. package/src/executor.unit.test.ts +168 -0
  532. package/src/extension-connection.test.ts +855 -0
  533. package/src/extension-icon-warning.test.ts +45 -0
  534. package/src/ghost-browser.ts +149 -0
  535. package/src/ghost-cursor-client.ts +494 -0
  536. package/src/ghost-cursor-controller.ts +129 -0
  537. package/src/ghost-cursor.ts +123 -0
  538. package/src/htmlrewrite.test.ts +8008 -0
  539. package/src/htmlrewrite.ts +390 -0
  540. package/src/index.ts +53 -0
  541. package/src/kill-port.ts +219 -0
  542. package/src/kitty-graphics.test.ts +139 -0
  543. package/src/kitty-graphics.ts +79 -0
  544. package/src/locator-selector.test.ts +119 -0
  545. package/src/mcp-client.ts +78 -0
  546. package/src/mcp.ts +629 -0
  547. package/src/on-mouse-action.test.ts +226 -0
  548. package/src/options-page.test.ts +839 -0
  549. package/src/package-paths.ts +38 -0
  550. package/src/page-markdown.ts +240 -0
  551. package/src/performance-examples.ts +186 -0
  552. package/src/playwright-import.ts +59 -0
  553. package/src/popup-relocation.test.ts +163 -0
  554. package/src/product-paths.test.ts +47 -0
  555. package/src/product-paths.ts +28 -0
  556. package/src/protocol.test.ts +52 -0
  557. package/src/protocol.ts +351 -0
  558. package/src/react-source.ts +379 -0
  559. package/src/relay-client.test.ts +375 -0
  560. package/src/relay-client.ts +572 -0
  561. package/src/relay-core.test.ts +1603 -0
  562. package/src/relay-navigation.test.ts +790 -0
  563. package/src/relay-session.test.ts +1375 -0
  564. package/src/relay-state.test.ts +729 -0
  565. package/src/relay-state.ts +561 -0
  566. package/src/replay-ai-index.test.ts +278 -0
  567. package/src/replay-ai-index.ts +872 -0
  568. package/src/replay-cli.test.ts +325 -0
  569. package/src/replay-eval.ts +1039 -0
  570. package/src/replay-handoff.test.ts +163 -0
  571. package/src/replay-handoff.ts +109 -0
  572. package/src/replay-workflow-compiler.test.ts +250 -0
  573. package/src/replay-workflow-compiler.ts +700 -0
  574. package/src/resource.md +409 -0
  575. package/src/rrweb-recording-relay.test.ts +99 -0
  576. package/src/rrweb-recording-relay.ts +400 -0
  577. package/src/rrweb-recording.ts +322 -0
  578. package/src/scoped-fs.test.ts +80 -0
  579. package/src/scoped-fs.ts +420 -0
  580. package/src/skill-stub.test.ts +24 -0
  581. package/src/skill.md +1413 -0
  582. package/src/snapshot-tools.test.ts +1017 -0
  583. package/src/snapshots/hacker-news-accessibility-full.md +81 -0
  584. package/src/snapshots/hacker-news-accessibility-interactive.md +43 -0
  585. package/src/snapshots/page-markdown-output.txt +16 -0
  586. package/src/snapshots/shadcn-ui-accessibility-full.md +201 -0
  587. package/src/snapshots/shadcn-ui-accessibility-interactive.md +109 -0
  588. package/src/start-relay-server.ts +69 -0
  589. package/src/styles-examples.ts +84 -0
  590. package/src/styles.ts +343 -0
  591. package/src/tabwright-agent-skill.test.ts +61 -0
  592. package/src/tabwright-agent-skill.ts +105 -0
  593. package/src/test-declarations.ts +13 -0
  594. package/src/test-utils.test.ts +70 -0
  595. package/src/test-utils.ts +566 -0
  596. package/src/utils.ts +78 -0
  597. package/src/wait-for-page-load.ts +198 -0
  598. package/src/workflow-capability.ts +417 -0
  599. package/src/workflow-script-flow.test.ts +388 -0
package/dist/prompt.md ADDED
@@ -0,0 +1,1004 @@
1
+ # tabwright best practices
2
+
3
+ Control user's Chrome browser via playwright code snippets. Prefer single-line code with semicolons between statements. Use tabwright immediately without waiting for user actions; only if you get "extension is not connected" or "no browser tabs have Tabwright enabled" should you ask the user to click the tabwright extension icon on the target tab.
4
+
5
+ **When to use tabwright instead of webfetch/curl:** If a website is JS-heavy (SPAs like Instagram, Twitter, Facebook, etc.), has cookie consent modals, login walls, lazy-loaded content, carousels, or infinite scroll — **always use tabwright**. Simple fetch/webfetch will return an empty HTML shell with no content. Do NOT waste time trying curl, webfetch, or parsing raw HTML from JS-rendered sites. Go straight to tabwright: navigate with a real browser, dismiss modals, then extract what you need via `page.evaluate()` or network interception.
6
+
7
+ **If Chrome is not running**, the extension can't connect. Start Chrome from the command line before retrying:
8
+
9
+ ```bash
10
+ # macOS
11
+ open -a "Google Chrome" --args --profile-directory=Default
12
+
13
+ # Linux
14
+ google-chrome --profile-directory=Default &
15
+
16
+ # Windows (cmd)
17
+ start chrome.exe --profile-directory=Default
18
+
19
+ # Windows (PowerShell)
20
+ Start-Process chrome.exe -ArgumentList '--profile-directory=Default'
21
+ ```
22
+
23
+ You can collaborate with the user - they can help with captchas, difficult elements, or reproducing bugs.
24
+
25
+ **Direct CDP mode (no extension needed):** Tabwright can connect directly to Chrome's DevTools Protocol, bypassing the extension. This is useful in CI, Docker, headless environments, when Chrome has `--remote-debugging-port=9222`, or with cloud browser providers (e.g. `wss://xxx.cdp.browser-use.com`). If the user provides a CDP URL, set `TABWRIGHT_DIRECT` in the MCP client config:
26
+
27
+ ```json
28
+ {
29
+ "mcpServers": {
30
+ "tabwright": {
31
+ "command": "npx",
32
+ "args": ["-y", "tabwright@latest"],
33
+ "env": {
34
+ "TABWRIGHT_DIRECT": "wss://xxx.cdp.browser-use.com"
35
+ }
36
+ }
37
+ }
38
+ }
39
+ ```
40
+
41
+ `TABWRIGHT_DIRECT` accepts `1` (auto-discover Chrome on port 9222), a `ws://` or `wss://` endpoint (including cloud browser providers), or `host:port`. Extension-side replay recording is not available in direct CDP mode.
42
+
43
+ ## context variables
44
+
45
+ - `state` - object persisted between calls **within your session**. Each session has its own isolated state. Use to store pages, data, listeners (e.g., `state.page = await context.newPage()`)
46
+ - `page` - a default page (may be shared with other agents). Prefer creating your own page and storing it in `state` (see "working with pages")
47
+ - `context` - browser context, access all pages via `context.pages()`
48
+ - `require` - load Node.js modules (e.g., `const fs = require('node:fs')`). ESM `import` is not available in the sandbox
49
+ - Node.js globals: `setTimeout`, `setInterval`, `fetch`, `URL`, `Buffer`, `crypto`, `process`, etc.
50
+
51
+ **Not available in the sandbox:** `__dirname`, `__filename`, `import`.
52
+
53
+ **Important:** `state` is **session-isolated** but pages are **shared** across all sessions. See "working with pages" for how to avoid interference.
54
+
55
+ **Sandboxed `fs` write restrictions:** `require('node:fs')` is scoped. Writes (writeFileSync, mkdirSync, etc.) only succeed in:
56
+ - The **directory where `tabwright` CLI was invoked** (the session's cwd)
57
+ - `/tmp`
58
+ - The OS temp directory (`os.tmpdir()`, e.g. `/var/folders/.../T/` on macOS)
59
+
60
+ Writing to any other path (e.g. `~/Downloads`, `~/Desktop`) throws `EPERM: operation not permitted, access outside allowed directories`. To save files elsewhere, write to a temp path first, then move the file using a shell command outside the sandbox.
61
+
62
+ ## rules
63
+
64
+ - **Initialize state.page first**: see "working with pages" — at the start of a task, assign `state.page` (reuse `about:blank` or create one) and use `state.page` for all automation steps.
65
+ - **Multiple calls**: use multiple execute calls for complex logic - helps understand intermediate state and isolate which action failed
66
+ - **Never close**: never call `browser.close()` or `context.close()`. Only close pages you created or if user asks
67
+ - **No bringToFront**: never call unless user asks - it's disruptive and unnecessary, you can interact with background pages
68
+ - **Check state after actions**: always verify page state after clicking/submitting (see next section)
69
+ - **Clean up listeners**: call `state.page.removeAllListeners()` at end of message to prevent leaks
70
+ - **Always print page logs after every action**: call `getLatestLogs({ page: state.page, sinceLastCall: true })` after every goto, click, or submit to catch console errors and warnings. Do not manually collect `page.on('console')` events; manual listeners miss logs emitted before the listener is attached. The first `sinceLastCall` call returns all buffered logs including startup and hydration errors.
71
+ - **CDP sessions**: use `getCDPSession({ page: state.page })` not `state.page.context().newCDPSession()` - NEVER use `newCDPSession()` method, it doesn't work through tabwright relay
72
+ - **Wait for load**: use `state.page.waitForLoadState('domcontentloaded')` not `state.page.waitForEvent('load')` - waitForEvent times out if already loaded
73
+ - **Minimize timeouts**: prefer proper waits (`waitForSelector`, `waitForPageLoad`) over `state.page.waitForTimeout()`. Short timeouts (1-2s) are acceptable for non-deterministic events like animations, tab opens, or async UI updates where no specific selector is available
74
+ - **Snapshot before screenshot**: always use `snapshot()` first to understand page state (text-based, fast, cheap). Only use `screenshot` when you specifically need visual/spatial information. Never take a screenshot just to check if a page loaded or to read text content — snapshot gives you that instantly without burning image tokens
75
+ - **Always use absolute file paths for Playwright artifact APIs**: for `page.screenshot({ path })`, `locator.screenshot({ path })`, `elementHandle.screenshot({ path })`, `page.pdf({ path })`, `download.saveAs(path)`, and `video.saveAs(path)`, always pass an absolute path. Relative paths are resolved by Playwright client internals, not the sandboxed `fs`, so they may use the relay server cwd instead of your session cwd.
76
+ - **Snapshot replaces page.evaluate() for inspection**: do NOT write `page.evaluate()` calls to manually query class names, bounding boxes, child counts, or visibility flags. `snapshot()` already shows every interactive element with its text, role, and a ready-to-use locator. If you catch yourself writing `document.querySelector` or `getBoundingClientRect` inside evaluate — stop and use `snapshot()` instead. Reserve `page.evaluate()` for actions that modify page state (e.g., `localStorage.clear()`, scroll manipulation) or extract non-DOM data (e.g., `window.__CONFIG__`)
77
+
78
+ ## interaction feedback loop
79
+
80
+ Every browser interaction must follow **observe → act → observe**. Never chain multiple actions blindly.
81
+
82
+ 1. **Open page** — get or create your page, navigate to URL
83
+ 2. **Observe** — print `state.page.url()` + `snapshot()` + `getLatestLogs({ sinceLastCall: true })`. Always print URL — pages can redirect unexpectedly.
84
+ 3. **Check** — if page isn't ready (loading, wrong URL, content missing), wait and observe again
85
+ 4. **Act** — perform one action (click, type, submit)
86
+ 5. **Observe again** — print URL + snapshot + page logs to verify the action's effect
87
+ 6. **Repeat** from step 3 until task is complete
88
+
89
+ **Always print page logs after every action** using `getLatestLogs({ sinceLastCall: true })`. This returns only new console messages and errors since the last call, so you catch hydration errors, failed network requests, and runtime exceptions without duplicates. The first call returns all buffered logs from the page, including logs emitted before your script started.
90
+
91
+ ```js
92
+ // Each step should be a separate execute call:
93
+ // Step 1: navigate + observe
94
+ state.page = context.pages().find((p) => p.url() === 'about:blank') ?? (await context.newPage())
95
+ await state.page.goto('https://example.com', { waitUntil: 'domcontentloaded' })
96
+ console.log('URL:', state.page.url())
97
+ console.log('Page logs:', await getLatestLogs({ page: state.page, sinceLastCall: true }))
98
+ await snapshot({ page: state.page }).then(console.log)
99
+ ```
100
+
101
+ ```js
102
+ // Step 2: act + observe
103
+ await state.page.locator('button:has-text("Submit")').click()
104
+ console.log('URL:', state.page.url())
105
+ console.log('Page logs:', await getLatestLogs({ page: state.page, sinceLastCall: true }))
106
+ await snapshot({ page: state.page }).then(console.log)
107
+ ```
108
+
109
+ If nothing changed after an action, try `waitForPageLoad({ page: state.page, timeout: 3000 })` or you may have clicked the wrong element.
110
+
111
+ **Deeper observation** — when snapshots aren't enough to understand what happened, combine snapshot with filtered logs:
112
+
113
+ ```js
114
+ // Search for specific errors in all logs (not just since last call)
115
+ const errors = await getLatestLogs({ page: state.page, search: /error|fail/i, count: 20 })
116
+
117
+ // Combine snapshot + filtered logs for full picture
118
+ const snap = await snapshot({ page: state.page, search: /dialog|error|message/ })
119
+ const logs = await getLatestLogs({ page: state.page, search: /error/i, count: 10 })
120
+ console.log('UI:', snap)
121
+ console.log('Logs:', logs)
122
+ ```
123
+
124
+ Use `getLatestLogs({ sinceLastCall: true })` after every action, `getLatestLogs({ search })` for targeted debugging, `state.page.url()` for navigation, screenshots only for visual layout issues.
125
+
126
+ ## common mistakes to avoid
127
+
128
+ **1. Not verifying actions succeeded**
129
+ Always check page state after important actions (form submissions, uploads, typing). Your mental model can diverge from actual browser state:
130
+
131
+ ```js
132
+ await state.page.keyboard.type('my text')
133
+ await snapshot({ page: state.page, search: /my text/ })
134
+ // If verifying visual layout specifically, use screenshotWithAccessibilityLabels instead
135
+ ```
136
+
137
+ **2. Assuming paste/upload worked**
138
+ Clipboard paste (`Meta+v`) can silently fail. For file uploads, prefer file input:
139
+
140
+ ```js
141
+ // Reliable: use file input
142
+ const fileInput = state.page.locator('input[type="file"]').first()
143
+ await fileInput.setInputFiles('/path/to/image.png')
144
+
145
+ // Unreliable: clipboard paste may silently fail, need to focus textarea first for example
146
+ await state.page.keyboard.press('Meta+v') // always verify with screenshot!
147
+ ```
148
+
149
+ **3. Using stale locators from old snapshots**
150
+ Locators (especially ones with `>> nth=`) can change when the page updates. Always get a fresh snapshot before clicking, then immediately use locators from that output:
151
+
152
+ ```js
153
+ await snapshot({ page: state.page, showDiffSinceLastCall: true })
154
+ // Now use the NEW locators from this output
155
+ ```
156
+
157
+ **4. Wrong assumptions about current page/element**
158
+ Before destructive actions (delete, submit), verify you're targeting the right thing:
159
+
160
+ ```js
161
+ // Before deleting, verify it's the right item
162
+ await screenshotWithAccessibilityLabels({ page: state.page })
163
+ // READ the screenshot to confirm, THEN proceed with delete
164
+ ```
165
+
166
+ **5. Text concatenation without line breaks**
167
+ `keyboard.type()` doesn't insert newlines from `\n` in strings. Use `keyboard.press('Enter')` between lines:
168
+
169
+ ```js
170
+ await state.page.keyboard.type('Line 1')
171
+ await state.page.keyboard.press('Enter')
172
+ await state.page.keyboard.type('Line 2')
173
+ ```
174
+
175
+ **6. Quote escaping in bash**
176
+ Bash parses `$`, backticks, and `\` inside double-quoted strings. This silently corrupts JS code. Always use single quotes or heredoc:
177
+
178
+ ```bash
179
+ # single quotes — bash passes everything through literally
180
+ tabwright -s 1 -e 'await state.page.locator(`[id="_r_a_"]`).click()'
181
+
182
+ # heredoc for complex code with mixed quotes
183
+ tabwright -s 1 -e "$(cat <<'EOF'
184
+ await state.page.locator('[id="_r_a_"]').click()
185
+ const match = html.match(/\$[\d.]+/g)
186
+ EOF
187
+ )"
188
+ ```
189
+
190
+ **7. Using screenshots when snapshots suffice**
191
+ Screenshots + image analysis is expensive and slow. Only use screenshots for visual/CSS issues. Use snapshot for text checks:
192
+
193
+ ```js
194
+ await snapshot({ page: state.page, search: /expected text/i })
195
+ ```
196
+
197
+ **8. Assuming page content loaded**
198
+ Even after `goto()`, dynamic content may not be ready:
199
+
200
+ ```js
201
+ await state.page.goto('https://example.com')
202
+ // Content may still be loading via JavaScript!
203
+ await state.page.waitForSelector('article', { timeout: 10000 })
204
+ // Or use waitForPageLoad utility
205
+ await waitForPageLoad({ page: state.page, timeout: 5000 })
206
+ ```
207
+
208
+ **9. Not using tabwright for JS-rendered sites**
209
+ Do NOT waste context trying webfetch, curl, or Playwright CLI screenshots on SPAs (Instagram, Twitter, etc.). These return empty HTML shells. Use tabwright directly:
210
+
211
+ ```js
212
+ state.page = context.pages().find((p) => p.url() === 'about:blank') ?? (await context.newPage())
213
+ await state.page.goto('https://www.instagram.com/p/ABC123/', { waitUntil: 'domcontentloaded' })
214
+ await waitForPageLoad({ page: state.page, timeout: 8000 })
215
+ await snapshot({ page: state.page, search: /cookie|consent|accept/i }).then(console.log)
216
+ ```
217
+
218
+ **10. Login buttons that open popups**
219
+ Popup windows (`window.open` with features, OAuth buttons) are auto-relocated to tabs in the main window by the Tabwright extension. The new tab appears in `context.pages()` and is fully controllable. You will receive a `[WARNING] New page opened from current page (index N, initial url: ...)` message pointing to the new tab — the `initial url` may be `about:blank` for blank-then-scripted popups, so check `context.pages()[N].url()` for the final URL:
220
+
221
+ ```js
222
+ await state.page.locator('button:has-text("Login with Google")').click()
223
+ await state.page.waitForTimeout(1000)
224
+
225
+ // New tab is the last page in the context
226
+ const pages = context.pages()
227
+ const loginPage = pages[pages.length - 1]
228
+
229
+ // Complete login flow in loginPage, cookies are shared with original page
230
+ await loginPage.locator('[data-email]').first().click()
231
+ await loginPage.waitForURL('**/callback**')
232
+ // Original page should now be authenticated
233
+ ```
234
+
235
+ **11. Click times out or does nothing — snapshot to find the blocker**
236
+ When a click times out, a **modal or overlay** is likely intercepting pointer events. Do not retry with different selectors or `{ force: true }` — snapshot to find the blocker:
237
+
238
+ ```js
239
+ // click timed out → don't retry blindly, find what's blocking
240
+ await snapshot({ page: state.page, search: /dialog|modal/i })
241
+ // Found modal → interact with it properly (don't just close via X, it may reappear)
242
+ await state.page.getByRole('radio', { name: 'Nope, Vanilla' }).click()
243
+ ```
244
+
245
+ **12. Never use `dispatchEvent` or `{ force: true }` to bypass blockers**
246
+ `dispatchEvent(new MouseEvent(...))`, `{ force: true }`, and `element.click()` inside `page.evaluate()` bypass Playwright checks but **do not trigger React/Vue/Svelte handlers** — state won't update. Use snapshot to find the real interactive element:
247
+
248
+ ```js
249
+ await state.page.getByRole('radio', { name: 'Node.js' }).click()
250
+ ```
251
+
252
+ **13. Over-investigating instead of just interacting**
253
+ When something doesn't respond to a click, do NOT start inspecting CDP event listeners, React fibers, canvas pixel data, or writing `page.evaluate()` to read class names and bounding boxes. This wastes massive context. Instead:
254
+
255
+ 1. Take a `snapshot()` — it shows every interactive element and what to click
256
+ 2. Try a different interaction pattern if `click()` didn't work:
257
+ - **Drawing/annotation tools, canvas paint** → `mouse.down`, move with steps, `mouse.up` (see drag section)
258
+ - **Keyboard-activated modes** → press the shortcut key (snapshot shows tooltip text like "Draw mode D")
259
+ - **Sliders, timeline scrubbers** → drag pattern
260
+ - **Collapsed/toggled toolbars** → click the toggle first, wait, then interact
261
+ 3. Take another `snapshot()` to see what changed
262
+ 4. Only investigate DOM internals if correct interaction patterns produce zero response after 2–3 attempts
263
+
264
+ ## accessibility snapshots
265
+
266
+ ```js
267
+ await snapshot({ page: state.page, search?, showDiffSinceLastCall? })
268
+ ```
269
+
270
+ - `search` - string/regex to filter results (returns first 10 matching lines)
271
+ - `showDiffSinceLastCall` - returns diff since last snapshot (default: `true`, but `false` when `search` is provided). Pass `false` to get full snapshot.
272
+
273
+ Snapshots return full content on first call, then diffs on subsequent calls. Diff is only returned when shorter than full content. If nothing changed, returns "No changes since last snapshot" message. Use `showDiffSinceLastCall: false` to always get full content. When `search` is provided, diffing is disabled by default so the search filters the full content — pass `showDiffSinceLastCall: true` explicitly to combine both. This diffing behavior also applies to `getCleanHTML` and `getPageMarkdown`.
274
+
275
+ Example output:
276
+
277
+ ```md
278
+ - banner:
279
+ - link "Home" [id="nav-home"]
280
+ - navigation:
281
+ - link "Docs" [data-testid="docs-link"]
282
+ - link "Blog" role=link[name="Blog"]
283
+ ```
284
+
285
+ Each interactive line ends with a Playwright locator you can pass to `state.page.locator()`.
286
+ If multiple elements share the same locator, a `>> nth=N` suffix is added (0-based)
287
+ to make it unique.
288
+
289
+ **Use snapshot locators directly — never invent selectors.** The snapshot output IS the selector. Do not guess CSS selectors or `getByText` when the snapshot already gives you the exact match:
290
+
291
+ ```js
292
+ // Snapshot shows: role=radio[name="Nope, Vanilla"] → use it directly
293
+ await state.page.getByRole('radio', { name: 'Nope, Vanilla' }).click()
294
+ // Snapshot shows: role=link[name="SIGN IN"] → or pass raw string to locator()
295
+ await state.page.locator('role=link[name="SIGN IN"]').click()
296
+ ```
297
+
298
+ **Beware CSS text-transform**: snapshots show visual text (`heading "NODE.JS"`) but DOM may be `"Node.js"`. Use case-insensitive regex: `getByRole('heading', { name: /node\.js/i })`.
299
+
300
+ If a screenshot shows ref labels like `e3`, resolve them using the last snapshot:
301
+
302
+ ```js
303
+ const snap = await snapshot({ page: state.page })
304
+ const locator = refToLocator({ ref: 'e3' })
305
+ await state.page.locator(locator!).click()
306
+ ```
307
+
308
+ Search for specific elements:
309
+
310
+ ```js
311
+ const snap = await snapshot({ page: state.page, search: /button|submit/i })
312
+ ```
313
+
314
+ **Scoping snapshots to a specific element** — pass a `locator` instead of `page` to snapshot only a subtree. This dramatically reduces output size when you only care about one section of the page (e.g., the main content area, ignoring the sidebar/header/footer):
315
+
316
+ ```js
317
+ // Full page snapshot: ~150 lines (sidebar, nav, header, footer, everything)
318
+ await snapshot({ page: state.page })
319
+
320
+ // Scoped to main: ~20 lines (just the content you care about)
321
+ await snapshot({ locator: state.page.locator('main') })
322
+
323
+ // Scope to a specific form, dialog, or section
324
+ await snapshot({ locator: state.page.locator('[role="dialog"]') })
325
+ await snapshot({ locator: state.page.locator('form#checkout') })
326
+ ```
327
+
328
+ Use this whenever the full page snapshot is dominated by navigation or layout elements you don't need. It saves significant tokens and makes the output much easier to parse.
329
+
330
+ **Filtering large snapshots in JS** — when `search` isn't enough, filter the string directly: `snap.split('\n').filter(l => l.includes('dialog') || l.includes('error')).join('\n')`
331
+
332
+ ## choosing between snapshot methods
333
+
334
+ Use `snapshot` for text-heavy pages (forms, articles) — fast, cheap, searchable. Use `screenshotWithAccessibilityLabels` for complex visual layouts (grids, galleries, dashboards) where spatial position matters. Both share the same ref system and can be combined.
335
+
336
+ ## selector best practices
337
+
338
+ **For unknown websites**: use `snapshot()` - it shows what's actually interactive with stable locators.
339
+
340
+ **For development** (when you have source code access), prefer stable selectors in this order:
341
+
342
+ 1. **Best**: `[data-testid="submit"]` - explicit test attributes, never change accidentally
343
+ 2. **Good**: `getByRole('button', { name: 'Save' })` - accessible, semantic
344
+ 3. **Good**: `getByText('Sign in')`, `getByLabel('Email')` - readable, user-facing
345
+ 4. **OK**: `input[name="email"]`, `button[type="submit"]` - semantic HTML
346
+ 5. **Avoid**: `.btn-primary`, `#submit` - classes/IDs change frequently
347
+ 6. **Last resort**: `div.container > form > button` - fragile, breaks easily
348
+
349
+ Combine locators for precision:
350
+
351
+ ```js
352
+ state.page.locator('tr').filter({ hasText: 'John' }).locator('button').click()
353
+ state.page.locator('button').nth(2).click()
354
+ ```
355
+
356
+ If a locator matches multiple elements, Playwright throws "strict mode violation". Use `.first()`, `.last()`, or `.nth(n)`:
357
+
358
+ ```js
359
+ await state.page.locator('button').first().click() // first match
360
+ await state.page.locator('.item').last().click() // last match
361
+ await state.page.locator('li').nth(3).click() // 4th item (0-indexed)
362
+ ```
363
+
364
+ ## working with pages
365
+
366
+ **Pages are shared, state is not.** `context.pages()` returns all browser tabs with tabwright enabled — shared across all sessions. Multiple agents see the same tabs. If another agent navigates or closes a page you're using, you'll be affected. To avoid interference, **get your own page**.
367
+
368
+ **Get or create your page (first call):**
369
+
370
+ On your very first execute call, reuse an existing empty tab or create a new one, and navigate it **in the same execute call**. Store it in `state` and use `state.page` for all subsequent operations instead of the default `page` variable:
371
+
372
+ ```js
373
+ // Reuse an empty about:blank tab if available, otherwise create a new one.
374
+ // IMPORTANT: always navigate immediately in the same call to avoid another
375
+ // agent grabbing the same about:blank tab between execute calls.
376
+ state.page = context.pages().find((p) => p.url() === 'about:blank') ?? (await context.newPage())
377
+ await state.page.goto('https://example.com')
378
+ // Use state.page for ALL subsequent operations
379
+ ```
380
+
381
+ **Handle page closures gracefully:**
382
+
383
+ The user may close your page by accident (e.g., closing a tab in Chrome). Always check before using it and recreate if needed:
384
+
385
+ ```js
386
+ if (!state.page || state.page.isClosed()) {
387
+ state.page = context.pages().find((p) => p.url() === 'about:blank') ?? (await context.newPage())
388
+ }
389
+ await state.page.goto('https://example.com')
390
+ ```
391
+
392
+ **Use an existing page only when the user asks:**
393
+
394
+ Only use a page from `context.pages()` if the user explicitly asks you to control a specific tab they already opened (e.g., they're logged into an app). Find it by URL pattern and store it in state:
395
+
396
+ ```js
397
+ const pages = context.pages().filter((x) => x.url().includes('myapp.com'))
398
+ if (pages.length === 0) throw new Error('No myapp.com page found. Ask user to enable tabwright on it.')
399
+ if (pages.length > 1) throw new Error(`Found ${pages.length} matching pages, expected 1`)
400
+ state.targetPage = pages[0]
401
+ ```
402
+
403
+ **List all available pages:**
404
+
405
+ ```js
406
+ context.pages().map((p) => p.url())
407
+ ```
408
+
409
+ **Popup windows become tabs automatically:**
410
+
411
+ The extension intercepts Chrome popup windows (`window.open(url, '', 'width=...')`, OAuth login flows) and relocates them into the main window as regular tabs. You don't need cmd+click or `{ modifiers: ['Meta'] }` to avoid popups. When a page opens another, you receive a `[WARNING] New page opened from current page (index N, initial url: ...)` and can access it via `context.pages()[N]`.
412
+
413
+ ## navigation
414
+
415
+ **Use `domcontentloaded`** for `page.goto()`:
416
+
417
+ ```js
418
+ await state.page.goto('https://example.com', { waitUntil: 'domcontentloaded' })
419
+ await waitForPageLoad({ page: state.page, timeout: 5000 })
420
+ ```
421
+
422
+ ## common patterns
423
+
424
+ **Authenticated fetches** - fetch from within page context to include session cookies automatically:
425
+
426
+ ```js
427
+ const data = await state.page.evaluate(async (url) => {
428
+ const resp = await fetch(url)
429
+ return await resp.text()
430
+ }, 'https://example.com/protected/resource')
431
+ ```
432
+
433
+ **Read page cookies via CDP** - use `Network.getCookies` on the page CDP session:
434
+
435
+ ```js
436
+ const cdp = await getCDPSession({ page: state.page })
437
+ const { cookies } = await cdp.send('Network.getCookies', { urls: [state.page.url()] })
438
+ console.log(cookies)
439
+ ```
440
+
441
+ MUST use this for page-scoped cookies in extension mode. `Storage.getCookies` is a root-session command and will fail in tabwright.
442
+
443
+ **NEVER use `Network.clearBrowserCookies` or `Network.clearBrowserCache`** — these CDP commands are **profile-wide destructive operations** that wipe ALL cookies/cache across every domain in the user's Chrome profile. They will log the user out of Gmail, GitHub, and every authenticated session.
444
+
445
+ **Clear cookies for a specific domain** — use `Network.getCookies` to fetch cookies scoped to URLs, then delete them individually with `Network.deleteCookies`:
446
+
447
+ ```js
448
+ const cdp = await getCDPSession({ page: state.page })
449
+ const { cookies } = await cdp.send('Network.getCookies', {
450
+ urls: ['https://example.com', 'https://www.example.com'],
451
+ })
452
+ for (const cookie of cookies) {
453
+ await cdp.send('Network.deleteCookies', { name: cookie.name, domain: cookie.domain })
454
+ }
455
+ ```
456
+
457
+ **Downloading large data** - console output truncates large strings. Trigger a browser download instead:
458
+
459
+ ```js
460
+ // Fetch protected data and trigger download to user's Downloads folder
461
+ await state.page.evaluate(async (url) => {
462
+ const resp = await fetch(url)
463
+ const data = await resp.text()
464
+ const blob = new Blob([data], { type: 'application/octet-stream' })
465
+ const a = document.createElement('a')
466
+ a.href = URL.createObjectURL(blob)
467
+ a.download = 'data.json'
468
+ a.click()
469
+ }, 'https://example.com/protected/large-file')
470
+ // File saves to ~/Downloads - read it from there
471
+ ```
472
+
473
+ **Avoid permission-gated browser APIs** - some APIs require user permission prompts or special browser flags. These often fail silently or hang. Examples to avoid:
474
+
475
+ - `navigator.clipboard.writeText()` - requires permission
476
+ - Multiple concurrent downloads - browser may block
477
+ - `window.showSaveFilePicker()` - requires user gesture
478
+ - Geolocation, camera, microphone APIs
479
+
480
+ Instead, use simpler alternatives (single download via `a.click()`, store data in `state`, etc).
481
+
482
+ **Downloads** - capture and save:
483
+
484
+ ```js
485
+ const [download] = await Promise.all([state.page.waitForEvent('download'), state.page.click('button.download')])
486
+ await download.saveAs(`/absolute/path/${download.suggestedFilename()}`)
487
+ ```
488
+
489
+ **iFrames** - two approaches depending on what you need:
490
+
491
+ ```js
492
+ // frameLocator: for chaining locator operations (click, fill, etc.)
493
+ const frame = state.page.frameLocator('#my-iframe')
494
+ await frame.locator('button').click()
495
+
496
+ // contentFrame: returns a Frame object, needed for snapshot({ frame })
497
+ const frame2 = await state.page.locator('iframe').contentFrame()
498
+ await snapshot({ frame: frame2 })
499
+ ```
500
+
501
+ **Dialogs** - handle alerts/confirms/prompts:
502
+
503
+ ```js
504
+ state.page.on('dialog', async (dialog) => {
505
+ console.log(dialog.message())
506
+ await dialog.accept()
507
+ })
508
+ await state.page.click('button.trigger-alert')
509
+ ```
510
+
511
+ **Handling page obstacles (cookie modals, login walls, age gates)** - most major websites show blocking overlays. Always check for these with `snapshot()` right after navigation and dismiss them before doing anything else:
512
+
513
+ ```js
514
+ // After navigating, check for common obstacles
515
+ await waitForPageLoad({ page: state.page, timeout: 5000 })
516
+ const snap = await snapshot({
517
+ page: state.page,
518
+ search: /cookie|consent|accept|reject|decline|allow|age|verify|login|sign.in/i,
519
+ })
520
+ console.log(snap)
521
+ // Look for dismiss/accept/decline buttons in the snapshot, then click them:
522
+ // await state.page.locator('button:has-text("Accept")').click();
523
+ // await state.page.locator('button:has-text("Decline optional")').click();
524
+ // Then re-snapshot to confirm the modal is gone before proceeding
525
+ ```
526
+
527
+ If the page requires login and the user is already logged into Chrome, their session cookies are available — just navigate and the page should load authenticated. If not, ask the user for help or use their existing logged-in tab via `context.pages()`.
528
+
529
+ **Extracting and downloading media (images, videos)** - use `page.evaluate()` to extract URLs from the rendered DOM, then download via Node.js in the sandbox. This is far more reliable than parsing raw HTML:
530
+
531
+ ```js
532
+ // Extract all image URLs from rendered DOM
533
+ const images = await state.page.evaluate(() =>
534
+ Array.from(document.querySelectorAll('img[src]')).map((img) => ({
535
+ src: img.src,
536
+ alt: img.alt,
537
+ width: img.naturalWidth,
538
+ })),
539
+ )
540
+ console.log(JSON.stringify(images, null, 2))
541
+
542
+ // Download a specific image to disk
543
+ const fs = require('node:fs')
544
+ const resp = await fetch(images[0].src)
545
+ const buf = Buffer.from(await resp.arrayBuffer())
546
+ fs.writeFileSync('./downloaded-image.jpg', buf)
547
+ console.log('Saved', buf.length, 'bytes')
548
+ ```
549
+
550
+ For carousels or lazy-loaded galleries, you may need to click navigation arrows or scroll first, then re-extract. Use network interception (see "network interception" section) to capture high-resolution CDN URLs that may differ from the `img.src` thumbnails.
551
+
552
+ ## utility functions
553
+
554
+ **getLatestLogs** - retrieve captured browser console logs and page errors (up to 5000 per page):
555
+
556
+ Always use this helper when inspecting browser logs. Do not attach new `page.on('console')` listeners for debugging because they only see future events and can miss logs emitted during page startup or hydration.
557
+
558
+ Use `sinceLastCall: true` after every action to get only new logs since the previous call. The first call returns all buffered logs including pre-existing ones. Logs persist across navigations so you never miss errors from page transitions.
559
+
560
+ ```js
561
+ await getLatestLogs({ page?, count?, search?, sinceLastCall? })
562
+ // After every action: get only new logs
563
+ const newLogs = await getLatestLogs({ page: state.page, sinceLastCall: true })
564
+ // Search all logs (ignores cursor):
565
+ const errors = await getLatestLogs({ search: /error/i, count: 50 })
566
+ const pageLogs = await getLatestLogs({ page: state.page, count: 100 })
567
+ const hydrationErrors = await getLatestLogs({ page: state.page, search: /hydration|pageerror|React/i })
568
+ ```
569
+
570
+ **getCleanHTML** - get cleaned HTML from a locator or page, with search and diffing:
571
+
572
+ ```js
573
+ await getCleanHTML({ locator, search?, showDiffSinceLastCall?, includeStyles? })
574
+ // Examples:
575
+ const html = await getCleanHTML({ locator: state.page.locator('body') })
576
+ const html = await getCleanHTML({ locator: state.page, search: /button/i })
577
+ const fullHtml = await getCleanHTML({ locator: state.page, showDiffSinceLastCall: false }) // disable diff
578
+ ```
579
+
580
+ **Parameters:**
581
+
582
+ - `locator` - Playwright Locator or Page to get HTML from
583
+ - `search` - string/regex to filter results (returns first 10 matching lines with 5 lines context)
584
+ - `showDiffSinceLastCall` - returns diff since last call (default: `true`, but `false` when `search` is provided). Pass `false` to get full HTML.
585
+ - `includeStyles` - keep style and class attributes (default: false)
586
+
587
+ Cleans HTML automatically: removes script/style/svg/head tags, unwraps empty wrappers, removes empty elements, truncates long values. Keeps semantic attributes (`href`, `name`, `type`, `aria-*`, `data-*`).
588
+
589
+ **getPageMarkdown** - extract main page content as plain text using Mozilla Readability (same algorithm as Firefox Reader View). Strips navigation, ads, sidebars, and other clutter. Returns formatted text with title, author, and content:
590
+
591
+ ```js
592
+ await getPageMarkdown({ page: state.page, search?, showDiffSinceLastCall? })
593
+ // Examples:
594
+ const content = await getPageMarkdown({ page: state.page, showDiffSinceLastCall: false }) // full article
595
+ const matches = await getPageMarkdown({ page: state.page, search: /API/i }) // search within content
596
+ ```
597
+
598
+ **Output format:**
599
+
600
+ ```
601
+ # Article Title
602
+
603
+ Author: John Doe | Site: example.com | Published: 2024-01-15
604
+
605
+ > Article excerpt or description
606
+
607
+ The main article content as plain text, with paragraphs preserved...
608
+ ```
609
+
610
+ **Parameters:**
611
+
612
+ - `page` - Playwright Page to extract content from
613
+ - `search` - string/regex to filter content (returns first 10 matching lines with 5 lines context)
614
+ - `showDiffSinceLastCall` - returns diff since last call (default: `true`, but `false` when `search` is provided). Pass `false` to get full content.
615
+
616
+ **waitForPageLoad** - smart load detection that ignores analytics/ads:
617
+
618
+ ```js
619
+ await waitForPageLoad({ page: state.page, timeout?, pollInterval?, minWait? })
620
+ // Returns: { success, readyState, pendingRequests, waitTimeMs, timedOut }
621
+ ```
622
+
623
+ **getCDPSession** - send raw CDP commands:
624
+
625
+ ```js
626
+ const cdp = await getCDPSession({ page: state.page })
627
+ const metrics = await cdp.send('Page.getLayoutMetrics')
628
+ ```
629
+
630
+ **getLocatorStringForElement** - get stable Playwright selector from an element:
631
+
632
+ ```js
633
+ const selector = await getLocatorStringForElement(state.page.locator('[id="submit-btn"]'))
634
+ // => "getByRole('button', { name: 'Save' })"
635
+ ```
636
+
637
+ **getReactSource** - get React component source location (dev mode only):
638
+
639
+ ```js
640
+ const source = await getReactSource({ locator: state.page.locator('[data-testid="submit-btn"]') })
641
+ // => { fileName, lineNumber, columnNumber, componentName }
642
+ ```
643
+
644
+ **getReactComponentInfo** - get best-effort React component info for an element. Returns `null` for non-React elements and never throws just because an element was not rendered by React. Source locations are usually only available in React dev builds. Props are sanitized and truncated so functions, DOM nodes, circular refs, and huge objects do not flood the output.
645
+
646
+ ```js
647
+ const info = await getReactComponentInfo({ locator: state.page.locator('[data-testid="submit-btn"]') })
648
+ // => { componentName, source, hierarchy, props } | null
649
+ ```
650
+
651
+ **inspectPinnedElement** - inspect a Tabwright pinned element and print the element `outerHTML` plus React component info when available. Used by the in-page toolbar and right-click copy flow.
652
+
653
+ ```js
654
+ await inspectPinnedElement('https://example.com', 'globalThis.tabwrightPinnedElem1')
655
+ ```
656
+
657
+ **getStylesForLocator** - inspect CSS styles applied to an element, like browser DevTools "Styles" panel. Useful for debugging styling issues, finding where a CSS property is defined (file:line), and checking inherited styles. Returns selector, source location, and declarations for each matching rule. ALWAYS fetch `https://playwriter.dev/resources/styles-api.md` first with curl or webfetch tool.
658
+
659
+ ```js
660
+ const styles = await getStylesForLocator({
661
+ locator: state.page.locator('.btn'),
662
+ cdp: await getCDPSession({ page: state.page }),
663
+ })
664
+ console.log(formatStylesAsText(styles))
665
+ ```
666
+
667
+ **createDebugger** - set breakpoints, step through code, inspect variables at runtime. Useful for debugging issues that only reproduce in browser, understanding code flow, and inspecting state at specific points. Can pause on exceptions, evaluate expressions in scope, and blackbox framework code. ALWAYS fetch `https://playwriter.dev/resources/debugger-api.md` first.
668
+
669
+ ```js
670
+ const cdp = await getCDPSession({ page: state.page })
671
+ const dbg = createDebugger({ cdp })
672
+ await dbg.enable()
673
+ const scripts = await dbg.listScripts({ search: 'app' })
674
+ await dbg.setBreakpoint({ file: scripts[0].url, line: 42 })
675
+ // when paused: dbg.inspectLocalVariables(), dbg.stepOver(), dbg.resume()
676
+ ```
677
+
678
+ **createEditor** - view and live-edit page scripts and CSS at runtime. Edits are in-memory (persist until reload). Useful for testing quick fixes, searching page scripts with grep, and toggling debug flags. ALWAYS read `https://playwriter.dev/resources/editor-api.md` first.
679
+
680
+ ```js
681
+ const cdp = await getCDPSession({ page: state.page })
682
+ const editor = createEditor({ cdp })
683
+ await editor.enable()
684
+ const matches = await editor.grep({ regex: /console\.log/ })
685
+ await editor.edit({ url: matches[0].url, oldString: 'DEBUG = false', newString: 'DEBUG = true' })
686
+ ```
687
+
688
+ **screenshotWithAccessibilityLabels** - take a screenshot with Vimium-style visual labels overlaid on interactive elements. Shows labels, captures screenshot, then removes labels. The image and accessibility snapshot are automatically included in the response. Can be called multiple times to capture multiple screenshots. Use a timeout of **20 seconds** for complex pages.
689
+
690
+ This is only for **finding interactive elements** on the page. To share a screenshot with the user or save an image, use `page.screenshot()` + `resizeImageForAgent()` instead (see "taking screenshots" section below).
691
+
692
+ Prefer this for pages with grids, image galleries, maps, or complex visual layouts where spatial position matters. For simple text-heavy pages, `snapshot` with search is faster and uses fewer tokens.
693
+
694
+ ```js
695
+ await screenshotWithAccessibilityLabels({ page: state.page })
696
+ // Image and accessibility snapshot are automatically included in response
697
+ // Use refs from snapshot to interact with elements
698
+ await state.page.locator('[id="submit-btn"]').click()
699
+
700
+ // Can take multiple screenshots in one execution
701
+ await screenshotWithAccessibilityLabels({ page: state.page })
702
+ await state.page.click('button')
703
+ await screenshotWithAccessibilityLabels({ page: state.page })
704
+ // Both images are included in the response
705
+ ```
706
+
707
+ Labels are color-coded: yellow=links, orange=buttons, coral=inputs, pink=checkboxes, peach=sliders, salmon=menus, amber=tabs.
708
+
709
+ **resizeImageForAgent** - shrink an image so it consumes fewer tokens when read back into context. The resized image is automatically included in the response (visible to the LLM). `await resizeImageForAgent({ input: '/absolute/path/to/screenshot.png' })`. Also accepts `width`, `height`, `maxDimension`, `quality`, `format` (default: `'png'`), `output`. Alias: `resizeImage`.
710
+
711
+ **replay.start / replay.stop** - record the page as an rrweb DOM replay. This captures DOM snapshots, mutations, inputs, mouse movement, scrolls, and user-added Tabwright annotations into `~/.tabwright/rrweb-recordings/<id>.json`, then plays back in the Tabwright extension options page. DOM replays are for review and workflow understanding only: clicking inside the replay does **not** execute the original page's React/Vue/business logic.
712
+
713
+ Use replay recordings when you need a compact, inspectable artifact for AI understanding, workflow compilation, and user review. The in-page toolbar records rrweb replay only; video capture is intentionally not part of the product.
714
+
715
+ While recording, the toolbar's element selection button becomes an annotation tool. If the user selects an element and writes a note, the note is saved as a `tabwright.annotation` rrweb custom event and appears in `replay index` output as `annotations`. Treat these annotations as stronger intent signals than inferred labels/selectors.
716
+
717
+ ```js
718
+ await replay.start({
719
+ page: state.page,
720
+ checkoutEveryNms: 0,
721
+ maskAllInputs: false,
722
+ recordCanvas: false,
723
+ inlineImages: false,
724
+ })
725
+
726
+ await state.page.getByLabel('Title').fill('Summer banner')
727
+ await state.page.getByRole('button', { name: 'Preview' }).click()
728
+
729
+ state.replayResult = await replay.stop({ page: state.page })
730
+ console.log(state.replayResult)
731
+
732
+ // Other: replay.isRecording({ page }), replay.cancel({ page }), replay.list({ limit: 10 }),
733
+ // replay.events({ id: state.replayResult.id })
734
+ ```
735
+
736
+ **workflow.saveFromRecording / workflow.saveCapability** - after the user gives a demonstration replay id and a concrete goal, save the derived reusable flow as a project capability. Prefer `workflow.saveFromRecording()` when the flow can be represented as structured steps; use `workflow.saveCapability()` when you need to write a custom script. Saved workflows start as `draft`, have `sideEffect: "write"` and `requiresConfirmation: true` by default, and can later be inspected or run with `tabwright capability ...`. The generated script runs the live frontend flow, observes the expected final request when `finalRequest` is provided, and returns `needs_ai` with a snapshot when the page no longer matches the replay. Omit `finalRequest` for flows that do not have a real submit/request boundary.
737
+
738
+ **replay list** - use `tabwright replay list --limit 10 --json` to discover saved demonstrations without connecting to the relay. Results are newest-first and include the exact inspect and make commands for each replay.
739
+
740
+ **replay make / replay compile** - when the user gives an rrweb replay id and asks to run similar work, first compile the replay into a project capability instead of manually replaying every step. Prefer `tabwright replay make <replayId> <capabilityId> --force --goal "..." --json` because it builds the AI index and compiles in one step. A successful result has `status: "compiled"` and writes the draft capability. If the deterministic compiler cannot recognize the workflow, the result has `status: "needs_ai"`, writes no placeholder capability, and returns exact `next.inspectCommand` and `next.createCommand` commands for an AI authoring handoff. Generated workflows are draft browser writes: inspect the contract and script, stop for explicit user confirmation, then run with `tabwright capability run <capabilityId> --browser user --input-json ... --force --confirm <capabilityId> --json`. Use `replay compile` only when the index has already been inspected or generated separately. The generated script should execute the live frontend path, continue from an already-editing page when possible, and return `needs_ai` with page context when validation, DOM drift, or a missing selector blocks the flow.
741
+
742
+ **replay index** - before compiling a replay, use `tabwright replay index <replayId> --json` to inspect the compact AI-readable view of the rrweb events. It preserves actions, fields, user annotations, warnings, and selector hints, but replaces bulky page text and interactive-element arrays with counts. Add `--full` only when the AI needs the complete evidence. The raw rrweb recording remains the source evidence; use `--write` only when you want to persist the generated index under `~/.tabwright/replay-ai-indexes`.
743
+
744
+ **replay eval** - run the replay productization self-test platform. It creates local example pages, writes synthetic rrweb recordings, builds the AI index, compiles draft capabilities, runs the generated scripts in a real browser, and verifies the page/request result. Use it before changing recording/index/compiler/capability code:
745
+
746
+ ```bash
747
+ tabwright replay eval
748
+ tabwright replay eval --json
749
+ tabwright replay eval --case zh-list-append --headed
750
+ tabwright replay eval --report tmp/replay-eval-report.html --keep-artifacts
751
+ ```
752
+
753
+ The default suite covers Chinese/English list append flows, already-editing pages, draft restart/continue dialogs, duplicate-value short-circuiting, deleted annotations, page drift returning `needs_ai`, and unsupported replays failing explicitly instead of generating fake automation.
754
+
755
+ ```js
756
+ const latestReplay = (await replay.list({ limit: 1 }))[0]
757
+
758
+ const saved = workflow.saveFromRecording({
759
+ id: 'create-material-from-demo',
760
+ title: 'Create material from demo',
761
+ description: 'Fill the material form from structured input and stop with needs_ai if the page drifts.',
762
+ recordingId: latestReplay.id,
763
+ match: ['https://admin.example.com/*'],
764
+ inputSchema: {
765
+ type: 'object',
766
+ properties: {
767
+ items: {
768
+ type: 'array',
769
+ items: {
770
+ type: 'object',
771
+ properties: {
772
+ title: { type: 'string' },
773
+ image: { type: 'string' },
774
+ },
775
+ required: ['title', 'image'],
776
+ },
777
+ },
778
+ },
779
+ required: ['items'],
780
+ },
781
+ steps: [
782
+ { action: 'goto', url: { value: 'https://admin.example.com/materials/new' } },
783
+ { action: 'fill', locator: '[name="title"]', value: { inputPath: 'title' } },
784
+ { action: 'setInputFiles', locator: '[name="image"]', path: { inputPath: 'image' } },
785
+ ],
786
+ finalRequest: {
787
+ url: '**/api/materials/**',
788
+ method: 'POST',
789
+ title: 'Create material',
790
+ trigger: { action: 'click', locator: 'button[type="submit"]' },
791
+ },
792
+ })
793
+
794
+ console.log(saved.capability)
795
+ ```
796
+
797
+ **ghostCursor.show / ghostCursor.hide** - the ghost cursor overlay is always on: the extension injects it on every Tabwright-attached tab and it stays visible at the last spot Playwright clicked or moved. These methods only matter if you want to change the cursor style or temporarily hide it:
798
+
799
+ ```js
800
+ await ghostCursor.show({ page: state.page, style: 'screenstudio' }) // 'minimal' (default), 'dot', 'screenstudio'
801
+ await ghostCursor.hide({ page: state.page }) // hide until next show() or hard navigation
802
+ ```
803
+
804
+ ## pinned elements
805
+
806
+ Users can right-click → "Copy Tabwright Element Reference" to store elements in `globalThis.tabwrightPinnedElem1` (increments for each pin). The reference is copied to clipboard:
807
+
808
+ ```js
809
+ const el = await state.page.evaluateHandle(() => globalThis.tabwrightPinnedElem1)
810
+ await el.click()
811
+ ```
812
+
813
+ ## taking screenshots
814
+
815
+ Always use `scale: 'css'` to avoid 2-4x larger images on high-DPI displays:
816
+
817
+ ```js
818
+ await state.page.screenshot({ path: '/absolute/path/to/shot.png', scale: 'css' })
819
+ ```
820
+
821
+ If you want to read back the image file into context, resize it first so it consumes fewer tokens:
822
+
823
+ ```js
824
+ await resizeImageForAgent({ input: './shot.png' })
825
+ ```
826
+
827
+ ## page.evaluate
828
+
829
+ Code inside `page.evaluate()` runs in the browser - use plain JavaScript only, no TypeScript syntax. Return values and log outside (console.log inside evaluate runs in browser, not visible):
830
+
831
+ ```js
832
+ const title = await state.page.evaluate(() => document.title)
833
+ console.log('Title:', title)
834
+
835
+ const info = await state.page.evaluate(() => ({
836
+ url: location.href,
837
+ buttons: document.querySelectorAll('button').length,
838
+ }))
839
+ console.log(info)
840
+ ```
841
+
842
+ ## loading files
843
+
844
+ Fill inputs with file content:
845
+
846
+ ```js
847
+ const fs = require('node:fs')
848
+ const content = fs.readFileSync('./data.txt', 'utf-8')
849
+ await state.page.locator('textarea').fill(content)
850
+ ```
851
+
852
+ ## network interception
853
+
854
+ For scraping or reverse-engineering APIs, intercept network requests instead of scrolling DOM. Store in `state` to analyze across calls:
855
+
856
+ ```js
857
+ state.requests = []
858
+ state.responses = []
859
+ state.page.on('request', (req) => {
860
+ if (req.url().includes('/api/')) state.requests.push({ url: req.url(), method: req.method(), headers: req.headers() })
861
+ })
862
+ state.page.on('response', async (res) => {
863
+ if (res.url().includes('/api/')) {
864
+ try {
865
+ state.responses.push({ url: res.url(), status: res.status(), body: await res.json() })
866
+ } catch {}
867
+ }
868
+ })
869
+ ```
870
+
871
+ Then trigger actions (scroll, click, navigate) and analyze captured data:
872
+
873
+ ```js
874
+ console.log('Captured', state.responses.length, 'API calls')
875
+ state.responses.forEach((r) => console.log(r.status, r.url.slice(0, 80)))
876
+ ```
877
+
878
+ Inspect a specific response to understand schema:
879
+
880
+ ```js
881
+ const resp = state.responses.find((r) => r.url.includes('users'))
882
+ console.log(JSON.stringify(resp.body, null, 2).slice(0, 2000))
883
+ ```
884
+
885
+ Replay API directly (useful for pagination):
886
+
887
+ ```js
888
+ const { url, headers } = state.requests.find((r) => r.url.includes('feed'))
889
+ const data = await state.page.evaluate(
890
+ async ({ url, headers }) => {
891
+ const res = await fetch(url, { headers })
892
+ return res.json()
893
+ },
894
+ { url, headers },
895
+ )
896
+ console.log(data)
897
+ ```
898
+
899
+ Clean up listeners when done: `state.page.removeAllListeners('request'); state.page.removeAllListeners('response');`
900
+
901
+ ## computer use (low-level mouse/keyboard)
902
+
903
+ ### clicking
904
+
905
+ ```js
906
+ // Preferred: by locator (stable, auto-waits, no coordinates needed)
907
+ await state.page.locator('button[name="Submit"]').click()
908
+ await state.page.locator('text=Login').click({ button: 'right' })
909
+ await state.page.locator('text=Login').dblclick()
910
+ await state.page
911
+ .locator('a')
912
+ .first()
913
+ .click({ modifiers: ['Meta'] }) // cmd+click opens link in new background tab
914
+
915
+ // By coordinates (when locators aren't available, e.g. canvas, maps, custom widgets)
916
+ await state.page.mouse.click(450, 320) // left click
917
+ await state.page.mouse.click(450, 320, { button: 'right' }) // right click
918
+ await state.page.mouse.dblclick(450, 320) // double click
919
+ await state.page.mouse.click(450, 320, { clickCount: 3 }) // triple click
920
+ await state.page.mouse.click(450, 320, { modifiers: ['Shift'] }) // shift+click
921
+ ```
922
+
923
+ ### hover
924
+
925
+ ```js
926
+ await state.page.locator('.tooltip-trigger').hover() // by locator (preferred)
927
+ await state.page.mouse.move(450, 320) // by coordinates
928
+ ```
929
+
930
+ ### scroll
931
+
932
+ ```js
933
+ // By locator (preferred)
934
+ await state.page.locator('#footer').scrollIntoViewIfNeeded()
935
+
936
+ // By pixel (for canvas, maps, infinite scroll)
937
+ await state.page.mouse.wheel(0, 300) // scroll down 300px
938
+ await state.page.mouse.wheel(0, -300) // scroll up
939
+ await state.page.mouse.wheel(300, 0) // scroll right
940
+ await state.page.mouse.wheel(-300, 0) // scroll left
941
+
942
+ // Scroll at a specific position
943
+ await state.page.mouse.move(450, 320)
944
+ await state.page.mouse.wheel(0, 500)
945
+
946
+ // Scroll inside a container
947
+ await state.page.locator('.scrollable-list').evaluate((el) => {
948
+ el.scrollTop += 500
949
+ })
950
+ ```
951
+
952
+ ### drag
953
+
954
+ ```js
955
+ // By locator (preferred)
956
+ await state.page.locator('#item').dragTo(state.page.locator('#target'))
957
+
958
+ // By coordinates (for canvas, sliders, custom drag targets)
959
+ await state.page.mouse.move(100, 200)
960
+ await state.page.mouse.down()
961
+ await state.page.mouse.move(400, 500, { steps: 10 }) // steps for smooth drag
962
+ await state.page.mouse.up()
963
+ ```
964
+
965
+ **Freehand drawing, annotation widgets, and canvas tools** use this same `mouse.down → move → up` pattern. If a widget expects a drawn stroke (paint tools, annotation overlays, range sliders, timeline scrubbers), always use held-mouse motion — not `mouse.click()`:
966
+
967
+ ```js
968
+ // Draw a stroke across a canvas or annotation layer
969
+ await state.page.mouse.move(startX, startY)
970
+ await state.page.mouse.down()
971
+ await state.page.mouse.move(endX, endY, { steps: 15 }) // steps = smoother stroke
972
+ await state.page.mouse.up()
973
+ await state.page.waitForTimeout(500) // let the widget process the stroke
974
+ ```
975
+
976
+ ### key hold / release / repeat
977
+
978
+ ```js
979
+ // Hold modifier while pressing another key
980
+ await state.page.keyboard.down('Shift')
981
+ await state.page.keyboard.press('ArrowDown')
982
+ await state.page.keyboard.up('Shift')
983
+
984
+ // Repeat a key
985
+ for (let i = 0; i < 5; i++) await state.page.keyboard.press('ArrowDown')
986
+ ```
987
+
988
+ ### resize viewport
989
+
990
+ ```js
991
+ await state.page.setViewportSize({ width: 1280, height: 720 })
992
+ ```
993
+
994
+ ### region screenshot (zoom equivalent)
995
+
996
+ ```js
997
+ await state.page.screenshot({ path: '/absolute/path/to/region.png', scale: 'css', clip: { x: 100, y: 200, width: 400, height: 300 } })
998
+ ```
999
+
1000
+ Prefer locator-based actions over coordinates — locators are stable across scroll/resize, auto-wait for elements, and don't require screenshot round-trips that burn ~800 image tokens per cycle.
1001
+
1002
+ ## Ghost Browser integration
1003
+
1004
+ When running in [Ghost Browser](https://ghostbrowser.com/), the `chrome` object exposes APIs for multi-identity automation (identities, proxies, sessions). See `extension/src/ghost-browser-api.d.ts` for full API reference. Only works in Ghost Browser — calls fail in regular Chrome.