@mercuryo-ai/agentbrowse 0.2.50

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 (301) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +335 -0
  3. package/dist/assistive-runtime.d.ts +110 -0
  4. package/dist/assistive-runtime.d.ts.map +1 -0
  5. package/dist/assistive-runtime.js +79 -0
  6. package/dist/assistive-runtime.test-support.d.ts +7 -0
  7. package/dist/assistive-runtime.test-support.d.ts.map +1 -0
  8. package/dist/assistive-runtime.test-support.js +106 -0
  9. package/dist/assistive-stagehand.d.ts +12 -0
  10. package/dist/assistive-stagehand.d.ts.map +1 -0
  11. package/dist/assistive-stagehand.js +10 -0
  12. package/dist/browser-session-state.d.ts +95 -0
  13. package/dist/browser-session-state.d.ts.map +1 -0
  14. package/dist/browser-session-state.js +279 -0
  15. package/dist/client-bindings.d.ts +10 -0
  16. package/dist/client-bindings.d.ts.map +1 -0
  17. package/dist/client-bindings.js +18 -0
  18. package/dist/client.d.ts +49 -0
  19. package/dist/client.d.ts.map +1 -0
  20. package/dist/client.js +63 -0
  21. package/dist/command-api-tracing.d.ts +20 -0
  22. package/dist/command-api-tracing.d.ts.map +1 -0
  23. package/dist/command-api-tracing.js +149 -0
  24. package/dist/command-name.d.ts +3 -0
  25. package/dist/command-name.d.ts.map +1 -0
  26. package/dist/command-name.js +11 -0
  27. package/dist/commands/act.d.ts +43 -0
  28. package/dist/commands/act.d.ts.map +1 -0
  29. package/dist/commands/act.js +1107 -0
  30. package/dist/commands/action-acceptance.d.ts +93 -0
  31. package/dist/commands/action-acceptance.d.ts.map +1 -0
  32. package/dist/commands/action-acceptance.js +1938 -0
  33. package/dist/commands/action-artifacts.d.ts +33 -0
  34. package/dist/commands/action-artifacts.d.ts.map +1 -0
  35. package/dist/commands/action-artifacts.js +104 -0
  36. package/dist/commands/action-execution-guards.d.ts +5 -0
  37. package/dist/commands/action-execution-guards.d.ts.map +1 -0
  38. package/dist/commands/action-execution-guards.js +3 -0
  39. package/dist/commands/action-executor-helpers.d.ts +21 -0
  40. package/dist/commands/action-executor-helpers.d.ts.map +1 -0
  41. package/dist/commands/action-executor-helpers.js +265 -0
  42. package/dist/commands/action-executor.d.ts +14 -0
  43. package/dist/commands/action-executor.d.ts.map +1 -0
  44. package/dist/commands/action-executor.js +46 -0
  45. package/dist/commands/action-fallbacks.d.ts +6 -0
  46. package/dist/commands/action-fallbacks.d.ts.map +1 -0
  47. package/dist/commands/action-fallbacks.js +43 -0
  48. package/dist/commands/action-result-resolution.d.ts +17 -0
  49. package/dist/commands/action-result-resolution.d.ts.map +1 -0
  50. package/dist/commands/action-result-resolution.js +132 -0
  51. package/dist/commands/action-value-projection.d.ts +32 -0
  52. package/dist/commands/action-value-projection.d.ts.map +1 -0
  53. package/dist/commands/action-value-projection.js +151 -0
  54. package/dist/commands/attach.d.ts +41 -0
  55. package/dist/commands/attach.d.ts.map +1 -0
  56. package/dist/commands/attach.js +103 -0
  57. package/dist/commands/browse-actions.d.ts +4 -0
  58. package/dist/commands/browse-actions.d.ts.map +1 -0
  59. package/dist/commands/browse-actions.js +4 -0
  60. package/dist/commands/browser-status.d.ts +57 -0
  61. package/dist/commands/browser-status.d.ts.map +1 -0
  62. package/dist/commands/browser-status.js +243 -0
  63. package/dist/commands/click-action-executor.d.ts +12 -0
  64. package/dist/commands/click-action-executor.d.ts.map +1 -0
  65. package/dist/commands/click-action-executor.js +111 -0
  66. package/dist/commands/click-activation-policy.d.ts +5 -0
  67. package/dist/commands/click-activation-policy.d.ts.map +1 -0
  68. package/dist/commands/click-activation-policy.js +13 -0
  69. package/dist/commands/close.d.ts +26 -0
  70. package/dist/commands/close.d.ts.map +1 -0
  71. package/dist/commands/close.js +124 -0
  72. package/dist/commands/datepicker-action-executor.d.ts +12 -0
  73. package/dist/commands/datepicker-action-executor.d.ts.map +1 -0
  74. package/dist/commands/datepicker-action-executor.js +218 -0
  75. package/dist/commands/descriptor-validation.d.ts +27 -0
  76. package/dist/commands/descriptor-validation.d.ts.map +1 -0
  77. package/dist/commands/descriptor-validation.js +192 -0
  78. package/dist/commands/extract-scope-resolution.d.ts +20 -0
  79. package/dist/commands/extract-scope-resolution.d.ts.map +1 -0
  80. package/dist/commands/extract-scope-resolution.js +109 -0
  81. package/dist/commands/extract-scoped-dialog-text.d.ts +3 -0
  82. package/dist/commands/extract-scoped-dialog-text.d.ts.map +1 -0
  83. package/dist/commands/extract-scoped-dialog-text.js +210 -0
  84. package/dist/commands/extract-snapshot-sanitizer.d.ts +5 -0
  85. package/dist/commands/extract-snapshot-sanitizer.d.ts.map +1 -0
  86. package/dist/commands/extract-snapshot-sanitizer.js +98 -0
  87. package/dist/commands/extract-stagehand-executor.d.ts +17 -0
  88. package/dist/commands/extract-stagehand-executor.d.ts.map +1 -0
  89. package/dist/commands/extract-stagehand-executor.js +112 -0
  90. package/dist/commands/extract.d.ts +57 -0
  91. package/dist/commands/extract.d.ts.map +1 -0
  92. package/dist/commands/extract.js +668 -0
  93. package/dist/commands/interaction-kernel.d.ts +46 -0
  94. package/dist/commands/interaction-kernel.d.ts.map +1 -0
  95. package/dist/commands/interaction-kernel.js +215 -0
  96. package/dist/commands/launch.d.ts +41 -0
  97. package/dist/commands/launch.d.ts.map +1 -0
  98. package/dist/commands/launch.js +182 -0
  99. package/dist/commands/navigate.d.ts +31 -0
  100. package/dist/commands/navigate.d.ts.map +1 -0
  101. package/dist/commands/navigate.js +202 -0
  102. package/dist/commands/observe-accessibility.d.ts +22 -0
  103. package/dist/commands/observe-accessibility.d.ts.map +1 -0
  104. package/dist/commands/observe-accessibility.js +566 -0
  105. package/dist/commands/observe-display-label.d.ts +4 -0
  106. package/dist/commands/observe-display-label.d.ts.map +1 -0
  107. package/dist/commands/observe-display-label.js +26 -0
  108. package/dist/commands/observe-dom-label-contract.d.ts +2 -0
  109. package/dist/commands/observe-dom-label-contract.d.ts.map +1 -0
  110. package/dist/commands/observe-dom-label-contract.js +564 -0
  111. package/dist/commands/observe-fallback-semantics.d.ts +6 -0
  112. package/dist/commands/observe-fallback-semantics.d.ts.map +1 -0
  113. package/dist/commands/observe-fallback-semantics.js +86 -0
  114. package/dist/commands/observe-inventory.d.ts +149 -0
  115. package/dist/commands/observe-inventory.d.ts.map +1 -0
  116. package/dist/commands/observe-inventory.js +3545 -0
  117. package/dist/commands/observe-label-policy.d.ts +8 -0
  118. package/dist/commands/observe-label-policy.d.ts.map +1 -0
  119. package/dist/commands/observe-label-policy.js +21 -0
  120. package/dist/commands/observe-page-state.d.ts +11 -0
  121. package/dist/commands/observe-page-state.d.ts.map +1 -0
  122. package/dist/commands/observe-page-state.js +89 -0
  123. package/dist/commands/observe-persistence.d.ts +15 -0
  124. package/dist/commands/observe-persistence.d.ts.map +1 -0
  125. package/dist/commands/observe-persistence.js +238 -0
  126. package/dist/commands/observe-projection.d.ts +119 -0
  127. package/dist/commands/observe-projection.d.ts.map +1 -0
  128. package/dist/commands/observe-projection.js +726 -0
  129. package/dist/commands/observe-protected.d.ts +6 -0
  130. package/dist/commands/observe-protected.d.ts.map +1 -0
  131. package/dist/commands/observe-protected.js +31 -0
  132. package/dist/commands/observe-semantics.d.ts +10 -0
  133. package/dist/commands/observe-semantics.d.ts.map +1 -0
  134. package/dist/commands/observe-semantics.js +535 -0
  135. package/dist/commands/observe-signals.d.ts +48 -0
  136. package/dist/commands/observe-signals.d.ts.map +1 -0
  137. package/dist/commands/observe-signals.js +461 -0
  138. package/dist/commands/observe-stagehand.d.ts +49 -0
  139. package/dist/commands/observe-stagehand.d.ts.map +1 -0
  140. package/dist/commands/observe-stagehand.js +94 -0
  141. package/dist/commands/observe-surfaces.d.ts +11 -0
  142. package/dist/commands/observe-surfaces.d.ts.map +1 -0
  143. package/dist/commands/observe-surfaces.js +290 -0
  144. package/dist/commands/observe.d.ts +113 -0
  145. package/dist/commands/observe.d.ts.map +1 -0
  146. package/dist/commands/observe.js +556 -0
  147. package/dist/commands/screenshot.d.ts +37 -0
  148. package/dist/commands/screenshot.d.ts.map +1 -0
  149. package/dist/commands/screenshot.js +269 -0
  150. package/dist/commands/select-action-executor.d.ts +10 -0
  151. package/dist/commands/select-action-executor.d.ts.map +1 -0
  152. package/dist/commands/select-action-executor.js +156 -0
  153. package/dist/commands/semantic-observe-lexical.d.ts +31 -0
  154. package/dist/commands/semantic-observe-lexical.d.ts.map +1 -0
  155. package/dist/commands/semantic-observe-lexical.js +186 -0
  156. package/dist/commands/semantic-observe.d.ts +37 -0
  157. package/dist/commands/semantic-observe.d.ts.map +1 -0
  158. package/dist/commands/semantic-observe.js +1339 -0
  159. package/dist/commands/structured-grid-action-executor.d.ts +3 -0
  160. package/dist/commands/structured-grid-action-executor.d.ts.map +1 -0
  161. package/dist/commands/structured-grid-action-executor.js +4 -0
  162. package/dist/commands/target-resolution.d.ts +4 -0
  163. package/dist/commands/target-resolution.d.ts.map +1 -0
  164. package/dist/commands/target-resolution.js +33 -0
  165. package/dist/commands/text-input-action-executor.d.ts +5 -0
  166. package/dist/commands/text-input-action-executor.d.ts.map +1 -0
  167. package/dist/commands/text-input-action-executor.js +116 -0
  168. package/dist/commands/user-actionable.d.ts +4 -0
  169. package/dist/commands/user-actionable.d.ts.map +1 -0
  170. package/dist/commands/user-actionable.js +216 -0
  171. package/dist/control-semantics.d.ts +30 -0
  172. package/dist/control-semantics.d.ts.map +1 -0
  173. package/dist/control-semantics.js +419 -0
  174. package/dist/diagnostics.d.ts +132 -0
  175. package/dist/diagnostics.d.ts.map +1 -0
  176. package/dist/diagnostics.js +120 -0
  177. package/dist/index.d.ts +5 -0
  178. package/dist/index.d.ts.map +1 -0
  179. package/dist/index.js +350 -0
  180. package/dist/library.d.ts +17 -0
  181. package/dist/library.d.ts.map +1 -0
  182. package/dist/library.js +14 -0
  183. package/dist/output.d.ts +32 -0
  184. package/dist/output.d.ts.map +1 -0
  185. package/dist/output.js +33 -0
  186. package/dist/owned-browser.d.ts +12 -0
  187. package/dist/owned-browser.d.ts.map +1 -0
  188. package/dist/owned-browser.js +69 -0
  189. package/dist/owned-process.d.ts +19 -0
  190. package/dist/owned-process.d.ts.map +1 -0
  191. package/dist/owned-process.js +145 -0
  192. package/dist/playwright-runtime.d.ts +43 -0
  193. package/dist/playwright-runtime.d.ts.map +1 -0
  194. package/dist/playwright-runtime.js +339 -0
  195. package/dist/protected-fill-browser.d.ts +22 -0
  196. package/dist/protected-fill-browser.d.ts.map +1 -0
  197. package/dist/protected-fill-browser.js +52 -0
  198. package/dist/protected-fill.d.ts +82 -0
  199. package/dist/protected-fill.d.ts.map +1 -0
  200. package/dist/protected-fill.js +20 -0
  201. package/dist/runtime-metrics.d.ts +27 -0
  202. package/dist/runtime-metrics.d.ts.map +1 -0
  203. package/dist/runtime-metrics.js +66 -0
  204. package/dist/runtime-page-state.d.ts +11 -0
  205. package/dist/runtime-page-state.d.ts.map +1 -0
  206. package/dist/runtime-page-state.js +62 -0
  207. package/dist/runtime-protected-state.d.ts +14 -0
  208. package/dist/runtime-protected-state.d.ts.map +1 -0
  209. package/dist/runtime-protected-state.js +148 -0
  210. package/dist/runtime-resolution.d.ts +9 -0
  211. package/dist/runtime-resolution.d.ts.map +1 -0
  212. package/dist/runtime-resolution.js +19 -0
  213. package/dist/runtime-state.d.ts +251 -0
  214. package/dist/runtime-state.d.ts.map +1 -0
  215. package/dist/runtime-state.js +599 -0
  216. package/dist/secrets/catalog-applicability.d.ts +5 -0
  217. package/dist/secrets/catalog-applicability.d.ts.map +1 -0
  218. package/dist/secrets/catalog-applicability.js +59 -0
  219. package/dist/secrets/field-policy.d.ts +3 -0
  220. package/dist/secrets/field-policy.d.ts.map +1 -0
  221. package/dist/secrets/field-policy.js +3 -0
  222. package/dist/secrets/fill-ordering.d.ts +10 -0
  223. package/dist/secrets/fill-ordering.d.ts.map +1 -0
  224. package/dist/secrets/fill-ordering.js +41 -0
  225. package/dist/secrets/form-matcher.d.ts +60 -0
  226. package/dist/secrets/form-matcher.d.ts.map +1 -0
  227. package/dist/secrets/form-matcher.js +948 -0
  228. package/dist/secrets/protected-artifact-guard.d.ts +39 -0
  229. package/dist/secrets/protected-artifact-guard.d.ts.map +1 -0
  230. package/dist/secrets/protected-artifact-guard.js +44 -0
  231. package/dist/secrets/protected-bindings.d.ts +14 -0
  232. package/dist/secrets/protected-bindings.d.ts.map +1 -0
  233. package/dist/secrets/protected-bindings.js +29 -0
  234. package/dist/secrets/protected-exact-value-redaction.d.ts +14 -0
  235. package/dist/secrets/protected-exact-value-redaction.d.ts.map +1 -0
  236. package/dist/secrets/protected-exact-value-redaction.js +360 -0
  237. package/dist/secrets/protected-field-semantics.d.ts +9 -0
  238. package/dist/secrets/protected-field-semantics.d.ts.map +1 -0
  239. package/dist/secrets/protected-field-semantics.js +154 -0
  240. package/dist/secrets/protected-field-values.d.ts +15 -0
  241. package/dist/secrets/protected-field-values.d.ts.map +1 -0
  242. package/dist/secrets/protected-field-values.js +131 -0
  243. package/dist/secrets/protected-fill.d.ts +47 -0
  244. package/dist/secrets/protected-fill.d.ts.map +1 -0
  245. package/dist/secrets/protected-fill.js +446 -0
  246. package/dist/secrets/protected-value-adapters.d.ts +4 -0
  247. package/dist/secrets/protected-value-adapters.d.ts.map +1 -0
  248. package/dist/secrets/protected-value-adapters.js +118 -0
  249. package/dist/secrets/types.d.ts +70 -0
  250. package/dist/secrets/types.d.ts.map +1 -0
  251. package/dist/secrets/types.js +30 -0
  252. package/dist/session.d.ts +19 -0
  253. package/dist/session.d.ts.map +1 -0
  254. package/dist/session.js +120 -0
  255. package/dist/solver/browser-launcher.d.ts +14 -0
  256. package/dist/solver/browser-launcher.d.ts.map +1 -0
  257. package/dist/solver/browser-launcher.js +799 -0
  258. package/dist/solver/config.d.ts +18 -0
  259. package/dist/solver/config.d.ts.map +1 -0
  260. package/dist/solver/config.js +67 -0
  261. package/dist/solver/fingerprint.d.ts +9 -0
  262. package/dist/solver/fingerprint.d.ts.map +1 -0
  263. package/dist/solver/fingerprint.js +96 -0
  264. package/dist/solver/profile-manager.d.ts +8 -0
  265. package/dist/solver/profile-manager.d.ts.map +1 -0
  266. package/dist/solver/profile-manager.js +74 -0
  267. package/dist/solver/turnstile-challenge.d.ts +3 -0
  268. package/dist/solver/turnstile-challenge.d.ts.map +1 -0
  269. package/dist/solver/turnstile-challenge.js +173 -0
  270. package/dist/solver/types.d.ts +67 -0
  271. package/dist/solver/types.d.ts.map +1 -0
  272. package/dist/solver/types.js +1 -0
  273. package/dist/stagehand-runtime.d.ts +4 -0
  274. package/dist/stagehand-runtime.d.ts.map +1 -0
  275. package/dist/stagehand-runtime.js +10 -0
  276. package/dist/stagehand.d.ts +15 -0
  277. package/dist/stagehand.d.ts.map +1 -0
  278. package/dist/stagehand.js +19 -0
  279. package/dist/testing.d.ts +5 -0
  280. package/dist/testing.d.ts.map +1 -0
  281. package/dist/testing.js +4 -0
  282. package/dist/update-check.d.ts +14 -0
  283. package/dist/update-check.d.ts.map +1 -0
  284. package/dist/update-check.js +182 -0
  285. package/dist/workflow-session-state.d.ts +30 -0
  286. package/dist/workflow-session-state.d.ts.map +1 -0
  287. package/dist/workflow-session-state.js +74 -0
  288. package/docs/README.md +25 -0
  289. package/docs/api-reference.md +242 -0
  290. package/docs/assistive-runtime.md +148 -0
  291. package/docs/configuration.md +287 -0
  292. package/docs/getting-started.md +237 -0
  293. package/docs/integration-checklist.md +36 -0
  294. package/docs/protected-fill.md +112 -0
  295. package/docs/testing.md +50 -0
  296. package/docs/troubleshooting.md +71 -0
  297. package/examples/README.md +18 -0
  298. package/examples/attach.ts +27 -0
  299. package/examples/basic.ts +36 -0
  300. package/examples/extract.ts +50 -0
  301. package/package.json +83 -0
