@mercuryo-ai/agentbrowse 0.2.57 → 0.2.60
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.
- package/README.md +50 -56
- package/dist/command-name.js +1 -1
- package/dist/commands/act.d.ts.map +1 -1
- package/dist/commands/act.js +13 -5
- package/dist/commands/action-executor-helpers.d.ts.map +1 -1
- package/dist/commands/action-executor-helpers.js +10 -8
- package/dist/commands/click-activation-policy.d.ts.map +1 -1
- package/dist/commands/click-activation-policy.js +6 -2
- package/dist/commands/launch.d.ts +0 -1
- package/dist/commands/launch.d.ts.map +1 -1
- package/dist/commands/launch.js +2 -8
- package/dist/commands/observe-inventory.d.ts +5 -1
- package/dist/commands/observe-inventory.d.ts.map +1 -1
- package/dist/commands/observe-inventory.js +316 -5
- package/dist/commands/observe-persistence.d.ts.map +1 -1
- package/dist/commands/observe-persistence.js +2 -0
- package/dist/commands/observe-projection.d.ts +3 -2
- package/dist/commands/observe-projection.d.ts.map +1 -1
- package/dist/commands/observe-projection.js +1 -0
- package/dist/commands/observe-protected.d.ts +3 -1
- package/dist/commands/observe-protected.d.ts.map +1 -1
- package/dist/commands/observe-protected.js +23 -1
- package/dist/commands/observe-semantics.d.ts.map +1 -1
- package/dist/commands/observe-semantics.js +70 -0
- package/dist/commands/observe.d.ts +1 -0
- package/dist/commands/observe.d.ts.map +1 -1
- package/dist/commands/observe.js +4 -2
- package/dist/control-semantics.d.ts.map +1 -1
- package/dist/control-semantics.js +5 -0
- package/dist/date-value-normalization.d.ts +16 -0
- package/dist/date-value-normalization.d.ts.map +1 -0
- package/dist/date-value-normalization.js +117 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -24
- package/dist/library.d.ts +3 -0
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +2 -0
- package/dist/protected-fill.d.ts +3 -2
- package/dist/protected-fill.d.ts.map +1 -1
- package/dist/runtime-protected-state.d.ts.map +1 -1
- package/dist/runtime-protected-state.js +8 -1
- package/dist/runtime-state.d.ts +11 -0
- package/dist/runtime-state.d.ts.map +1 -1
- package/dist/secrets/form-matcher.d.ts +1 -2
- package/dist/secrets/form-matcher.d.ts.map +1 -1
- package/dist/secrets/form-matcher.js +125 -119
- package/dist/secrets/matching-helpers.d.ts +13 -0
- package/dist/secrets/matching-helpers.d.ts.map +1 -0
- package/dist/secrets/matching-helpers.js +147 -0
- package/dist/secrets/observed-field-resolution.d.ts +43 -0
- package/dist/secrets/observed-field-resolution.d.ts.map +1 -0
- package/dist/secrets/observed-field-resolution.js +223 -0
- package/dist/secrets/protected-field-semantics.d.ts.map +1 -1
- package/dist/secrets/protected-field-semantics.js +3 -2
- package/dist/secrets/protected-fill.d.ts +3 -1
- package/dist/secrets/protected-fill.d.ts.map +1 -1
- package/dist/secrets/protected-fill.js +31 -0
- package/dist/secrets/protected-value-adapters.d.ts.map +1 -1
- package/dist/secrets/protected-value-adapters.js +14 -22
- package/dist/secrets/types.d.ts +3 -0
- package/dist/secrets/types.d.ts.map +1 -1
- package/docs/README.md +15 -2
- package/docs/api-reference.md +13 -3
- package/docs/assistive-runtime.md +63 -7
- package/docs/configuration.md +16 -8
- package/docs/getting-started.md +17 -8
- package/docs/integration-checklist.md +8 -7
- package/docs/protected-fill.md +40 -7
- package/docs/testing.md +4 -3
- package/docs/troubleshooting.md +88 -34
- package/examples/README.md +9 -2
- package/package.json +8 -3
|
@@ -204,6 +204,10 @@ function applyInheritedDomTargetMetadata(target, options) {
|
|
|
204
204
|
framePath: normalizedFramePath,
|
|
205
205
|
frameUrl: normalizedFrameUrl,
|
|
206
206
|
pageSignature: normalizedPageSignature,
|
|
207
|
+
pageFormSelector: target.pageFormSelector ??
|
|
208
|
+
(typeof options?.pageFormSelector === 'string' && options.pageFormSelector.trim().length > 0
|
|
209
|
+
? options.pageFormSelector
|
|
210
|
+
: undefined),
|
|
207
211
|
};
|
|
208
212
|
}
|
|
209
213
|
function enrichObservedTargetSemantics(target) {
|
|
@@ -405,11 +409,13 @@ async function collectDomTargetsFromDocument(context, options) {
|
|
|
405
409
|
const inheritedFramePath = JSON.stringify(options?.framePath ?? []);
|
|
406
410
|
const inheritedFrameUrl = JSON.stringify(options?.frameUrl ?? '');
|
|
407
411
|
const inheritedPageSignature = JSON.stringify(options?.pageSignature ?? '');
|
|
412
|
+
const inheritedPageFormSelector = JSON.stringify(options?.pageFormSelector ?? '');
|
|
408
413
|
const observedTargets = await context.evaluate(String.raw `(() => {
|
|
409
414
|
const includeActivationAffordances = ${includeActivationAffordances ? 'true' : 'false'};
|
|
410
415
|
const inheritedFramePath = ${inheritedFramePath};
|
|
411
416
|
const inheritedFrameUrl = ${inheritedFrameUrl};
|
|
412
417
|
const inheritedPageSignature = ${inheritedPageSignature};
|
|
418
|
+
const inheritedPageFormSelector = ${inheritedPageFormSelector};
|
|
413
419
|
const domSignatureOf = (element) => {
|
|
414
420
|
${LOCATOR_DOM_SIGNATURE_SCRIPT}
|
|
415
421
|
};
|
|
@@ -892,6 +898,152 @@ async function collectDomTargetsFromDocument(context, options) {
|
|
|
892
898
|
|
|
893
899
|
const looseFieldLabelOf = (element) => observedLooseFieldLabelOf(element);
|
|
894
900
|
|
|
901
|
+
const controlledPopupSurfaceOf = (element) => {
|
|
902
|
+
const controlledId = element.getAttribute('aria-controls')?.trim();
|
|
903
|
+
if (!controlledId) {
|
|
904
|
+
return undefined;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
const controlled = document.getElementById(controlledId);
|
|
908
|
+
return isHTMLElementNode(controlled) ? controlled : undefined;
|
|
909
|
+
};
|
|
910
|
+
|
|
911
|
+
const normalizeSelectionLabel = (value, explicitLabel) => {
|
|
912
|
+
const normalized = normalizeDescriptorText(value || '');
|
|
913
|
+
if (!isMeaningfulLabel(normalized)) {
|
|
914
|
+
return undefined;
|
|
915
|
+
}
|
|
916
|
+
if (normalized.length > 64) {
|
|
917
|
+
return undefined;
|
|
918
|
+
}
|
|
919
|
+
if (observedLooseActionTextRe.test(normalized)) {
|
|
920
|
+
return undefined;
|
|
921
|
+
}
|
|
922
|
+
if (explicitLabel && normalized.toLowerCase() === explicitLabel.toLowerCase()) {
|
|
923
|
+
return undefined;
|
|
924
|
+
}
|
|
925
|
+
return normalized;
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
const inlineSelectionLabelsOf = (element) => {
|
|
929
|
+
const explicitLabel = normalizeDescriptorText(explicitLabelOf(element) || '');
|
|
930
|
+
const labels = [];
|
|
931
|
+
const seen = new Set();
|
|
932
|
+
const anchors = [
|
|
933
|
+
composedParentElement(element),
|
|
934
|
+
composedParentElement(composedParentElement(element)),
|
|
935
|
+
].filter(Boolean);
|
|
936
|
+
|
|
937
|
+
const pushLabel = (value) => {
|
|
938
|
+
const normalized = normalizeSelectionLabel(value, explicitLabel);
|
|
939
|
+
if (!normalized) {
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
const key = normalized.toLowerCase();
|
|
943
|
+
if (seen.has(key)) {
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
946
|
+
seen.add(key);
|
|
947
|
+
labels.push(normalized);
|
|
948
|
+
};
|
|
949
|
+
|
|
950
|
+
const collectCandidateLabels = (candidate, depth = 0) => {
|
|
951
|
+
if (!isHTMLElementNode(candidate)) {
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
if (candidate === element || candidate.contains(element) || element.contains(candidate)) {
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
if (candidate.getAttribute('aria-hidden')?.trim() === 'true') {
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
if (observedMatchesSelector(candidate, observedLabelLikeSelector)) {
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
const tag = candidate.tagName.toLowerCase();
|
|
965
|
+
if (['input', 'textarea', 'select', 'button', 'a', 'svg', 'img'].includes(tag)) {
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
const visibleChildren = Array.from(candidate.children).filter(
|
|
970
|
+
(child) => isHTMLElementNode(child) && isVisible(child)
|
|
971
|
+
);
|
|
972
|
+
const candidateStyle = window.getComputedStyle(candidate);
|
|
973
|
+
const visibleOrTransparentGrouping =
|
|
974
|
+
isVisible(candidate) ||
|
|
975
|
+
(candidateStyle.display === 'contents' && visibleChildren.length > 0);
|
|
976
|
+
if (!visibleOrTransparentGrouping) {
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
if (depth === 0 && visibleChildren.length > 1) {
|
|
980
|
+
for (const child of visibleChildren.slice(0, 6)) {
|
|
981
|
+
collectCandidateLabels(child, depth + 1);
|
|
982
|
+
}
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
pushLabel(observedTextOf(candidate, element));
|
|
987
|
+
};
|
|
988
|
+
|
|
989
|
+
for (const anchor of anchors) {
|
|
990
|
+
if (!isHTMLElementNode(anchor)) {
|
|
991
|
+
continue;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
for (const child of Array.from(anchor.children).slice(0, 8)) {
|
|
995
|
+
if (!isHTMLElementNode(child)) {
|
|
996
|
+
continue;
|
|
997
|
+
}
|
|
998
|
+
if (!observedPrecedesElementInDocument(child, element)) {
|
|
999
|
+
continue;
|
|
1000
|
+
}
|
|
1001
|
+
collectCandidateLabels(child);
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
if (labels.length > 0) {
|
|
1005
|
+
break;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
return labels;
|
|
1010
|
+
};
|
|
1011
|
+
|
|
1012
|
+
const selectionOf = (element) => {
|
|
1013
|
+
if (!isHTMLElementNode(element)) {
|
|
1014
|
+
return undefined;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
if (isHTMLSelectNode(element)) {
|
|
1018
|
+
const items = Array.from(element.selectedOptions)
|
|
1019
|
+
.map((option) => normalizeDescriptorText(option.textContent || option.value || ''))
|
|
1020
|
+
.filter((label) => isMeaningfulLabel(label))
|
|
1021
|
+
.map((label) => ({ label, selected: true }));
|
|
1022
|
+
if (items.length === 0) {
|
|
1023
|
+
return undefined;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
return {
|
|
1027
|
+
mode: element.multiple ? 'multiple' : 'single',
|
|
1028
|
+
items,
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
const inlineLabels = inlineSelectionLabelsOf(element);
|
|
1033
|
+
const controlledSurface = controlledPopupSurfaceOf(element);
|
|
1034
|
+
const ariaMultiSelectable =
|
|
1035
|
+
controlledSurface?.getAttribute('aria-multiselectable')?.trim() === 'true';
|
|
1036
|
+
const mode = inlineLabels.length > 1 || ariaMultiSelectable ? 'multiple' : undefined;
|
|
1037
|
+
if (!mode) {
|
|
1038
|
+
return undefined;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
return {
|
|
1042
|
+
mode,
|
|
1043
|
+
items: inlineLabels.map((label) => ({ label, selected: true })),
|
|
1044
|
+
};
|
|
1045
|
+
};
|
|
1046
|
+
|
|
895
1047
|
const VALIDATION_TEXT_RE =
|
|
896
1048
|
/(?:required|invalid|incorrect|too\s+(?:short|long)|must|error|format|please\s+(?:enter|select|choose|fill)|невер|ошиб|обязател|заполн|введите|укажите|выберите|долж|нужно|формат|цифр|символ)/i;
|
|
897
1049
|
|
|
@@ -1210,6 +1362,103 @@ async function collectDomTargetsFromDocument(context, options) {
|
|
|
1210
1362
|
return Math.max(window.innerWidth || 0, 1) * Math.max(window.innerHeight || 0, 1);
|
|
1211
1363
|
};
|
|
1212
1364
|
|
|
1365
|
+
const compactClickableCompanionTextOf = (element) => {
|
|
1366
|
+
const anchors = [
|
|
1367
|
+
composedParentElement(element),
|
|
1368
|
+
composedParentElement(composedParentElement(element)),
|
|
1369
|
+
].filter(Boolean);
|
|
1370
|
+
|
|
1371
|
+
for (const anchor of anchors) {
|
|
1372
|
+
if (!isHTMLElementNode(anchor)) {
|
|
1373
|
+
continue;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
for (const child of Array.from(anchor.children).slice(0, 8)) {
|
|
1377
|
+
if (!isHTMLElementNode(child) || child === element) {
|
|
1378
|
+
continue;
|
|
1379
|
+
}
|
|
1380
|
+
if (child.contains(element) || element.contains(child) || !isVisible(child)) {
|
|
1381
|
+
continue;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
const tag = child.tagName.toLowerCase();
|
|
1385
|
+
if (['input', 'textarea', 'select', 'button', 'a', 'svg', 'img'].includes(tag)) {
|
|
1386
|
+
continue;
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
const candidateText = normalizeDescriptorText(textOf(child));
|
|
1390
|
+
if (
|
|
1391
|
+
candidateText &&
|
|
1392
|
+
candidateText.length <= 64 &&
|
|
1393
|
+
!observedLooseActionTextRe.test(candidateText)
|
|
1394
|
+
) {
|
|
1395
|
+
return candidateText;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
return undefined;
|
|
1401
|
+
};
|
|
1402
|
+
|
|
1403
|
+
const compactClickableItemOf = (element) => {
|
|
1404
|
+
const companionText = compactClickableCompanionTextOf(element);
|
|
1405
|
+
if (!companionText) {
|
|
1406
|
+
return undefined;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
let current = composedParentElement(element);
|
|
1410
|
+
let depth = 0;
|
|
1411
|
+
while (isHTMLElementNode(current) && depth < 2) {
|
|
1412
|
+
const currentText = normalizeDescriptorText(textOf(current, { container: true }));
|
|
1413
|
+
if (currentText && currentText.toLowerCase() === companionText.toLowerCase()) {
|
|
1414
|
+
return current;
|
|
1415
|
+
}
|
|
1416
|
+
current = composedParentElement(current);
|
|
1417
|
+
depth += 1;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
return undefined;
|
|
1421
|
+
};
|
|
1422
|
+
|
|
1423
|
+
const compactAffordanceIntentRe =
|
|
1424
|
+
/\b(remove|clear|close|delete|dismiss|cancel|minus|cross|убрать|удалить|очистить|закрыть)\b/i;
|
|
1425
|
+
|
|
1426
|
+
const isCompactGenericClickableAffordance = (element) => {
|
|
1427
|
+
if (!isHTMLElementNode(element)) return false;
|
|
1428
|
+
if (element.matches?.(selector)) return false;
|
|
1429
|
+
if (hasSemanticInteractiveAncestor(element)) return false;
|
|
1430
|
+
|
|
1431
|
+
const tag = element.tagName.toLowerCase();
|
|
1432
|
+
const associatedChoiceControl = associatedChoiceControlOf(element);
|
|
1433
|
+
if (['body', 'main', 'form'].includes(tag)) return false;
|
|
1434
|
+
if (tag === 'label' && !associatedChoiceControl) return false;
|
|
1435
|
+
|
|
1436
|
+
const style = window.getComputedStyle(element);
|
|
1437
|
+
if (style.pointerEvents === 'none') return false;
|
|
1438
|
+
|
|
1439
|
+
const explicitClick =
|
|
1440
|
+
element.hasAttribute('onclick') || typeof element.onclick === 'function';
|
|
1441
|
+
const cursorClick = style.cursor === 'pointer';
|
|
1442
|
+
if (!explicitClick && !cursorClick) return false;
|
|
1443
|
+
|
|
1444
|
+
const rect = element.getBoundingClientRect();
|
|
1445
|
+
const area = rect.width * rect.height;
|
|
1446
|
+
if (rect.width < 12 || rect.height < 12 || area < 120) return false;
|
|
1447
|
+
if (rect.width > 40 || rect.height > 40 || area > 1200) return false;
|
|
1448
|
+
|
|
1449
|
+
const intentText = normalizeDescriptorText(
|
|
1450
|
+
explicitLabelOf(element) ||
|
|
1451
|
+
element.getAttribute('title') ||
|
|
1452
|
+
element.getAttribute('aria-label') ||
|
|
1453
|
+
''
|
|
1454
|
+
);
|
|
1455
|
+
if (!intentText || !compactAffordanceIntentRe.test(intentText)) {
|
|
1456
|
+
return false;
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
return Boolean(compactClickableCompanionTextOf(element));
|
|
1460
|
+
};
|
|
1461
|
+
|
|
1213
1462
|
const isBareFocusableClickTarget = (element) => {
|
|
1214
1463
|
if (!isHTMLElementNode(element)) return false;
|
|
1215
1464
|
if (!element.matches?.(selector)) return false;
|
|
@@ -1324,7 +1573,12 @@ async function collectDomTargetsFromDocument(context, options) {
|
|
|
1324
1573
|
for (const candidate of descendants) {
|
|
1325
1574
|
if (acc.length >= limit) break;
|
|
1326
1575
|
if (!isHTMLElementNode(candidate) || seen.has(candidate)) continue;
|
|
1327
|
-
if (
|
|
1576
|
+
if (
|
|
1577
|
+
!isGenericClickableElement(candidate) &&
|
|
1578
|
+
!isCompactGenericClickableAffordance(candidate)
|
|
1579
|
+
) {
|
|
1580
|
+
continue;
|
|
1581
|
+
}
|
|
1328
1582
|
if (hasAcceptedGenericClickableAncestor(candidate, acc)) continue;
|
|
1329
1583
|
seen.add(candidate);
|
|
1330
1584
|
acc.push(candidate);
|
|
@@ -2996,6 +3250,7 @@ async function collectDomTargetsFromDocument(context, options) {
|
|
|
2996
3250
|
const visualSeatGrid = visualSeatGridMeta.get(element);
|
|
2997
3251
|
const associatedChoiceControl = associatedChoiceControlOf(element);
|
|
2998
3252
|
const genericClickable = isGenericClickableElement(element);
|
|
3253
|
+
const compactClickableAffordance = isCompactGenericClickableAffordance(element);
|
|
2999
3254
|
const bareFocusableClickTarget = isBareFocusableClickTarget(element);
|
|
3000
3255
|
const effectiveElement = element;
|
|
3001
3256
|
const domSignature = domSignatureOf(effectiveElement);
|
|
@@ -3019,7 +3274,9 @@ async function collectDomTargetsFromDocument(context, options) {
|
|
|
3019
3274
|
const container = containerOf(element);
|
|
3020
3275
|
const landmark = composedClosest(element, contextSelector);
|
|
3021
3276
|
const group = groupOf(element);
|
|
3022
|
-
const item =
|
|
3277
|
+
const item =
|
|
3278
|
+
(compactClickableAffordance ? compactClickableItemOf(element) : undefined) ||
|
|
3279
|
+
itemOf(element);
|
|
3023
3280
|
const overlaySurface = composedClosest(element, overlaySurfaceSelector);
|
|
3024
3281
|
const localSurface = localSurfaceCandidateOf(element);
|
|
3025
3282
|
const selfSurface =
|
|
@@ -3038,6 +3295,7 @@ async function collectDomTargetsFromDocument(context, options) {
|
|
|
3038
3295
|
);
|
|
3039
3296
|
const fallbackLabel = directionalFallbackLabel || directFallbackLabel;
|
|
3040
3297
|
const currentValue = popupCurrentValueOf(element);
|
|
3298
|
+
const selection = selectionOf(element);
|
|
3041
3299
|
const role = inferRole(element) || inferRole(associatedChoiceControl);
|
|
3042
3300
|
const surfaceKind = visualSeatGrid?.surfaceKind || surfaceKindOf(surface);
|
|
3043
3301
|
const fallbackSurfaceLabel =
|
|
@@ -3055,9 +3313,12 @@ async function collectDomTargetsFromDocument(context, options) {
|
|
|
3055
3313
|
fallbackLabel: visualSeatGrid?.label || fallbackLabel,
|
|
3056
3314
|
interactionHint:
|
|
3057
3315
|
visualSeatGrid?.interactionHint ||
|
|
3058
|
-
(genericClickable ||
|
|
3316
|
+
(genericClickable || compactClickableAffordance || bareFocusableClickTarget
|
|
3317
|
+
? 'click'
|
|
3318
|
+
: undefined),
|
|
3059
3319
|
role,
|
|
3060
3320
|
currentValue: currentValue || undefined,
|
|
3321
|
+
selection: selection || undefined,
|
|
3061
3322
|
text: textOf(element),
|
|
3062
3323
|
placeholder: element.getAttribute('placeholder')?.trim() || undefined,
|
|
3063
3324
|
inputName:
|
|
@@ -3095,6 +3356,7 @@ async function collectDomTargetsFromDocument(context, options) {
|
|
|
3095
3356
|
controlsSurfaceSelector:
|
|
3096
3357
|
selectorFromRelation(element, 'aria-controls') || selectorFromRelation(element, 'aria-owns'),
|
|
3097
3358
|
formSelector: form ? buildSelector(form) : undefined,
|
|
3359
|
+
pageFormSelector: form ? buildSelector(form) : inheritedPageFormSelector || undefined,
|
|
3098
3360
|
descendantInteractiveCount: element.querySelectorAll(selector).length,
|
|
3099
3361
|
descendantEditableCount: element.querySelectorAll(
|
|
3100
3362
|
'input:not([type="hidden"]), textarea, select, [contenteditable="true"]'
|
|
@@ -3260,6 +3522,7 @@ async function collectDomTargetsFromDocument(context, options) {
|
|
|
3260
3522
|
framePath: options?.framePath,
|
|
3261
3523
|
frameUrl: options?.frameUrl,
|
|
3262
3524
|
pageSignature: options?.pageSignature,
|
|
3525
|
+
pageFormSelector: options?.pageFormSelector,
|
|
3263
3526
|
})));
|
|
3264
3527
|
}
|
|
3265
3528
|
const FRAME_HOST_DESCRIPTOR_SCRIPT = String.raw `
|
|
@@ -3350,6 +3613,53 @@ const FRAME_HOST_DESCRIPTOR_SCRIPT = String.raw `
|
|
|
3350
3613
|
? {
|
|
3351
3614
|
selector,
|
|
3352
3615
|
userVisible: isUserVisible(element),
|
|
3616
|
+
pageFormSelector: (() => {
|
|
3617
|
+
const form = element.closest('form');
|
|
3618
|
+
if (!(form instanceof HTMLFormElement)) {
|
|
3619
|
+
return undefined;
|
|
3620
|
+
}
|
|
3621
|
+
|
|
3622
|
+
const buildSelector = (candidate) => {
|
|
3623
|
+
if (!(candidate instanceof HTMLElement)) {
|
|
3624
|
+
return undefined;
|
|
3625
|
+
}
|
|
3626
|
+
|
|
3627
|
+
if (candidate.id && isSelectorUniqueFor(candidate, '#' + cssEscape(candidate.id))) {
|
|
3628
|
+
return '#' + cssEscape(candidate.id);
|
|
3629
|
+
}
|
|
3630
|
+
|
|
3631
|
+
const path = [];
|
|
3632
|
+
let current = candidate;
|
|
3633
|
+
while (current && current.nodeType === Node.ELEMENT_NODE && path.length < 8) {
|
|
3634
|
+
const currentTag = current.tagName.toLowerCase();
|
|
3635
|
+
const parent = current.parentElement;
|
|
3636
|
+
const root = current.getRootNode?.();
|
|
3637
|
+
const siblingPool = parent
|
|
3638
|
+
? Array.from(parent.children)
|
|
3639
|
+
: isShadowRootNode(root)
|
|
3640
|
+
? Array.from(root.children)
|
|
3641
|
+
: [];
|
|
3642
|
+
const siblings = siblingPool.filter(
|
|
3643
|
+
(child) => child.tagName.toLowerCase() === currentTag
|
|
3644
|
+
);
|
|
3645
|
+
const index = siblings.indexOf(current) + 1;
|
|
3646
|
+
path.unshift(currentTag + ':nth-of-type(' + Math.max(index, 1) + ')');
|
|
3647
|
+
if (current.id) {
|
|
3648
|
+
break;
|
|
3649
|
+
}
|
|
3650
|
+
current = current.parentElement;
|
|
3651
|
+
}
|
|
3652
|
+
|
|
3653
|
+
if (path.length === 0) {
|
|
3654
|
+
return undefined;
|
|
3655
|
+
}
|
|
3656
|
+
|
|
3657
|
+
const structuralSelector = path.join(' > ');
|
|
3658
|
+
return isSelectorUniqueFor(candidate, structuralSelector) ? structuralSelector : undefined;
|
|
3659
|
+
};
|
|
3660
|
+
|
|
3661
|
+
return buildSelector(form);
|
|
3662
|
+
})(),
|
|
3353
3663
|
}
|
|
3354
3664
|
: null;
|
|
3355
3665
|
|
|
@@ -3497,7 +3807,7 @@ export async function collectDomTargets(page, options) {
|
|
|
3497
3807
|
}
|
|
3498
3808
|
const collected = [];
|
|
3499
3809
|
const includeActivationAffordances = options?.includeActivationAffordances === true;
|
|
3500
|
-
const walk = async (frame, framePath) => {
|
|
3810
|
+
const walk = async (frame, framePath, pageFormSelector) => {
|
|
3501
3811
|
if (collected.length >= DOM_TARGET_COLLECTION_LIMIT) {
|
|
3502
3812
|
return;
|
|
3503
3813
|
}
|
|
@@ -3507,6 +3817,7 @@ export async function collectDomTargets(page, options) {
|
|
|
3507
3817
|
pageSignature: topLevelPageSignature,
|
|
3508
3818
|
framePath,
|
|
3509
3819
|
frameUrl,
|
|
3820
|
+
pageFormSelector,
|
|
3510
3821
|
}).catch(() => []);
|
|
3511
3822
|
for (const target of targets) {
|
|
3512
3823
|
if (collected.length >= DOM_TARGET_COLLECTION_LIMIT) {
|
|
@@ -3525,7 +3836,7 @@ export async function collectDomTargets(page, options) {
|
|
|
3525
3836
|
if (!frameHost?.selector || !frameHost.userVisible) {
|
|
3526
3837
|
continue;
|
|
3527
3838
|
}
|
|
3528
|
-
await walk(childFrame, [...(framePath ?? []), frameHost.selector]);
|
|
3839
|
+
await walk(childFrame, [...(framePath ?? []), frameHost.selector], frameHost.pageFormSelector ?? pageFormSelector);
|
|
3529
3840
|
}
|
|
3530
3841
|
};
|
|
3531
3842
|
await walk(page.mainFrame());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe-persistence.d.ts","sourceRoot":"","sources":["../../src/commands/observe-persistence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AASnD,OAAO,KAAK,EAAoB,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACjG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAQhE,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,iBAAiB,EACzB,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACzC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"observe-persistence.d.ts","sourceRoot":"","sources":["../../src/commands/observe-persistence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AASnD,OAAO,KAAK,EAAoB,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACjG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAQhE,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,iBAAiB,EACzB,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACzC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CA4F/B;AAED,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,EAC5C,OAAO,EAAE,gBAAgB,EAAE,GAC1B,IAAI,CAYN;AAED,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,aAAa,CAAC,iBAAiB,CAAC,EACzC,OAAO,CAAC,EAAE;IACR,gBAAgB,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC,CAAC;IACjE,kBAAkB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC1C,GACA;IACD,cAAc,EAAE,iBAAiB,EAAE,CAAC;IACpC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAkEA;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,aAAa,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,GAC5D,IAAI,CAsBN;AAUD,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,EAC5C,gBAAgB,EAAE,aAAa,CAAC,gBAAgB,CAAC,EACjD,cAAc,EAAE,aAAa,CAAC,iBAAiB,CAAC,EAChD,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACzC,iBAAiB,EAAE,CAyDrB"}
|
|
@@ -51,6 +51,7 @@ export function toDomDescriptor(pageRef, target, surfaceRefMap) {
|
|
|
51
51
|
pageRef,
|
|
52
52
|
framePath: target.framePath,
|
|
53
53
|
frameUrl: target.frameUrl,
|
|
54
|
+
pageFormSelector: target.pageFormSelector,
|
|
54
55
|
kind: target.kind,
|
|
55
56
|
label: target.label ?? target.text ?? target.placeholder ?? target.title,
|
|
56
57
|
displayLabel: target.displayLabel,
|
|
@@ -62,6 +63,7 @@ export function toDomDescriptor(pageRef, target, surfaceRefMap) {
|
|
|
62
63
|
surfaceKind: target.surfaceKind,
|
|
63
64
|
controlsSurfaceSelector: target.controlsSurfaceSelector,
|
|
64
65
|
validation: target.validation,
|
|
66
|
+
selection: target.selection,
|
|
65
67
|
locatorCandidates,
|
|
66
68
|
semantics: target.role || target.label || target.states
|
|
67
69
|
? {
|
|
@@ -26,7 +26,7 @@ type ExpandWorkflowGraphTargetOptions = {
|
|
|
26
26
|
selectedSurfaceIds?: ReadonlySet<string>;
|
|
27
27
|
};
|
|
28
28
|
export declare function expandWorkflowGraphTargets(allTargets: ReadonlyArray<DomObservedTarget>, selectedTargets: ReadonlyArray<DomObservedTarget>, options?: ExpandWorkflowGraphTargetOptions): DomObservedTarget[];
|
|
29
|
-
export declare function compactTargets(targets: ReadonlyArray<Pick<TargetDescriptor, 'ref' | 'kind' | 'label' | 'displayLabel' | 'placeholder' | 'inputName' | 'inputType' | 'autocomplete' | 'validation' | 'context' | 'semantics' | 'structure' | 'capability' | 'availability' | 'surfaceRef'>>): Array<{
|
|
29
|
+
export declare function compactTargets(targets: ReadonlyArray<Pick<TargetDescriptor, 'ref' | 'kind' | 'label' | 'displayLabel' | 'placeholder' | 'inputName' | 'inputType' | 'autocomplete' | 'selection' | 'validation' | 'context' | 'semantics' | 'structure' | 'capability' | 'availability' | 'surfaceRef'>>): Array<{
|
|
30
30
|
ref: string;
|
|
31
31
|
kind?: string;
|
|
32
32
|
label?: string;
|
|
@@ -35,6 +35,7 @@ export declare function compactTargets(targets: ReadonlyArray<Pick<TargetDescrip
|
|
|
35
35
|
inputName?: string;
|
|
36
36
|
inputType?: string;
|
|
37
37
|
autocomplete?: string;
|
|
38
|
+
selection?: TargetDescriptor['selection'];
|
|
38
39
|
validation?: AgentFacingTargetValidationEvidence;
|
|
39
40
|
context?: string;
|
|
40
41
|
state?: Record<string, string | boolean | number>;
|
|
@@ -76,7 +77,7 @@ type BuildGroupedObserveScopesOptions = {
|
|
|
76
77
|
pageRef: string;
|
|
77
78
|
title?: string;
|
|
78
79
|
scopes: ReadonlyArray<Pick<SurfaceDescriptor, 'ref' | 'kind' | 'label' | 'availability' | 'parentSurfaceRef' | 'childSurfaceRefs' | 'extractScopeLifetime'>>;
|
|
79
|
-
targets: ReadonlyArray<Pick<TargetDescriptor, 'ref' | 'kind' | 'label' | 'displayLabel' | 'placeholder' | 'inputName' | 'inputType' | 'autocomplete' | 'validation' | 'context' | 'semantics' | 'structure' | 'capability' | 'availability' | 'surfaceRef'>>;
|
|
80
|
+
targets: ReadonlyArray<Pick<TargetDescriptor, 'ref' | 'kind' | 'label' | 'displayLabel' | 'placeholder' | 'inputName' | 'inputType' | 'autocomplete' | 'selection' | 'validation' | 'context' | 'semantics' | 'structure' | 'capability' | 'availability' | 'surfaceRef'>>;
|
|
80
81
|
};
|
|
81
82
|
export declare function buildGroupedObserveScopes(options: BuildGroupedObserveScopesOptions): CompactObservedScope[];
|
|
82
83
|
export declare function compactFillableForms(forms: ReadonlyArray<PersistedFillableForm>): Array<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe-projection.d.ts","sourceRoot":"","sources":["../../src/commands/observe-projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAC5F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAa/D,MAAM,MAAM,yBAAyB,GAAG;IACtC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB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OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACjC,CAyDA;AAED,wBAAgB,4BAA4B,CAC1C,gBAAgB,EAAE,aAAa,CAAC,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC,EACrE,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAC,EACvC,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACzC,GAAG,CAAC,MAAM,CAAC,CAkBb;AAED,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,EAC5C,gBAAgB,EAAE,aAAa,CAAC,gBAAgB,CAAC,EACjD,eAAe,EAAE,aAAa,CAAC,iBAAiB,CAAC,GAChD,gBAAgB,EAAE,CAsEpB"}
|
|
@@ -417,6 +417,7 @@ export function compactTargets(targets) {
|
|
|
417
417
|
inputName: target.inputName,
|
|
418
418
|
inputType: target.inputType,
|
|
419
419
|
autocomplete: target.autocomplete,
|
|
420
|
+
selection: target.selection,
|
|
420
421
|
validation: compactValidationEvidence(target.validation),
|
|
421
422
|
context: summarizeContext(target.context),
|
|
422
423
|
state: target.semantics?.states,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { BrowseSession } from '../session.js';
|
|
2
2
|
import { type TargetDescriptor } from '../runtime-state.js';
|
|
3
|
-
export declare function persistProtectedFillableFormsForPage(session: BrowseSession, pageRef: string, pageUrl: string, targets: ReadonlyArray<TargetDescriptor>, observedAt: string
|
|
3
|
+
export declare function persistProtectedFillableFormsForPage(session: BrowseSession, pageRef: string, pageUrl: string, targets: ReadonlyArray<TargetDescriptor>, observedAt: string, options?: {
|
|
4
|
+
previousPageUrl?: string;
|
|
5
|
+
}): Promise<import("../secrets/types.js").PersistedFillableForm[]>;
|
|
4
6
|
export declare function markProtectedFillableFormsUnknownForPage(session: BrowseSession, pageRef: string): import("../secrets/types.js").PersistedFillableForm[];
|
|
5
7
|
export declare function clearProtectedFillableFormsForPage(session: BrowseSession, pageRef: string): import("../secrets/types.js").PersistedFillableForm[];
|
|
6
8
|
//# sourceMappingURL=observe-protected.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe-protected.d.ts","sourceRoot":"","sources":["../../src/commands/observe-protected.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAoB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"observe-protected.d.ts","sourceRoot":"","sources":["../../src/commands/observe-protected.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAoB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAqC9E,wBAAsB,oCAAoC,CACxD,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,EACxC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IACP,eAAe,CAAC,EAAE,MAAM,CAAC;CACrB,kEAmBP;AAED,wBAAgB,wCAAwC,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,yDAE/F;AAED,wBAAgB,kCAAkC,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,yDAEzF"}
|
|
@@ -9,7 +9,26 @@ function tryResolveHost(pageUrl) {
|
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
function normalizeMeaningfulPageUrl(pageUrl) {
|
|
13
|
+
const trimmed = pageUrl?.trim();
|
|
14
|
+
if (!trimmed) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const url = new URL(trimmed);
|
|
19
|
+
url.hash = '';
|
|
20
|
+
return url.toString();
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return trimmed;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function didMeaningfulPageUrlChange(previousPageUrl, pageUrl) {
|
|
27
|
+
const previous = normalizeMeaningfulPageUrl(previousPageUrl);
|
|
28
|
+
const current = normalizeMeaningfulPageUrl(pageUrl);
|
|
29
|
+
return previous !== null && current !== null && previous !== current;
|
|
30
|
+
}
|
|
31
|
+
export async function persistProtectedFillableFormsForPage(session, pageRef, pageUrl, targets, observedAt, options = {}) {
|
|
13
32
|
const host = tryResolveHost(pageUrl);
|
|
14
33
|
const catalog = host ? getSecretCatalog(session, host) : null;
|
|
15
34
|
const matchedForms = await matchStoredSecretsToObservedTargets(pageRef, targets, catalog, {
|
|
@@ -17,6 +36,9 @@ export async function persistProtectedFillableFormsForPage(session, pageRef, pag
|
|
|
17
36
|
session,
|
|
18
37
|
});
|
|
19
38
|
if (matchedForms.length === 0) {
|
|
39
|
+
if (didMeaningfulPageUrlChange(options.previousPageUrl, pageUrl)) {
|
|
40
|
+
return clearProtectedFillableFormsForPage(session, pageRef);
|
|
41
|
+
}
|
|
20
42
|
return markFillableFormsUnknownForPage(session, pageRef);
|
|
21
43
|
}
|
|
22
44
|
return replaceFillableFormsForPage(session, pageRef, matchedForms, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe-semantics.d.ts","sourceRoot":"","sources":["../../src/commands/observe-semantics.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAYjF;
|
|
1
|
+
{"version":3,"file":"observe-semantics.d.ts","sourceRoot":"","sources":["../../src/commands/observe-semantics.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAYjF;AAgED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CA6B7E;AAgBD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,GAAG,SAAS,CAQ/E;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAMnE;AA6OD,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,aAAa,CAAC,iBAAiB,CAAC,GAChD,iBAAiB,EAAE,CA+BrB;AAqBD,wBAAgB,oCAAoC,CAClD,OAAO,EAAE,aAAa,CAAC,iBAAiB,CAAC,GACxC,iBAAiB,EAAE,CAuBrB;AAqGD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,EAAE,CAmHjG;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,aAAa,CAAC,iBAAiB,CAAC,GACxC,iBAAiB,EAAE,CAsFrB"}
|
|
@@ -11,6 +11,52 @@ export function normalizeSemanticDuplicateLabel(target) {
|
|
|
11
11
|
.trim()
|
|
12
12
|
.toLowerCase();
|
|
13
13
|
}
|
|
14
|
+
function normalizeSelectionText(value) {
|
|
15
|
+
const normalized = (value ?? '').replace(/\s+/g, ' ').trim();
|
|
16
|
+
return normalized || undefined;
|
|
17
|
+
}
|
|
18
|
+
function compactRemoveItemLabelOf(target) {
|
|
19
|
+
const contextItemLabel = normalizeSelectionText(target.context?.item?.label);
|
|
20
|
+
if (contextItemLabel) {
|
|
21
|
+
return contextItemLabel;
|
|
22
|
+
}
|
|
23
|
+
const contextItemText = normalizeSelectionText(target.context?.item?.text);
|
|
24
|
+
if (contextItemText) {
|
|
25
|
+
return contextItemText;
|
|
26
|
+
}
|
|
27
|
+
const label = normalizeSelectionText(target.label);
|
|
28
|
+
if (!label) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
const removeFromMatch = label.match(/^remove\s+(.+?)\s+from\s+.+$/i);
|
|
32
|
+
return removeFromMatch?.[1]?.trim() || undefined;
|
|
33
|
+
}
|
|
34
|
+
function isCompactRemoveActionTarget(target) {
|
|
35
|
+
const normalizedLabel = normalizeSemanticDuplicateLabel(target);
|
|
36
|
+
if (!normalizedLabel) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return (target.allowedActions?.includes('click') === true &&
|
|
40
|
+
/(?:^|\b)(remove|clear|close|delete|dismiss|cancel|убрать|удалить|очистить|закрыть)\b/i.test(normalizedLabel));
|
|
41
|
+
}
|
|
42
|
+
function isSelectionOwnerTarget(target) {
|
|
43
|
+
if (target.controlFamily === 'select') {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return Boolean(target.allowedActions?.includes('fill') ||
|
|
47
|
+
target.allowedActions?.includes('type') ||
|
|
48
|
+
target.allowedActions?.includes('select'));
|
|
49
|
+
}
|
|
50
|
+
function shareWorkflowContainer(left, right) {
|
|
51
|
+
const leftContainer = left.context?.container?.selector?.trim();
|
|
52
|
+
const rightContainer = right.context?.container?.selector?.trim();
|
|
53
|
+
if (leftContainer && rightContainer) {
|
|
54
|
+
return leftContainer === rightContainer;
|
|
55
|
+
}
|
|
56
|
+
const leftSurface = left.surfaceRef?.trim();
|
|
57
|
+
const rightSurface = right.surfaceRef?.trim();
|
|
58
|
+
return Boolean(leftSurface && rightSurface && leftSurface === rightSurface);
|
|
59
|
+
}
|
|
14
60
|
export function isPrimaryFormControlTarget(target) {
|
|
15
61
|
const kind = (target.kind ?? '').trim().toLowerCase();
|
|
16
62
|
const role = (target.role ?? '').trim().toLowerCase();
|
|
@@ -417,6 +463,30 @@ export function annotateDomTargets(targets) {
|
|
|
417
463
|
};
|
|
418
464
|
}));
|
|
419
465
|
return annotated.map((target, index, current) => {
|
|
466
|
+
const compactRemoveItemLabel = compactRemoveItemLabelOf(target);
|
|
467
|
+
const compactRemoveOwnerIndex = isCompactRemoveActionTarget(target) && compactRemoveItemLabel
|
|
468
|
+
? current.findIndex((candidate, candidateIndex) => {
|
|
469
|
+
if (candidateIndex === index)
|
|
470
|
+
return false;
|
|
471
|
+
if (!isSelectionOwnerTarget(candidate))
|
|
472
|
+
return false;
|
|
473
|
+
if (!shareWorkflowContainer(target, candidate))
|
|
474
|
+
return false;
|
|
475
|
+
return true;
|
|
476
|
+
})
|
|
477
|
+
: -1;
|
|
478
|
+
if (compactRemoveOwnerIndex >= 0 && compactRemoveItemLabel) {
|
|
479
|
+
const owner = current[compactRemoveOwnerIndex];
|
|
480
|
+
const ownerLabel = normalizeSelectionText(owner?.label);
|
|
481
|
+
const relabeledTarget = ownerLabel && compactRemoveItemLabel
|
|
482
|
+
? `Remove ${compactRemoveItemLabel} from ${ownerLabel}`
|
|
483
|
+
: target.label;
|
|
484
|
+
return {
|
|
485
|
+
...target,
|
|
486
|
+
label: relabeledTarget,
|
|
487
|
+
ownerIndex: compactRemoveOwnerIndex,
|
|
488
|
+
};
|
|
489
|
+
}
|
|
420
490
|
if (!target.surfaceRef ||
|
|
421
491
|
!target.acceptancePolicy ||
|
|
422
492
|
!(target.acceptancePolicy === 'selection' || target.acceptancePolicy === 'date-selection')) {
|