@burdenoff/ui-engine 2026.1127.5 → 2026.1129.1

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 (57) hide show
  1. package/README.md +42 -4
  2. package/dist/analyze/messages.d.ts +7 -0
  3. package/dist/analyze/rules/heal-consequential.d.ts +2 -0
  4. package/dist/analyze/rules/popup-handler-loop.d.ts +2 -0
  5. package/dist/analyze/types.d.ts +24 -1
  6. package/dist/analyze.js +1 -1
  7. package/dist/dom-runtime.iife.js +1 -1
  8. package/dist/dom-runtime.js +2 -2
  9. package/dist/drivers.js +9 -7
  10. package/dist/heal/answer.d.ts +26 -0
  11. package/dist/heal/consequence.d.ts +74 -0
  12. package/dist/heal/index.d.ts +19 -0
  13. package/dist/heal/modes.d.ts +25 -0
  14. package/dist/heal/popup-limits.d.ts +11 -0
  15. package/dist/heal/popup.d.ts +48 -0
  16. package/dist/heal/question.d.ts +41 -0
  17. package/dist/heal/target-from-node.d.ts +9 -0
  18. package/dist/heal/types.d.ts +134 -0
  19. package/dist/heal/verify-rules.d.ts +19 -0
  20. package/dist/heal/verify.d.ts +52 -0
  21. package/dist/heal.d.ts +2 -0
  22. package/dist/heal.js +106 -0
  23. package/dist/index-20bbwwc9.js +37 -0
  24. package/dist/{index-xner4tgb.js → index-2g060ryg.js} +2 -2
  25. package/dist/index-6h7ah1dw.js +328 -0
  26. package/dist/{index-8w0f6rsz.js → index-6kva2gvd.js} +3 -3
  27. package/dist/{index-ct2xctrq.js → index-70vm0qz8.js} +2 -2
  28. package/dist/{index-21hvbvx1.js → index-8w31tpfq.js} +21 -8
  29. package/dist/{index-r2a9rftv.js → index-eff47v1g.js} +424 -17
  30. package/dist/{index-9s5nphx0.js → index-hw5npwsv.js} +1 -37
  31. package/dist/{index-ycs2bz1a.js → index-mhv6a02p.js} +11 -166
  32. package/dist/index-p5823rpv.js +0 -0
  33. package/dist/{index-5k26keah.js → index-qg9yfr7r.js} +16 -67
  34. package/dist/{index-c88tvyj1.js → index-qmv3ar39.js} +1 -1
  35. package/dist/index-t55wvhvh.js +229 -0
  36. package/dist/{index-77pcz6n3.js → index-vnv9tp11.js} +4 -2
  37. package/dist/index-w9jc25y9.js +306 -0
  38. package/dist/{index-s7qdecev.js → index-xdtanv9b.js} +358 -4
  39. package/dist/{index-vg8r40y7.js → index-yc0jgph6.js} +7 -0
  40. package/dist/index-zhbwhdya.js +407 -0
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.js +125 -23
  43. package/dist/interpret/driver.d.ts +14 -0
  44. package/dist/interpret/errors.d.ts +11 -2
  45. package/dist/interpret/events.d.ts +4 -0
  46. package/dist/interpret/run.d.ts +33 -0
  47. package/dist/interpret.js +5 -4
  48. package/dist/script.js +10 -8
  49. package/dist/target/index.d.ts +2 -0
  50. package/dist/target/roles.d.ts +11 -0
  51. package/dist/target/snapshot-mask.d.ts +49 -0
  52. package/dist/target/snapshot-tree.d.ts +65 -0
  53. package/dist/target/snapshot-url.d.ts +6 -0
  54. package/dist/target/snapshot.d.ts +1 -6
  55. package/dist/target.js +55 -13
  56. package/dist/testing.js +2 -2
  57. package/package.json +7 -3
@@ -9,6 +9,200 @@ import {
9
9
  visitExpression2
10
10
  } from "./index-g7724awk.js";
11
11
 