@@ -0,0 +1,33 @@
1
+ import type { Page } from 'playwright-core';
2
+ import type { BrowseAction } from './browse-actions.js';
3
+ type TraceController = {
4
+ finishSuccess(): Promise<void>;
5
+ finishFailure(artifactDir: string): Promise<string | undefined>;
6
+ };
7
+ export type ActionFailureArtifacts = {
8
+ dir: string;
9
+ screenshotPath?: string;
10
+ htmlPath?: string;
11
+ tracePath?: string;
12
+ actionLogPath: string;
13
+ };
14
+ export declare function startActionTrace(page: Page, options?: {
15
+ suppressSensitiveArtifacts?: boolean;
16
+ }): Promise<TraceController>;
17
+ export declare function captureActionFailureArtifacts(params: {
18
+ page: Page;
19
+ targetRef: string;
20
+ action: BrowseAction;
21
+ pageRef: string;
22
+ attempts: string[];
23
+ locatorStrategy?: string | null;
24
+ popup: boolean;
25
+ overlayHandled: boolean;
26
+ iframe: boolean;
27
+ jsFallback: boolean;
28
+ durationMs: number;
29
+ error: string;
30
+ finishTrace(artifactDir: string): Promise<string | undefined>;
31
+ }): Promise<ActionFailureArtifacts>;
32
+ export {};
33
+ //# sourceMappingURL=action-artifacts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-artifacts.d.ts","sourceRoot":"","sources":["../../src/commands/action-artifacts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,KAAK,eAAe,GAAG;IACrB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAWF,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,OAAO,GAAE;IACP,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACjC,GACL,OAAO,CAAC,eAAe,CAAC,CAsD1B;AAED,wBAAsB,6BAA6B,CAAC,MAAM,EAAE;IAC1D,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,KAAK,EAAE,OAAO,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAC/D,GAAG,OAAO,CAAC,sBAAsB,CAAC,CA4DlC"}
@@ -0,0 +1,104 @@
1
+ import { mkdir, writeFile } from 'node:fs/promises';
2
+ import { tmpdir } from 'node:os';
3
+ import path from 'node:path';
4
+ function sanitizeSegment(value) {
5
+ return (value
6
+ .replace(/[^a-zA-Z0-9._-]+/g, '-')
7
+ .replace(/^-+|-+$/g, '')
8
+ .slice(0, 64) || 'item');
9
+ }
10
+ export async function startActionTrace(page, options = {}) {
11
+ if (options.suppressSensitiveArtifacts) {
12
+ return {
13
+ finishSuccess: async () => { },
14
+ finishFailure: async () => undefined,
15
+ };
16
+ }
17
+ const tracing = page.context().tracing;
18
+ if (!tracing?.start || !tracing?.stop) {
19
+ return {
20
+ finishSuccess: async () => { },
21
+ finishFailure: async () => undefined,
22
+ };
23
+ }
24
+ let active = false;
25
+ try {
26
+ await tracing.start({ screenshots: true, snapshots: true });
27
+ active = true;
28
+ }
29
+ catch {
30
+ active = false;
31
+ }
32
+ return {
33
+ finishSuccess: async () => {
34
+ if (!active)
35
+ return;
36
+ active = false;
37
+ try {
38
+ await tracing.stop();
39
+ }
40
+ catch {
41
+ // Best effort only.
42
+ }
43
+ },
44
+ finishFailure: async (artifactDir) => {
45
+ if (!active)
46
+ return undefined;
47
+ active = false;
48
+ const tracePath = path.join(artifactDir, 'trace.zip');
49
+ try {
50
+ await tracing.stop({ path: tracePath });
51
+ return tracePath;
52
+ }
53
+ catch {
54
+ return undefined;
55
+ }
56
+ },
57
+ };
58
+ }
59
+ export async function captureActionFailureArtifacts(params) {
60
+ const artifactDir = path.join(tmpdir(), 'agentbrowse-artifacts', `act-${Date.now()}-${sanitizeSegment(params.targetRef)}-${sanitizeSegment(params.action)}`);
61
+ await mkdir(artifactDir, { recursive: true });
62
+ let screenshotPath;
63
+ try {
64
+ screenshotPath = path.join(artifactDir, 'page.png');
65
+ await params.page.screenshot({ path: screenshotPath, fullPage: true });
66
+ }
67
+ catch {
68
+ screenshotPath = undefined;
69
+ }
70
+ let htmlPath;
71
+ try {
72
+ htmlPath = path.join(artifactDir, 'page.html');
73
+ const html = await params.page.content();
74
+ await writeFile(htmlPath, html, 'utf-8');
75
+ }
76
+ catch {
77
+ htmlPath = undefined;
78
+ }
79
+ const tracePath = await params.finishTrace(artifactDir);
80
+ const actionLogPath = path.join(artifactDir, 'action-log.json');
81
+ await writeFile(actionLogPath, JSON.stringify({
82
+ targetRef: params.targetRef,
83
+ action: params.action,
84
+ pageRef: params.pageRef,
85
+ locatorStrategy: params.locatorStrategy ?? undefined,
86
+ attempts: params.attempts,
87
+ popup: params.popup,
88
+ overlayHandled: params.overlayHandled,
89
+ iframe: params.iframe,
90
+ jsFallback: params.jsFallback,
91
+ durationMs: params.durationMs,
92
+ error: params.error,
93
+ screenshotPath,
94
+ htmlPath,
95
+ tracePath,
96
+ }, null, 2) + '\n', 'utf-8');
97
+ return {
98
+ dir: artifactDir,
99
+ screenshotPath,
100
+ htmlPath,
101
+ tracePath,
102
+ actionLogPath,
103
+ };
104
+ }
@@ -0,0 +1,5 @@
1
+ export type ActionExecutionGuards = {
2
+ assertStillValid?: (stage: string) => Promise<void>;
3
+ };
4
+ export declare function runActionExecutionGuard(guards: ActionExecutionGuards | undefined, stage: string): Promise<void>;
5
+ //# sourceMappingURL=action-execution-guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-execution-guards.d.ts","sourceRoot":"","sources":["../../src/commands/action-execution-guards.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;AAEF,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,qBAAqB,GAAG,SAAS,EACzC,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAEf"}
@@ -0,0 +1,3 @@
1
+ export async function runActionExecutionGuard(guards, stage) {
2
+ await guards?.assertStillValid?.(stage);
3
+ }
@@ -0,0 +1,21 @@
1
+ import type { Locator, Page } from 'playwright-core';
2
+ export declare const LOCATOR_CLICK_TIMEOUT_MS = 1500;
3
+ export declare const LOCATOR_FILL_TIMEOUT_MS = 1500;
4
+ export declare function looksLikeOverlayInterference(error: unknown): boolean;
5
+ export declare function dismissBlockingOverlay(page: Page, attempts: string[]): Promise<boolean>;
6
+ export declare function applyValueWithJsFallback(locator: Locator, value: string, attempts: string[]): Promise<void>;
7
+ export declare function focusLocator(page: Page, locator: Locator, attempts: string[]): Promise<void>;
8
+ export declare function normalizeFillValue(locator: Locator, value: string, attempts: string[]): Promise<string>;
9
+ export declare function readLocatorCurrentValue(locator: Locator): Promise<string>;
10
+ export declare function planTextFillStrategy(locator: Locator, value: string, attempts: string[]): Promise<{
11
+ normalizedValue: string;
12
+ preferSequential: boolean;
13
+ settleMs: number;
14
+ initialPhonePrefix: string | null;
15
+ blurAfterFill: boolean;
16
+ }>;
17
+ export declare function normalizeDigitsOnly(value: string): string;
18
+ export declare function deriveMaskedSequentialValue(value: string, residualValue: string, initialPhonePrefix: string | null, attempts: string[]): string;
19
+ export declare function clearLocatorForReplacement(locator: Locator, attempts: string[]): Promise<void>;
20
+ export declare function blurLocator(locator: Locator, attempts: string[]): Promise<void>;
21
+ //# sourceMappingURL=action-executor-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-executor-helpers.d.ts","sourceRoot":"","sources":["../../src/commands/action-executor-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAgBrD,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AAC9C,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAkB7C,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAWpE;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAqB7F;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,IAAI,CAAC,CAsCf;AAED,wBAAsB,YAAY,CAChC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,IAAI,CAAC,CAmBf;AAED,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,MAAM,CAAC,CAOjB;AA2GD,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAE/E;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC;IACT,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC,CAqBD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EACrB,kBAAkB,EAAE,MAAM,GAAG,IAAI,EACjC,QAAQ,EAAE,MAAM,EAAE,GACjB,MAAM,CAkBR;AAED,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,IAAI,CAAC,CAYf;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAarF"}
@@ -0,0 +1,265 @@
1
+ import { inferComparableValueTypeFromFacts } from '../control-semantics.js';
2
+ const OVERLAY_DISMISS_SELECTORS = [
3
+ '[aria-label="Close"]',
4
+ '[aria-label="Dismiss"]',
5
+ '[data-testid*="close"]',
6
+ '[data-testid*="dismiss"]',
7
+ 'button:has-text("Close")',
8
+ 'button:has-text("Dismiss")',
9
+ 'button:has-text("Not now")',
10
+ 'button:has-text("No thanks")',
11
+ 'button:has-text("Skip")',
12
+ 'button:has-text("Maybe later")',
13
+ ];
14
+ export const LOCATOR_CLICK_TIMEOUT_MS = 1_500;
15
+ export const LOCATOR_FILL_TIMEOUT_MS = 1_500;
16
+ const DATE_MASK_PLACEHOLDER_RE = /(?:^|\b)(?:dd|d|дд|д)\s*[./-]\s*(?:mm|m|мм|м)\s*[./-]\s*(?:yyyy|yyy|yy|y|гггг|гг|г)(?:\b|$)/i;
17
+ const DATE_FIELD_HINT_RE = /\b(?:birth|dob|date|dates|expire|expires|expiry|expir|bday)\b|(?:дата|рожд|срок)/i;
18
+ const ISO_DATE_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
19
+ export function looksLikeOverlayInterference(error) {
20
+ const message = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();
21
+ return (message.includes('intercept') ||
22
+ message.includes('another element') ||
23
+ message.includes('not receiving pointer events') ||
24
+ message.includes('obscured') ||
25
+ message.includes('blocked by') ||
26
+ message.includes('element click intercepted'));
27
+ }
28
+ export async function dismissBlockingOverlay(page, attempts) {
29
+ attempts.push('overlay.dismiss.scan');
30
+ for (const selector of OVERLAY_DISMISS_SELECTORS) {
31
+ const candidate = page.locator(selector).first();
32
+ const visible = await candidate.isVisible().catch(() => false);
33
+ if (!visible) {
34
+ continue;
35
+ }
36
+ attempts.push(`overlay.dismiss:${selector}`);
37
+ try {
38
+ await candidate.click({ timeout: LOCATOR_CLICK_TIMEOUT_MS });
39
+ attempts.push('overlay.dismissed');
40
+ return true;
41
+ }
42
+ catch {
43
+ continue;
44
+ }
45
+ }
46
+ return false;
47
+ }
48
+ export async function applyValueWithJsFallback(locator, value, attempts) {
49
+ attempts.push('locator.evaluate.setValue');
50
+ await locator.evaluate((element, nextValue) => {
51
+ if (!(element instanceof HTMLElement)) {
52
+ throw new Error('unsupported_js_value_fallback');
53
+ }
54
+ if (element instanceof HTMLInputElement ||
55
+ element instanceof HTMLTextAreaElement ||
56
+ element instanceof HTMLSelectElement) {
57
+ const prototype = element instanceof HTMLInputElement
58
+ ? HTMLInputElement.prototype
59
+ : element instanceof HTMLTextAreaElement
60
+ ? HTMLTextAreaElement.prototype
61
+ : HTMLSelectElement.prototype;
62
+ const setter = Object.getOwnPropertyDescriptor(prototype, 'value')?.set;
63
+ if (setter) {
64
+ setter.call(element, nextValue);
65
+ }
66
+ else {
67
+ element.value = nextValue;
68
+ }
69
+ element.dispatchEvent(new Event('input', { bubbles: true }));
70
+ element.dispatchEvent(new Event('change', { bubbles: true }));
71
+ return;
72
+ }
73
+ if (element.isContentEditable) {
74
+ element.textContent = nextValue;
75
+ element.dispatchEvent(new Event('input', { bubbles: true }));
76
+ element.dispatchEvent(new Event('change', { bubbles: true }));
77
+ return;
78
+ }
79
+ throw new Error('unsupported_js_value_fallback');
80
+ }, value);
81
+ }
82
+ export async function focusLocator(page, locator, attempts) {
83
+ attempts.push('locator.click');
84
+ try {
85
+ await locator.click({ timeout: LOCATOR_CLICK_TIMEOUT_MS });
86
+ }
87
+ catch (error) {
88
+ if (looksLikeOverlayInterference(error)) {
89
+ const dismissed = await dismissBlockingOverlay(page, attempts);
90
+ if (dismissed) {
91
+ attempts.push('locator.click.retry.afterOverlay');
92
+ try {
93
+ await locator.click({ timeout: LOCATOR_CLICK_TIMEOUT_MS });
94
+ return;
95
+ }
96
+ catch {
97
+ // Ignore focus click failure and fall through.
98
+ }
99
+ }
100
+ }
101
+ // Ignore focus click failure and let downstream fallback continue.
102
+ }
103
+ }
104
+ export async function normalizeFillValue(locator, value, attempts) {
105
+ const metadata = await readTextEntryMetadata(locator);
106
+ const normalized = normalizeDateLikeValue(value, metadata);
107
+ if (normalized !== value) {
108
+ attempts.push('fill.normalize:date-mask');
109
+ }
110
+ return normalized;
111
+ }
112
+ function extractPhonePrefix(value) {
113
+ const raw = (value ?? '').trim();
114
+ if (!raw.startsWith('+')) {
115
+ return null;
116
+ }
117
+ const explicitBoundary = raw.match(/^\+\d{1,4}(?=[\s(.-]|$)/);
118
+ if (explicitBoundary) {
119
+ return explicitBoundary[0];
120
+ }
121
+ return null;
122
+ }
123
+ async function readTextEntryMetadata(locator) {
124
+ const [type, autocomplete, name, role, ariaHasPopup, ariaControls, ariaExpanded, placeholder, id, currentValue,] = await Promise.all([
125
+ locator.getAttribute?.('type').catch(() => null),
126
+ locator.getAttribute?.('autocomplete').catch(() => null),
127
+ locator.getAttribute?.('name').catch(() => null),
128
+ locator.getAttribute?.('role').catch(() => null),
129
+ locator.getAttribute?.('aria-haspopup').catch(() => null),
130
+ locator.getAttribute?.('aria-controls').catch(() => null),
131
+ locator.getAttribute?.('aria-expanded').catch(() => null),
132
+ locator.getAttribute?.('placeholder').catch(() => null),
133
+ locator.getAttribute?.('id').catch(() => null),
134
+ typeof locator.inputValue === 'function' ? locator.inputValue().catch(() => '') : '',
135
+ ]);
136
+ const normalizedType = (type || '').toLowerCase();
137
+ const normalizedAutocomplete = (autocomplete || '').toLowerCase();
138
+ const normalizedName = (name || '').toLowerCase();
139
+ const cardAutocomplete = normalizedAutocomplete.startsWith('cc-');
140
+ const phoneLike = !cardAutocomplete &&
141
+ (normalizedType === 'tel' ||
142
+ normalizedAutocomplete.includes('tel') ||
143
+ normalizedName.includes('phone'));
144
+ const comparableValueType = inferComparableValueTypeFromFacts({
145
+ kind: 'input',
146
+ role: role || undefined,
147
+ placeholder: placeholder || undefined,
148
+ inputName: name || undefined,
149
+ inputType: type || undefined,
150
+ autocomplete: autocomplete || undefined,
151
+ });
152
+ const dateHintBlob = [type, autocomplete, name, placeholder, id]
153
+ .filter((value) => typeof value === 'string' && value.trim().length > 0)
154
+ .join(' ');
155
+ const nativeDateInput = normalizedType === 'date';
156
+ const trimmedPlaceholder = (placeholder || '').trim();
157
+ const dateSeparator = trimmedPlaceholder.includes('/')
158
+ ? '/'
159
+ : trimmedPlaceholder.includes('-')
160
+ ? '-'
161
+ : '.';
162
+ const maskedDateLike = !nativeDateInput &&
163
+ comparableValueType !== 'expiry' &&
164
+ (DATE_MASK_PLACEHOLDER_RE.test(trimmedPlaceholder) || DATE_FIELD_HINT_RE.test(dateHintBlob));
165
+ const popupBackedTextEntry = Boolean((ariaControls || '').trim()) ||
166
+ ['listbox', 'menu'].includes((ariaHasPopup || '').toLowerCase()) ||
167
+ (role || '').toLowerCase() === 'combobox' ||
168
+ ariaExpanded !== null;
169
+ return {
170
+ phoneLike,
171
+ popupBackedTextEntry,
172
+ maskedDateLike,
173
+ nativeDateInput,
174
+ dateSeparator,
175
+ currentValue: currentValue || '',
176
+ currentPhonePrefix: phoneLike ? extractPhonePrefix(currentValue || '') : null,
177
+ };
178
+ }
179
+ function normalizeDateLikeValue(value, metadata) {
180
+ if (metadata.nativeDateInput) {
181
+ return value;
182
+ }
183
+ if (!metadata.maskedDateLike) {
184
+ return value;
185
+ }
186
+ const isoMatch = value.match(ISO_DATE_RE);
187
+ if (!isoMatch) {
188
+ return value;
189
+ }
190
+ const [, year, month, day] = isoMatch;
191
+ return `${day}${metadata.dateSeparator}${month}${metadata.dateSeparator}${year}`;
192
+ }
193
+ export async function readLocatorCurrentValue(locator) {
194
+ return typeof locator.inputValue === 'function' ? locator.inputValue().catch(() => '') : '';
195
+ }
196
+ export async function planTextFillStrategy(locator, value, attempts) {
197
+ const metadata = await readTextEntryMetadata(locator);
198
+ if (metadata.phoneLike) {
199
+ attempts.push('fill.strategy:masked-sequential');
200
+ }
201
+ else if (metadata.maskedDateLike) {
202
+ attempts.push('fill.strategy:date-sequential');
203
+ }
204
+ else if (metadata.popupBackedTextEntry) {
205
+ attempts.push('fill.strategy:popup-sequential');
206
+ }
207
+ return {
208
+ normalizedValue: normalizeDateLikeValue(value, metadata),
209
+ preferSequential: metadata.phoneLike || metadata.popupBackedTextEntry || metadata.maskedDateLike,
210
+ settleMs: metadata.phoneLike
211
+ ? 120
212
+ : metadata.popupBackedTextEntry || metadata.maskedDateLike
213
+ ? 80
214
+ : 0,
215
+ initialPhonePrefix: metadata.currentPhonePrefix,
216
+ blurAfterFill: metadata.maskedDateLike,
217
+ };
218
+ }
219
+ export function normalizeDigitsOnly(value) {
220
+ return value.replace(/\s+/g, '');
221
+ }
222
+ export function deriveMaskedSequentialValue(value, residualValue, initialPhonePrefix, attempts) {
223
+ const normalizedIncoming = normalizeDigitsOnly(value);
224
+ if (!/^\d{5,}$/.test(normalizedIncoming) || normalizedIncoming.startsWith('+')) {
225
+ return value;
226
+ }
227
+ const residualPrefix = extractPhonePrefix(residualValue);
228
+ if (residualPrefix) {
229
+ attempts.push(`fill.masked.residual-prefix:${residualPrefix}`);
230
+ return value;
231
+ }
232
+ if (initialPhonePrefix) {
233
+ attempts.push(`fill.masked.initial-prefix:${initialPhonePrefix}`);
234
+ return `${initialPhonePrefix}${normalizedIncoming}`;
235
+ }
236
+ return value;
237
+ }
238
+ export async function clearLocatorForReplacement(locator, attempts) {
239
+ if (typeof locator.selectText === 'function') {
240
+ attempts.push('locator.selectText');
241
+ try {
242
+ await locator.selectText();
243
+ attempts.push('locator.press:Backspace');
244
+ await locator.press('Backspace');
245
+ return;
246
+ }
247
+ catch {
248
+ // Fall through to downstream replacement strategies.
249
+ }
250
+ }
251
+ }
252
+ export async function blurLocator(locator, attempts) {
253
+ if (typeof locator.blur === 'function') {
254
+ attempts.push('locator.blur');
255
+ try {
256
+ await locator.blur();
257
+ return;
258
+ }
259
+ catch {
260
+ // Fall through to DOM-event fallback.
261
+ }
262
+ }
263
+ attempts.push('locator.dispatchEvent:blur');
264
+ await locator.dispatchEvent?.('blur').catch(() => { });
265
+ }
@@ -0,0 +1,14 @@
1
+ import type { Locator, Page } from 'playwright-core';
2
+ import type { TargetControlFamily } from '../runtime-state.js';
3
+ import type { BrowseAction } from './browse-actions.js';
4
+ import type { LocatorRoot } from './action-fallbacks.js';
5
+ import type { ActionExecutionGuards } from './action-execution-guards.js';
6
+ import type { ClickActivationStrategy } from './click-activation-policy.js';
7
+ type ActionExecutionOptions = {
8
+ beforeClickRetry?: () => Promise<void>;
9
+ guards?: ActionExecutionGuards;
10
+ clickActivationStrategy?: ClickActivationStrategy;
11
+ };
12
+ export declare function applyActionWithFallbacks(page: Page, root: LocatorRoot, locator: Locator, action: BrowseAction, value: string | undefined, attempts: string[], family?: TargetControlFamily, options?: ActionExecutionOptions): Promise<boolean>;
13
+ export {};
14
+ //# sourceMappingURL=action-executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-executor.d.ts","sourceRoot":"","sources":["../../src/commands/action-executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAc5E,KAAK,sBAAsB,GAAG;IAC5B,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD,CAAC;AAEF,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,QAAQ,EAAE,MAAM,EAAE,EAClB,MAAM,CAAC,EAAE,mBAAmB,EAC5B,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,OAAO,CAAC,CAsDlB"}
@@ -0,0 +1,46 @@
1
+ import { applyValueWithJsFallback, blurLocator, clearLocatorForReplacement, focusLocator, normalizeFillValue, } from './action-executor-helpers.js';
2
+ import { applyEditableClickAction, applyTriggerAction } from './click-action-executor.js';
3
+ import { applyDatepickerAction } from './datepicker-action-executor.js';
4
+ import { applySelectLikeAction } from './select-action-executor.js';
5
+ import { applyStructuredGridAction } from './structured-grid-action-executor.js';
6
+ import { applyTextFillAction, applyTypeAction } from './text-input-action-executor.js';
7
+ export async function applyActionWithFallbacks(page, root, locator, action, value, attempts, family, options) {
8
+ switch (action) {
9
+ case 'click':
10
+ if (family === 'structured-grid') {
11
+ return applyStructuredGridAction(page, locator, attempts);
12
+ }
13
+ if (family === 'trigger') {
14
+ return applyTriggerAction(page, locator, attempts, {
15
+ beforeRetry: options?.beforeClickRetry,
16
+ guards: options?.guards,
17
+ clickActivationStrategy: options?.clickActivationStrategy,
18
+ });
19
+ }
20
+ return applyEditableClickAction(page, locator, attempts, {
21
+ beforeRetry: options?.beforeClickRetry,
22
+ guards: options?.guards,
23
+ });
24
+ case 'fill':
25
+ return family === 'datepicker'
26
+ ? applyDatepickerAction(page, locator, value, attempts, {
27
+ normalizeFillValue,
28
+ focusLocator,
29
+ clearLocatorForReplacement,
30
+ applyValueWithJsFallback,
31
+ blurLocator,
32
+ }, options?.guards)
33
+ : applyTextFillAction(page, locator, value, attempts, options?.guards);
34
+ case 'type':
35
+ return applyTypeAction(page, locator, value, attempts, options?.guards);
36
+ case 'select':
37
+ return applySelectLikeAction(page, root, locator, value, attempts, {
38
+ focusLocator,
39
+ clearLocatorForReplacement,
40
+ }, options?.guards);
41
+ case 'press':
42
+ attempts.push('locator.press');
43
+ await locator.press(value);
44
+ return false;
45
+ }
46
+ }
@@ -0,0 +1,6 @@
1
+ import type { FrameLocator, Locator, Page } from 'playwright-core';
2
+ import type { LocatorCandidate } from '../runtime-state.js';
3
+ export type LocatorRoot = Page | FrameLocator | Locator;
4
+ export declare function resolveLocatorRoot(page: Page, framePath?: ReadonlyArray<string>): LocatorRoot;
5
+ export declare function buildLocator(root: LocatorRoot, candidate: LocatorCandidate): Locator | null;
6
+ //# sourceMappingURL=action-fallbacks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-fallbacks.d.ts","sourceRoot":"","sources":["../../src/commands/action-fallbacks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,YAAY,GAAG,OAAO,CAAC;AAcxD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,WAAW,CAU7F;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,gBAAgB,GAAG,OAAO,GAAG,IAAI,CAsB3F"}
@@ -0,0 +1,43 @@
1
+ function escapeSelectorAttributeValue(value) {
2
+ return JSON.stringify(value);
3
+ }
4
+ function buildTestIdSelector(value, attribute) {
5
+ const escapedValue = escapeSelectorAttributeValue(value);
6
+ if (attribute) {
7
+ return `[${attribute}=${escapedValue}]`;
8
+ }
9
+ return `[data-testid=${escapedValue}], [data-test-id=${escapedValue}]`;
10
+ }
11
+ export function resolveLocatorRoot(page, framePath) {
12
+ if (!framePath || framePath.length === 0) {
13
+ return page;
14
+ }
15
+ let root = page;
16
+ for (const frameSelector of framePath) {
17
+ root = root.frameLocator(frameSelector);
18
+ }
19
+ return root;
20
+ }
21
+ export function buildLocator(root, candidate) {
22
+ switch (candidate.strategy) {
23
+ case 'role': {
24
+ const role = candidate.value;
25
+ return root.getByRole(role, candidate.name ? { name: candidate.name } : undefined);
26
+ }
27
+ case 'label':
28
+ return root.getByLabel(candidate.value);
29
+ case 'placeholder':
30
+ return root.getByPlaceholder(candidate.value);
31
+ case 'text':
32
+ return root.getByText(candidate.value);
33
+ case 'title':
34
+ return root.getByTitle(candidate.value);
35
+ case 'testId':
36
+ return root.locator(buildTestIdSelector(candidate.value, candidate.attribute));
37
+ case 'css':
38
+ case 'xpath':
39
+ return root.locator(candidate.value);
40
+ default:
41
+ return null;
42
+ }
43
+ }
@@ -0,0 +1,17 @@
1
+ import { type AcceptanceProbe, type PageObservation } from './action-acceptance.js';
2
+ export type SubmitResultClaimKind = 'hard_result' | 'hard_blocker' | 'intermediate_progress' | 'soft_result_candidate' | 'noisy_change';
3
+ export type SubmitResultClaim = {
4
+ kind: SubmitResultClaimKind;
5
+ source: string;
6
+ reason: string;
7
+ ownerScopeRef?: string;
8
+ };
9
+ export type SubmitResultResolution = {
10
+ finalVerdict: 'outcome' | 'blocked' | 'progress' | 'none';
11
+ claims: SubmitResultClaim[];
12
+ decisiveClaims: SubmitResultClaim[];
13
+ acceptAsProgress: boolean;
14
+ };
15
+ export declare function reduceSubmitResultClaims(claims: ReadonlyArray<SubmitResultClaim>): Omit<SubmitResultResolution, 'claims' | 'acceptAsProgress'>;
16
+ export declare function resolveSubmitResult(probe: AcceptanceProbe, afterPageObservation: PageObservation | null): Promise<SubmitResultResolution>;
17
+ //# sourceMappingURL=action-result-resolution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-result-resolution.d.ts","sourceRoot":"","sources":["../../src/commands/action-result-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;AAGhC,MAAM,MAAM,qBAAqB,GAC7B,aAAa,GACb,cAAc,GACd,uBAAuB,GACvB,uBAAuB,GACvB,cAAc,CAAC;AAEnB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,YAAY,EAAE,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;IAC1D,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,cAAc,EAAE,iBAAiB,EAAE,CAAC;IACpC,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,aAAa,CAAC,iBAAiB,CAAC,GACvC,IAAI,CAAC,sBAAsB,EAAE,QAAQ,GAAG,kBAAkB,CAAC,CA+B7D;AA2BD,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,eAAe,EACtB,oBAAoB,EAAE,eAAe,GAAG,IAAI,GAC3C,OAAO,CAAC,sBAAsB,CAAC,CA8FjC"}