@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,154 @@
1
+ import { inferComparableValueTypeFromFacts } from '../control-semantics.js';
2
+ const LOGIN_USERNAME_SIGNAL_RE = /\b(email|e-mail|username|user name|login|account(?: email| name)?|member(?: email| name| id)?)\b/i;
3
+ const LOGIN_PASSWORD_SIGNAL_RE = /\b(password|passcode|pass word)\b/i;
4
+ const PAYMENT_CARD_NAME_SIGNAL_RE = /\b(cardholder|card holder|name on card|cardholder name|full name)\b/i;
5
+ const PAYMENT_CARD_PAN_SIGNAL_RE = /\b(card number|card no|cc-number|cc number)\b/i;
6
+ const PAYMENT_CARD_EXP_SIGNAL_RE = /\b(expiration|expiry|exp(?:iry)? date|exp date|mm\s*\/\s*yy|mmyy|mm\/yy)\b/i;
7
+ const PAYMENT_CARD_CVV_SIGNAL_RE = /\b(security code|cvv|cvc)\b/i;
8
+ const IDENTITY_DOCUMENT_SIGNAL_RE = /\b(passport|document(?: number| no)?|id(?: number| no)?|identity(?: number)?)\b/i;
9
+ const IDENTITY_BIRTH_SIGNAL_RE = /\b(date of birth|birth date|dob)\b/i;
10
+ const IDENTITY_NATIONALITY_SIGNAL_RE = /\b(nationality|citizenship)\b/i;
11
+ const IDENTITY_ISSUING_COUNTRY_SIGNAL_RE = /\b(issuing country|country of issue|country\/region of issue|issuing state)\b/i;
12
+ const IDENTITY_ISSUE_DATE_SIGNAL_RE = /\b(issue date|date of issue)\b/i;
13
+ const IDENTITY_EXPIRY_DATE_SIGNAL_RE = /\b(expiry date|expiration date|date of expiry)\b/i;
14
+ function normalizeText(value) {
15
+ return value?.replace(/\s+/g, ' ').trim().toLowerCase() ?? '';
16
+ }
17
+ function directFieldSignals(target) {
18
+ const values = new Set();
19
+ const push = (value) => {
20
+ const normalized = normalizeText(value);
21
+ if (normalized) {
22
+ values.add(normalized);
23
+ }
24
+ };
25
+ push(target.label);
26
+ push(target.displayLabel);
27
+ push(target.placeholder);
28
+ push(target.inputName);
29
+ push(target.inputType);
30
+ push(target.autocomplete);
31
+ push(target.semantics?.name);
32
+ return [...values];
33
+ }
34
+ function uniqueMeaningHints(hints) {
35
+ const seen = new Set();
36
+ const result = [];
37
+ for (const hint of hints) {
38
+ const key = `${hint.kind}:${hint.fieldKey}:${hint.valueHint}`;
39
+ if (seen.has(key)) {
40
+ continue;
41
+ }
42
+ seen.add(key);
43
+ result.push(hint);
44
+ }
45
+ return result;
46
+ }
47
+ export function inferProtectedFieldMeaningFromTarget(target) {
48
+ const autocomplete = normalizeText(target.autocomplete);
49
+ const inputType = normalizeText(target.inputType);
50
+ const inputName = normalizeText(target.inputName);
51
+ const signals = directFieldSignals(target);
52
+ const comparableValueType = inferComparableValueTypeFromFacts({
53
+ kind: target.kind,
54
+ role: target.semantics?.role,
55
+ label: target.label,
56
+ displayLabel: target.displayLabel,
57
+ placeholder: target.placeholder,
58
+ inputName: target.inputName,
59
+ inputType: target.inputType,
60
+ autocomplete: target.autocomplete,
61
+ states: target.semantics?.states,
62
+ structure: target.structure,
63
+ });
64
+ const hints = [];
65
+ if (autocomplete.includes('username') ||
66
+ autocomplete.includes('email') ||
67
+ inputType === 'email' ||
68
+ /\b(user(name)?|login|email|account)\b/.test(inputName) ||
69
+ signals.some((signal) => LOGIN_USERNAME_SIGNAL_RE.test(signal))) {
70
+ hints.push({ kind: 'login', fieldKey: 'username', valueHint: 'direct' });
71
+ }
72
+ if (autocomplete.includes('current-password') ||
73
+ inputType === 'password' ||
74
+ /\bpassword\b/.test(inputName) ||
75
+ signals.some((signal) => LOGIN_PASSWORD_SIGNAL_RE.test(signal))) {
76
+ hints.push({ kind: 'login', fieldKey: 'password', valueHint: 'direct' });
77
+ }
78
+ if (autocomplete.includes('cc-number') || comparableValueType === 'card-number') {
79
+ hints.push({ kind: 'payment_card', fieldKey: 'pan', valueHint: 'direct' });
80
+ }
81
+ else if (/\b(card[-_ ]?number|cardnumber|cc-?number)\b/.test(inputName) ||
82
+ signals.some((signal) => PAYMENT_CARD_PAN_SIGNAL_RE.test(signal))) {
83
+ hints.push({ kind: 'payment_card', fieldKey: 'pan', valueHint: 'direct' });
84
+ }
85
+ if (autocomplete.includes('cc-exp') || comparableValueType === 'expiry') {
86
+ hints.push({ kind: 'payment_card', fieldKey: 'exp_month', valueHint: 'direct' });
87
+ hints.push({ kind: 'payment_card', fieldKey: 'exp_year', valueHint: 'direct' });
88
+ }
89
+ else if (/\b(exp|expiry|expiration)\b/.test(inputName) ||
90
+ signals.some((signal) => PAYMENT_CARD_EXP_SIGNAL_RE.test(signal))) {
91
+ hints.push({ kind: 'payment_card', fieldKey: 'exp_month', valueHint: 'direct' });
92
+ hints.push({ kind: 'payment_card', fieldKey: 'exp_year', valueHint: 'direct' });
93
+ }
94
+ if (autocomplete.includes('cc-csc') || comparableValueType === 'cvc') {
95
+ hints.push({ kind: 'payment_card', fieldKey: 'cvv', valueHint: 'direct' });
96
+ }
97
+ else if (/\b(cvv|cvc|security)\b/.test(inputName) ||
98
+ signals.some((signal) => PAYMENT_CARD_CVV_SIGNAL_RE.test(signal))) {
99
+ hints.push({ kind: 'payment_card', fieldKey: 'cvv', valueHint: 'direct' });
100
+ }
101
+ if (autocomplete.includes('cc-name') ||
102
+ /\b(cardholder|card-holder|cc-name)\b/.test(inputName) ||
103
+ signals.some((signal) => PAYMENT_CARD_NAME_SIGNAL_RE.test(signal))) {
104
+ hints.push({ kind: 'payment_card', fieldKey: 'cardholder', valueHint: 'direct' });
105
+ }
106
+ if (autocomplete.includes('given-name')) {
107
+ hints.push({ kind: 'identity', fieldKey: 'full_name', valueHint: 'full_name.given' });
108
+ }
109
+ if (autocomplete.includes('family-name')) {
110
+ hints.push({ kind: 'identity', fieldKey: 'full_name', valueHint: 'full_name.family' });
111
+ }
112
+ if (autocomplete === 'name' ||
113
+ /\bfull_?name\b/.test(inputName) ||
114
+ signals.some((signal) => /\bfull name\b/.test(signal))) {
115
+ hints.push({ kind: 'identity', fieldKey: 'full_name', valueHint: 'direct' });
116
+ }
117
+ if (/\b(first|given|forename)_?name\b/.test(inputName) ||
118
+ signals.some((signal) => /\b(first name|given name|forename)\b/.test(signal))) {
119
+ hints.push({ kind: 'identity', fieldKey: 'full_name', valueHint: 'full_name.given' });
120
+ }
121
+ if (/\b(last|family|surname)_?name\b/.test(inputName) ||
122
+ signals.some((signal) => /\b(last name|family name|surname)\b/.test(signal))) {
123
+ hints.push({ kind: 'identity', fieldKey: 'full_name', valueHint: 'full_name.family' });
124
+ }
125
+ if (autocomplete.includes('bday') ||
126
+ (comparableValueType === 'date' &&
127
+ (/\b(date_?of_?birth|birth_?date|dob)\b/.test(inputName) ||
128
+ signals.some((signal) => IDENTITY_BIRTH_SIGNAL_RE.test(signal))))) {
129
+ hints.push({ kind: 'identity', fieldKey: 'date_of_birth', valueHint: 'direct' });
130
+ }
131
+ if (/\b(passport|document|identity|id)(?:_?number|_?no)?\b/.test(inputName) ||
132
+ signals.some((signal) => IDENTITY_DOCUMENT_SIGNAL_RE.test(signal))) {
133
+ hints.push({ kind: 'identity', fieldKey: 'document_number', valueHint: 'direct' });
134
+ }
135
+ if (/\b(nationality|citizenship)\b/.test(inputName) ||
136
+ signals.some((signal) => IDENTITY_NATIONALITY_SIGNAL_RE.test(signal))) {
137
+ hints.push({ kind: 'identity', fieldKey: 'nationality', valueHint: 'direct' });
138
+ }
139
+ if (/\b(issuing_?country|country_?of_?issue|issuing_?state)\b/.test(inputName) ||
140
+ signals.some((signal) => IDENTITY_ISSUING_COUNTRY_SIGNAL_RE.test(signal))) {
141
+ hints.push({ kind: 'identity', fieldKey: 'issuing_country', valueHint: 'direct' });
142
+ }
143
+ if (comparableValueType === 'date' &&
144
+ (/\b(issue(?:_?date)?)\b/.test(inputName) ||
145
+ signals.some((signal) => IDENTITY_ISSUE_DATE_SIGNAL_RE.test(signal)))) {
146
+ hints.push({ kind: 'identity', fieldKey: 'issue_date', valueHint: 'direct' });
147
+ }
148
+ if (comparableValueType === 'date' &&
149
+ (/\b(expiry|expiration)(?:_?date)?\b/.test(inputName) ||
150
+ signals.some((signal) => IDENTITY_EXPIRY_DATE_SIGNAL_RE.test(signal)))) {
151
+ hints.push({ kind: 'identity', fieldKey: 'expiry_date', valueHint: 'direct' });
152
+ }
153
+ return uniqueMeaningHints(hints);
154
+ }
@@ -0,0 +1,15 @@
1
+ import type { Page } from 'playwright-core';
2
+ import type { BrowserSessionState } from '../browser-session-state.js';
3
+ import type { TargetDescriptor } from '../runtime-state.js';
4
+ import type { FillableFormFieldBinding, StoredSecretFieldPolicies } from './types.js';
5
+ export declare function resolveAssistedProtectedFieldValues(params: {
6
+ session?: BrowserSessionState;
7
+ page: Page;
8
+ bindings: ReadonlyArray<{
9
+ binding: FillableFormFieldBinding;
10
+ target: TargetDescriptor | null;
11
+ }>;
12
+ protectedValues: Record<string, string>;
13
+ fieldPolicies?: StoredSecretFieldPolicies;
14
+ }): Promise<Map<string, string>>;
15
+ //# sourceMappingURL=protected-field-values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protected-field-values.d.ts","sourceRoot":"","sources":["../../src/secrets/protected-field-values.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAK5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAK5D,OAAO,KAAK,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAyDtF,wBAAsB,mCAAmC,CAAC,MAAM,EAAE;IAChE,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,aAAa,CAAC;QACtB,OAAO,EAAE,wBAAwB,CAAC;QAClC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;KACjC,CAAC,CAAC;IACH,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,aAAa,CAAC,EAAE,yBAAyB,CAAC;CAC3C,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA2G/B"}
@@ -0,0 +1,131 @@
1
+ import { z } from 'zod';
2
+ import { AgentbrowseAssistiveRuntimeMissingError, tryCreateAgentbrowseAssistiveLlmClient, } from '../assistive-runtime.js';
3
+ import { recordLlmUsage, recordPayloadBudget } from '../runtime-metrics.js';
4
+ import { resolveProtectedFieldPolicy } from './field-policy.js';
5
+ import { resolveDeterministicProtectedBindingValue } from './protected-value-adapters.js';
6
+ import { protectedBindingKey, protectedBindingValueHintSchema } from './protected-bindings.js';
7
+ const protectedFieldValuesSchema = z.object({
8
+ values: z
9
+ .array(z.object({
10
+ targetRef: z.string(),
11
+ fieldKey: z.string(),
12
+ valueHint: protectedBindingValueHintSchema.optional(),
13
+ value: z.string(),
14
+ confidence: z.enum(['high', 'medium', 'low']),
15
+ }))
16
+ .max(24),
17
+ });
18
+ function buildBindingSummary(binding, target) {
19
+ const parts = [
20
+ `targetRef=${JSON.stringify(binding.targetRef)}`,
21
+ `fieldKey=${JSON.stringify(binding.fieldKey)}`,
22
+ `valueHint=${JSON.stringify(binding.valueHint ?? 'direct')}`,
23
+ ];
24
+ if (target?.label)
25
+ parts.push(`label=${JSON.stringify(target.label)}`);
26
+ if (target?.kind || target?.semantics?.role) {
27
+ parts.push(`control=${JSON.stringify({
28
+ kind: target?.kind,
29
+ role: target?.semantics?.role,
30
+ })}`);
31
+ }
32
+ const ownerLabel = target?.context?.container?.label ?? target?.context?.group?.label ?? target?.displayLabel;
33
+ if (ownerLabel) {
34
+ parts.push(`owner=${JSON.stringify(ownerLabel)}`);
35
+ }
36
+ return parts.join(' | ');
37
+ }
38
+ function canUseDeterministicValueForPolicy(binding, fieldPolicies) {
39
+ const policy = resolveProtectedFieldPolicy(fieldPolicies, binding.fieldKey);
40
+ if (policy !== 'llm_assisted') {
41
+ return true;
42
+ }
43
+ return (binding.valueHint ?? 'direct') !== 'direct';
44
+ }
45
+ export async function resolveAssistedProtectedFieldValues(params) {
46
+ const assistedBindings = params.bindings.filter(({ binding }) => {
47
+ return resolveProtectedFieldPolicy(params.fieldPolicies, binding.fieldKey) === 'llm_assisted';
48
+ });
49
+ if (params.session) {
50
+ recordPayloadBudget(params.session, {
51
+ protectedBindingsSeen: params.bindings.length,
52
+ });
53
+ }
54
+ if (assistedBindings.length === 0) {
55
+ return new Map();
56
+ }
57
+ const resolvedValues = new Map();
58
+ const unresolvedBindings = assistedBindings.filter(({ binding, target }) => {
59
+ const deterministicValue = resolveDeterministicProtectedBindingValue(binding, params.protectedValues, target ?? undefined);
60
+ if (typeof deterministicValue !== 'string' ||
61
+ deterministicValue.trim().length === 0 ||
62
+ !canUseDeterministicValueForPolicy(binding, params.fieldPolicies)) {
63
+ return true;
64
+ }
65
+ resolvedValues.set(protectedBindingKey(binding), deterministicValue.trim());
66
+ return false;
67
+ });
68
+ if (params.session) {
69
+ recordPayloadBudget(params.session, {
70
+ protectedBindingsSent: unresolvedBindings.length,
71
+ });
72
+ }
73
+ if (unresolvedBindings.length === 0) {
74
+ return resolvedValues;
75
+ }
76
+ const client = tryCreateAgentbrowseAssistiveLlmClient({ session: params.session });
77
+ if (!client) {
78
+ throw new AgentbrowseAssistiveRuntimeMissingError('protected field value resolution');
79
+ }
80
+ const pageLocale = await params.page
81
+ .evaluate(() => document.documentElement.lang || document.body?.lang || '')
82
+ .catch(() => '');
83
+ const prompt = [
84
+ 'You are resolving UI-ready values for already matched protected fields.',
85
+ 'Do not invent new bindings. Use only the provided targetRef values.',
86
+ 'Return one resolved value per binding.',
87
+ 'Use page language, target labels, and field hints to adapt the stored value to the visible UI representation.',
88
+ 'Examples:',
89
+ '- full_name + valueHint=full_name.given -> return only the given/first-name part',
90
+ '- full_name + valueHint=full_name.family -> return only the family/last-name part',
91
+ '- nationality or issuing_country may require a localized UI value such as Россия for RU',
92
+ 'If unsure, return confidence=low for that binding.',
93
+ '',
94
+ `pageLocale=${JSON.stringify(pageLocale)}`,
95
+ 'Bindings:',
96
+ ...unresolvedBindings.map(({ binding, target }) => {
97
+ const storedValue = params.protectedValues[binding.fieldKey] ?? '';
98
+ return `${buildBindingSummary(binding, target)} | storedValue=${JSON.stringify(storedValue)}`;
99
+ }),
100
+ ].join('\n');
101
+ const result = await client.createChatCompletion({
102
+ logger: () => { },
103
+ options: {
104
+ messages: [{ role: 'user', content: prompt }],
105
+ response_model: {
106
+ name: 'ProtectedFieldValues',
107
+ schema: protectedFieldValuesSchema,
108
+ },
109
+ },
110
+ });
111
+ if (params.session) {
112
+ recordLlmUsage(params.session, {
113
+ purpose: 'browse.protected_fill.resolve',
114
+ usage: result.usage,
115
+ inputChars: prompt.length,
116
+ });
117
+ }
118
+ const allowedKeys = new Set(unresolvedBindings.map(({ binding }) => protectedBindingKey(binding)));
119
+ for (const entry of result.data.values) {
120
+ const key = protectedBindingKey(entry);
121
+ if (!allowedKeys.has(key) || entry.confidence === 'low') {
122
+ continue;
123
+ }
124
+ const value = entry.value.trim();
125
+ if (!value) {
126
+ continue;
127
+ }
128
+ resolvedValues.set(key, value);
129
+ }
130
+ return resolvedValues;
131
+ }
@@ -0,0 +1,47 @@
1
+ import type { Page } from 'playwright-core';
2
+ import type { BrowserSessionState } from '../browser-session-state.js';
3
+ import { type TargetDescriptor } from '../runtime-state.js';
4
+ import type { PersistedFillableForm, StoredSecretFieldPolicies, StoredSecretFieldKey } from './types.js';
5
+ type ProtectedFillAction = 'fill' | 'select' | 'type';
6
+ export interface ProtectedFilledField {
7
+ fieldKey: StoredSecretFieldKey;
8
+ targetRef: string;
9
+ }
10
+ export interface ProtectedFieldError extends ProtectedFilledField {
11
+ reason: 'client_validation_rejected' | 'value_not_applied';
12
+ validationTextRedacted?: true;
13
+ }
14
+ type ProtectedBindingStaleReason = 'target_missing' | 'target_not_live' | 'page_signature_mismatch' | 'dom_signature_mismatch' | 'locator_resolution_failed' | 'target_blocked';
15
+ export type ProtectedFillExecutionResult = {
16
+ kind: 'success';
17
+ filledFields: ProtectedFilledField[];
18
+ } | {
19
+ kind: 'binding_stale';
20
+ targetRef: string;
21
+ fieldKeys: StoredSecretFieldKey[];
22
+ reason: ProtectedBindingStaleReason;
23
+ attempts: string[];
24
+ } | {
25
+ kind: 'validation_failed';
26
+ filledFields: ProtectedFilledField[];
27
+ fieldErrors: ProtectedFieldError[];
28
+ } | {
29
+ kind: 'unexpected_error';
30
+ reason: 'missing_protected_value' | 'unsupported_protected_field_group' | 'deterministic_only_resolution_failed' | 'assisted_value_resolution_failed' | 'action_failed';
31
+ };
32
+ declare function actionForTarget(target: TargetDescriptor): ProtectedFillAction;
33
+ declare function formatCardExpiry(month: string, year: string): string;
34
+ export declare function executeProtectedFill(params: {
35
+ session: BrowserSessionState;
36
+ page: Page;
37
+ fillableForm: PersistedFillableForm;
38
+ protectedValues: Record<string, string>;
39
+ fieldPolicies?: StoredSecretFieldPolicies;
40
+ }): Promise<ProtectedFillExecutionResult>;
41
+ export declare const __testProtectedFill: {
42
+ actionForTarget: typeof actionForTarget;
43
+ formatCardExpiry: typeof formatCardExpiry;
44
+ resolveBindingValue: (fieldKeys: ReadonlyArray<StoredSecretFieldKey>, protectedValues: Record<string, string>, target?: TargetDescriptor) => string;
45
+ };
46
+ export {};
47
+ //# sourceMappingURL=protected-fill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protected-fill.d.ts","sourceRoot":"","sources":["../../src/secrets/protected-fill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAyB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAiBnF,OAAO,KAAK,EAEV,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAGpB,KAAK,mBAAmB,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEtD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,MAAM,EAAE,4BAA4B,GAAG,mBAAmB,CAAC;IAC3D,sBAAsB,CAAC,EAAE,IAAI,CAAC;CAC/B;AAED,KAAK,2BAA2B,GAC5B,gBAAgB,GAChB,iBAAiB,GACjB,yBAAyB,GACzB,wBAAwB,GACxB,2BAA2B,GAC3B,gBAAgB,CAAC;AAarB,MAAM,MAAM,4BAA4B,GACpC;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,YAAY,EAAE,oBAAoB,EAAE,CAAC;CACtC,GACD;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,oBAAoB,EAAE,CAAC;IAClC,MAAM,EAAE,2BAA2B,CAAC;IACpC,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,GACD;IACE,IAAI,EAAE,mBAAmB,CAAC;IAC1B,YAAY,EAAE,oBAAoB,EAAE,CAAC;IACrC,WAAW,EAAE,mBAAmB,EAAE,CAAC;CACpC,GACD;IACE,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EACF,yBAAyB,GACzB,mCAAmC,GACnC,sCAAsC,GACtC,kCAAkC,GAClC,eAAe,CAAC;CACrB,CAAC;AAEN,iBAAS,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,mBAAmB,CActE;AAED,iBAAS,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAK7D;AAsTD,wBAAsB,oBAAoB,CAAC,MAAM,EAAE;IACjD,OAAO,EAAE,mBAAmB,CAAC;IAC7B,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,qBAAqB,CAAC;IACpC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,aAAa,CAAC,EAAE,yBAAyB,CAAC;CAC3C,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAgNxC;AAED,eAAO,MAAM,mBAAmB;;;qCAIjB,aAAa,CAAC,oBAAoB,CAAC,mBAC7B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAC9B,gBAAgB;CAuB5B,CAAC"}