12
+ // src/heal/consequence.ts
13
+ var MAX_HEAL_KEYWORDS2 = 50;
14
+ var MAX_HEAL_KEYWORD_LENGTH2 = 100;
15
+ var CONSEQUENCE_KEYWORDS2 = Object.freeze({
16
+ payment: [
17
+ "pay",
18
+ "pay now",
19
+ "payment",
20
+ "payments",
21
+ "checkout",
22
+ "check out",
23
+ "purchase",
24
+ "buy",
25
+ "buy now",
26
+ "place order",
27
+ "order now",
28
+ "confirm order",
29
+ "submit order",
30
+ "complete order",
31
+ "complete purchase",
32
+ "subscribe",
33
+ "donate",
34
+ "transfer",
35
+ "send money",
36
+ "wire",
37
+ "charge",
38
+ "billing",
39
+ "top up",
40
+ "add funds",
41
+ "withdraw",
42
+ "refund",
43
+ "invoice payment"
44
+ ],
45
+ delete: [
46
+ "delete",
47
+ "remove",
48
+ "erase",
49
+ "destroy",
50
+ "discard",
51
+ "trash",
52
+ "purge",
53
+ "wipe",
54
+ "deactivate",
55
+ "terminate",
56
+ "close account",
57
+ "cancel subscription",
58
+ "cancel account",
59
+ "cancel order",
60
+ "unsubscribe",
61
+ "clear all",
62
+ "permanently"
63
+ ],
64
+ send_external: [
65
+ "send",
66
+ "submit",
67
+ "publish",
68
+ "post",
69
+ "share",
70
+ "email",
71
+ "reply",
72
+ "forward",
73
+ "invite",
74
+ "broadcast",
75
+ "notify",
76
+ "message",
77
+ "tweet",
78
+ "upload",
79
+ "file return"
80
+ ],
81
+ security: [
82
+ "password",
83
+ "change password",
84
+ "reset password",
85
+ "two factor",
86
+ "2fa",
87
+ "mfa",
88
+ "security",
89
+ "permission",
90
+ "permissions",
91
+ "grant",
92
+ "revoke",
93
+ "api key",
94
+ "access token",
95
+ "authorize",
96
+ "authorise",
97
+ "allow access",
98
+ "make admin",
99
+ "admin",
100
+ "sign out everywhere",
101
+ "log out everywhere"
102
+ ]
103
+ });
104
+ var ORDER = ["payment", "delete", "security", "send_external"];
105
+ var ACTING_ACTIONS = new Set(["click", "doubleClick", "check", "select", "pressKey"]);
106
+ function keywordWords2(text) {
107
+ return text.replace(/([a-z])([A-Z])/g, "$1 $2").normalize("NFKC").toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);
108
+ }
109
+ function containsPhrase(words, phrase) {
110
+ if (phrase.length === 0 || phrase.length > words.length)
111
+ return false;
112
+ for (let start = 0;start + phrase.length <= words.length; start += 1) {
113
+ let all = true;
114
+ for (let offset = 0;offset < phrase.length; offset += 1) {
115
+ if (words[start + offset] !== phrase[offset]) {
116
+ all = false;
117
+ break;
118
+ }
119
+ }
120
+ if (all)
121
+ return true;
122
+ }
123
+ return false;
124
+ }
125
+ var BUILT_IN = ORDER.map((consequence) => [consequence, CONSEQUENCE_KEYWORDS2[consequence].map(keywordWords2)]);
126
+ function builtInClass(words) {
127
+ for (const [consequence, phrases] of BUILT_IN) {
128
+ if (phrases.some((phrase) => containsPhrase(words, phrase)))
129
+ return consequence;
130
+ }
131
+ return null;
132
+ }
133
+ function usableKeywords2(keywords) {
134
+ const usable = [];
135
+ for (const keyword of (keywords ?? []).slice(0, MAX_HEAL_KEYWORDS2)) {
136
+ if (typeof keyword !== "string")
137
+ continue;
138
+ const trimmed = keyword.trim();
139
+ if (trimmed.length === 0 || trimmed.length > MAX_HEAL_KEYWORD_LENGTH2)
140
+ continue;
141
+ usable.push(trimmed);
142
+ }
143
+ return usable;
144
+ }
145
+ function isActingStep(step) {
146
+ return ACTING_ACTIONS.has(step.action) || step.action === "type" && step.pressEnter === true;
147
+ }
148
+ function isSubmitControl(element) {
149
+ const tag = element.tag?.toLowerCase();
150
+ const type = element.type?.toLowerCase();
151
+ if (tag === "button")
152
+ return type === undefined || type === "" || type === "submit";
153
+ return tag === "input" && (type === "submit" || type === "image");
154
+ }
155
+ function classifyConsequence2(element, step, extraKeywords) {
156
+ if (!isActingStep(step))
157
+ return { consequence: null, keyword: null };
158
+ const own = [element.name ?? "", element.href ?? "", ...element.hints ?? []].flatMap(keywordWords2);
159
+ const formWords = keywordWords2(element.formWords ?? "");
160
+ const submits = isSubmitControl(element) || step.action === "type" || step.action === "pressKey";
161
+ const words = submits ? [...own, ...formWords] : own;
162
+ const consequence = builtInClass(words);
163
+ let keyword = null;
164
+ for (const phrase of usableKeywords2(extraKeywords)) {
165
+ if (containsPhrase(words, keywordWords2(phrase))) {
166
+ keyword = phrase;
167
+ break;
168
+ }
169
+ }
170
+ return { consequence, keyword };
171
+ }
172
+ function elementInfoFromTarget2(target, elementName) {
173
+ const names = elementName ? [elementName] : [];
174
+ const hints = [];
175
+ let role;
176
+ for (const method of target.methods) {
177
+ switch (method.kind) {
178
+ case "role":
179
+ role ??= method.role;
180
+ names.push(method.name);
181
+ break;
182
+ case "fuzzy":
183
+ if (method.role)
184
+ role ??= method.role;
185
+ names.push(method.name);
186
+ break;
187
+ case "text":
188
+ names.push(method.text);
189
+ break;
190
+ case "anchor":
191
+ break;
192
+ case "testId":
193
+ hints.push(method.value);
194
+ break;
195
+ case "css":
196
+ hints.push(method.selector);
197
+ break;
198
+ case "xpath":
199
+ hints.push(method.xpath);
200
+ break;
201
+ }
202
+ }
203
+ return { ...role === undefined ? {} : { role }, name: names.join(" "), hints };
204
+ }
205
+
12
206
  // src/analyze/context.ts
13
207
  function stepNumber2(path) {
14
208
  return path.split(".").filter((part) => part !== "then" && part !== "steps").map((part) => /^\d+$/.test(part) ? String(Number(part) + 1) : part).join(".");
@@ -88,7 +282,14 @@ var UI_SCRIPT_PROBLEM_MESSAGES2 = {
88
282
  sensitiveScreenshotSettings: "The script takes a screenshot of every step, including step {{step}}, which signs in or types a secret. Take screenshots on failure only, or turn them off for that step.",
89
283
  inlineTarget: "Step {{step}} uses an inline target. Add it to the Element library so other workflows can reuse it.",
90
284
  unusedValue: "Step {{step}} stores {{name}}, but no step, output or later node reads it.",
91
- unusedVariable: "The variable {{name}} is declared, but no step reads it."
285
+ unusedVariable: "The variable {{name}} is declared, but no step reads it.",
286
+ healConsequential: "Step {{step}} acts on {{target}}, which looks like a {{consequence}} control. If healing finds a new target for it, a person must approve the change before the step runs.",
287
+ healAlwaysAskKeyword: "Step {{step}} acts on {{target}}, which matches the always-ask phrase {{keyword}}. If healing finds a new target for it, a person must approve the change before the step runs.",
288
+ popupHandlerFlow: "Pop-up handler step {{step}} is a {{action}} block. A handler is a short, straight list of steps, so it can never loop.",
289
+ popupHandlerAction: "Pop-up handler step {{step}} uses {{action}}. A handler may only click, check, press keys, hover, scroll or wait.",
290
+ popupHandlerConsequential: "Pop-up handler step {{step}} acts on {{target}}, which looks like a {{consequence}} control. A handler never acts on such a control.",
291
+ popupHandlerWait: "Pop-up handler step {{step}} waits {{milliseconds}} ms. A handler step waits at most 5,000 ms, so a pop-up never holds up a run.",
292
+ popupHandlerNoAction: "The pop-up handler has no step that clicks, checks or presses a key, so it cannot clear the pop-up."
92
293
  };
93
294
  function problemMessageKey2(name) {
94
295
  return `${UI_SCRIPT_PROBLEM_KEY_PREFIX2}${name}`;
@@ -140,6 +341,95 @@ var hardwareInputRule = {
140
341
  }
141
342
  };
142
343
 
344
+ // src/heal/verify-rules.ts
345
+ var HEALABLE_ACTIONS2 = new Set([
346
+ "click",
347
+ "doubleClick",
348
+ "hover",
349
+ "type",
350
+ "clear",
351
+ "check",
352
+ "select",
353
+ "getText",
354
+ "getValue",
355
+ "getAttribute",
356
+ "waitFor"
357
+ ]);
358
+ var CLICKABLE = [
359
+ "button",
360
+ "link",
361
+ "checkbox",
362
+ "menuitem",
363
+ "menuitemcheckbox",
364
+ "menuitemradio",
365
+ "tab",
366
+ "option",
367
+ "radio",
368
+ "switch",
369
+ "treeitem",
370
+ "combobox",
371
+ "gridcell"
372
+ ];
373
+ var TYPEABLE = ["textbox", "searchbox", "combobox", "spinbutton"];
374
+ var ROLES_BY_ACTION = {
375
+ click: new Set(CLICKABLE),
376
+ doubleClick: new Set(CLICKABLE),
377
+ hover: new Set([...CLICKABLE, "img"]),
378
+ type: new Set(TYPEABLE),
379
+ clear: new Set(TYPEABLE),
380
+ check: new Set(["checkbox", "radio", "switch", "menuitemcheckbox", "menuitemradio"]),
381
+ select: new Set(["combobox", "listbox"])
382
+ };
383
+ function compatibleRoles2(action) {
384
+ return ROLES_BY_ACTION[action];
385
+ }
386
+ var VALUE_ACTIONS2 = new Set(["type", "clear", "select"]);
387
+ var ACTIONABLE_ROLES = new Set([
388
+ ...CLICKABLE,
389
+ ...TYPEABLE,
390
+ "listbox",
391
+ "slider",
392
+ "spinbutton"
393
+ ]);
394
+
395
+ // src/analyze/rules/heal-consequential.ts
396
+ var CONSEQUENCE_WORDS = {
397
+ payment: "payment",
398
+ delete: "delete",
399
+ send_external: "send-outside",
400
+ security: "security"
401
+ };
402
+ var healConsequentialRule = {
403
+ id: "healConsequential",
404
+ group: "security",
405
+ severity: "info",
406
+ description: "A step that acts on a payment, delete, send or security control, or on an always-ask phrase.",
407
+ check: (context) => {
408
+ const healing = context.options.healing;
409
+ if (!healing)
410
+ return [];
411
+ const alwaysAsk = new Set(healing.alwaysAskStepIds ?? []);
412
+ const findings = [];
413
+ for (const active of context.steps) {
414
+ const step = active.step;
415
+ if (!HEALABLE_ACTIONS2.has(step.action) || alwaysAsk.has(step.id) || !("target" in step) || !step.target)
416
+ continue;
417
+ const target = context.targetOf(step.target);
418
+ if (!target)
419
+ continue;
420
+ const name = "element" in step.target ? context.elements[step.target.element]?.name : undefined;
421
+ const verdict = classifyConsequence2(elementInfoFromTarget2(target, name), { action: step.action, ...step.action === "type" && step.pressEnter === true ? { pressEnter: true } : {} }, healing.keywords);
422
+ const vars = { target: context.describeTarget(step.target) };
423
+ if (verdict.consequence) {
424
+ findings.push(stepFinding(active, "healConsequential", { ...vars, consequence: CONSEQUENCE_WORDS[verdict.consequence] }, "target"));
425
+ } else if (verdict.keyword) {
426
+ findings.push(stepFinding(active, "healAlwaysAskKeyword", { ...vars, keyword: `"${verdict.keyword}"` }, "target"));
427
+ }
428
+ }
429
+ return findings;
430
+ }
431
+ };
432
+
143
433
  // src/analyze/rules/inline-target.ts
144
434
  var inlineTargetRule = {
145
435
  id: "inlineTarget",
@@ -243,6 +533,65 @@ var plainTextSecretRule = {
243
533
  })
244
534
  };
245
535
 
536
+ // src/heal/popup-limits.ts
537
+ var MAX_POPUP_HANDLERS_PER_STEP2 = 2;
538
+ var MAX_POPUP_HANDLERS_PER_APPLICATION2 = 50;
539
+ var MAX_POPUP_HANDLER_STEPS2 = 10;
540
+ var MAX_POPUP_URL_PATTERN2 = 500;
541
+ var POPUP_HANDLER_STEP_WAIT_MS2 = 5000;
542
+
543
+ // src/analyze/rules/popup-handler-loop.ts
544
+ var FLOW = new Set(["if", "forEach", "while", "retryScope", "call"]);
545
+ var ALLOWED = new Set(["click", "doubleClick", "hover", "check", "pressKey", "scroll", "waitFor"]);
546
+ var CLEARING = new Set(["click", "doubleClick", "check", "pressKey"]);
547
+ var CONSEQUENCE_WORDS2 = {
548
+ payment: "payment",
549
+ delete: "delete",
550
+ send_external: "send-outside",
551
+ security: "security"
552
+ };
553
+ var popupHandlerLoopRule = {
554
+ id: "popupHandlerLoop",
555
+ group: "reliability",
556
+ severity: "warning",
557
+ description: "A pop-up handler that could loop, leave the page, type, or press a consequential control.",
558
+ check: (context) => {
559
+ if (!context.options.popupHandler)
560
+ return [];
561
+ const findings = [];
562
+ let clears = false;
563
+ for (const active of context.steps) {
564
+ const step = active.step;
565
+ if (FLOW.has(step.action)) {
566
+ findings.push(stepFinding(active, "popupHandlerFlow", { action: step.action }, "action"));
567
+ continue;
568
+ }
569
+ if (!ALLOWED.has(step.action)) {
570
+ findings.push(stepFinding(active, "popupHandlerAction", { action: step.action }, "action"));
571
+ continue;
572
+ }
573
+ if (CLEARING.has(step.action))
574
+ clears = true;
575
+ const wait = step.action === "waitFor" && step.milliseconds !== undefined ? step.milliseconds : step.timeoutMs;
576
+ if (wait !== undefined && wait > POPUP_HANDLER_STEP_WAIT_MS2) {
577
+ findings.push(stepFinding(active, "popupHandlerWait", { milliseconds: wait }, "timeoutMs"));
578
+ }
579
+ if (!("target" in step) || !step.target)
580
+ continue;
581
+ const target = context.targetOf(step.target);
582
+ if (!target)
583
+ continue;
584
+ const verdict = classifyConsequence2(elementInfoFromTarget2(target), { action: step.action });
585
+ if (verdict.consequence) {
586
+ findings.push(stepFinding(active, "popupHandlerConsequential", { target: context.describeTarget(step.target), consequence: CONSEQUENCE_WORDS2[verdict.consequence] }, "target"));
587
+ }
588
+ }
589
+ if (!clears)
590
+ findings.push({ message: "popupHandlerNoAction", vars: {}, order: -1 });
591
+ return findings;
592
+ }
593
+ };
594
+
246
595
  // src/analyze/rules/secret-origin.ts
247
596
  var secretOriginRule = {
248
597
  id: "secretOrigin",
@@ -431,7 +780,9 @@ var UI_ANALYZER_RULES2 = [
431
780
  secretOriginRule,
432
781
  sensitiveScreenshotRule,
433
782
  inlineTargetRule,
434
- unusedValueRule
783
+ unusedValueRule,
784
+ healConsequentialRule,
785
+ popupHandlerLoopRule
435
786
  ];
436
787
 
437
788
  // src/analyze/types.ts
@@ -448,7 +799,9 @@ var UI_ANALYZER_RULE_IDS2 = [
448
799
  "secretOrigin",
449
800
  "sensitiveScreenshot",
450
801
  "inlineTarget",
451
- "unusedValue"
802
+ "unusedValue",
803
+ "healConsequential",
804
+ "popupHandlerLoop"
452
805
  ];
453
806
 
454
807
  // src/analyze/analyze.ts
@@ -486,4 +839,5 @@ function analyzeUiScript2(script, options = {}) {
486
839
  });
487
840
  return found.sort((a, b) => a.order - b.order || a.rank - b.rank || a.seq - b.seq).map(({ problem }) => problem);
488
841
  }
489
- export { stepNumber2, UI_SCRIPT_PROBLEM_KEY_PREFIX2, UI_SCRIPT_PROBLEM_MESSAGES2, problemMessageKey2, problemMessage2, UI_ANALYZER_RULES2, UI_PROBLEM_SEVERITIES2, UI_ANALYZER_RULE_GROUPS2, UI_ANALYZER_RULE_IDS2, UI_ANALYZER_DEFAULT_SEVERITY2, analyzeUiScript2 };
842
+
843
+ export { MAX_HEAL_KEYWORDS2, MAX_HEAL_KEYWORD_LENGTH2, CONSEQUENCE_KEYWORDS2, keywordWords2, usableKeywords2, isActingStep, classifyConsequence2, elementInfoFromTarget2, stepNumber2, UI_SCRIPT_PROBLEM_KEY_PREFIX2, UI_SCRIPT_PROBLEM_MESSAGES2, problemMessageKey2, problemMessage2, HEALABLE_ACTIONS2, compatibleRoles2, VALUE_ACTIONS2, ACTIONABLE_ROLES, MAX_POPUP_HANDLERS_PER_STEP2, MAX_POPUP_HANDLERS_PER_APPLICATION2, MAX_POPUP_HANDLER_STEPS2, MAX_POPUP_URL_PATTERN2, POPUP_HANDLER_STEP_WAIT_MS2, UI_ANALYZER_RULES2, UI_PROBLEM_SEVERITIES2, UI_ANALYZER_RULE_GROUPS2, UI_ANALYZER_RULE_IDS2, UI_ANALYZER_DEFAULT_SEVERITY2, analyzeUiScript2 };
@@ -137,6 +137,11 @@ var UI_ERROR_CODES2 = {
137
137
  family: "CANCELLED",
138
138
  preflight: false,
139
139
  meaning: "A person sent STOP to a paused TEST run; the clean-up steps ran"
140
+ },
141
+ HEAL_APPROVAL_REQUIRED: {
142
+ family: "DEPENDENCY",
143
+ preflight: false,
144
+ meaning: "Healing found and checked a new target, but a person must approve it first (heal with approval, an always-ask step or keyword, or a consequential control); the run stops with the candidate in error.heal and the desk parks it for approval. Never retried in the script"
140
145
  }
141
146
  };
142
147
  var UI_ERROR_CODE_LIST2 = Object.keys(UI_ERROR_CODES2);
@@ -147,6 +152,8 @@ function errorFamilyOf2(code) {
147
152
  return UI_ERROR_CODES2[code].family;
148
153
  }
149
154
  function isRetryableInScript2(code) {
155
+ if (code === "HEAL_APPROVAL_REQUIRED")
156
+ return false;
150
157
  const family = errorFamilyOf2(code);
151
158
  return family !== "VALIDATION" && family !== "CANCELLED" && family !== "AUTHORIZATION";
152
159
  }