@mercuryo-ai/agentbrowse 0.2.60 → 0.2.63
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/CHANGELOG.md +33 -1
- package/README.md +132 -14
- package/dist/browser-session-state.d.ts +40 -10
- package/dist/browser-session-state.d.ts.map +1 -1
- package/dist/browser-session-state.js +63 -5
- package/dist/commands/act.d.ts.map +1 -1
- package/dist/commands/act.js +548 -535
- package/dist/commands/attach.d.ts +1 -3
- package/dist/commands/attach.d.ts.map +1 -1
- package/dist/commands/attach.js +5 -12
- package/dist/commands/browser-connection-failure.d.ts +9 -0
- package/dist/commands/browser-connection-failure.d.ts.map +1 -0
- package/dist/commands/browser-connection-failure.js +15 -0
- package/dist/commands/browser-status.d.ts +0 -2
- package/dist/commands/browser-status.d.ts.map +1 -1
- package/dist/commands/browser-status.js +27 -37
- package/dist/commands/close.d.ts.map +1 -1
- package/dist/commands/close.js +5 -0
- package/dist/commands/extract.d.ts.map +1 -1
- package/dist/commands/extract.js +147 -144
- package/dist/commands/interaction-kernel.d.ts +1 -1
- package/dist/commands/interaction-kernel.d.ts.map +1 -1
- package/dist/commands/interaction-kernel.js +1 -1
- package/dist/commands/launch.d.ts +0 -1
- package/dist/commands/launch.d.ts.map +1 -1
- package/dist/commands/launch.js +11 -12
- package/dist/commands/navigate.d.ts.map +1 -1
- package/dist/commands/navigate.js +79 -73
- package/dist/commands/observe-accessibility.d.ts.map +1 -1
- package/dist/commands/observe-accessibility.js +36 -2
- package/dist/commands/observe-inventory.d.ts +50 -7
- package/dist/commands/observe-inventory.d.ts.map +1 -1
- package/dist/commands/observe-inventory.js +822 -99
- package/dist/commands/observe-persistence.d.ts.map +1 -1
- package/dist/commands/observe-persistence.js +49 -6
- package/dist/commands/observe-projection.d.ts +6 -2
- package/dist/commands/observe-projection.d.ts.map +1 -1
- package/dist/commands/observe-projection.js +251 -27
- package/dist/commands/observe-semantics.d.ts +1 -0
- package/dist/commands/observe-semantics.d.ts.map +1 -1
- package/dist/commands/observe-semantics.js +541 -135
- package/dist/commands/observe-signals.d.ts +4 -4
- package/dist/commands/observe-signals.d.ts.map +1 -1
- package/dist/commands/observe-signals.js +2 -2
- package/dist/commands/observe-surfaces.d.ts +2 -1
- package/dist/commands/observe-surfaces.d.ts.map +1 -1
- package/dist/commands/observe-surfaces.js +143 -45
- package/dist/commands/observe.d.ts +5 -1
- package/dist/commands/observe.d.ts.map +1 -1
- package/dist/commands/observe.js +266 -274
- package/dist/commands/screenshot.d.ts.map +1 -1
- package/dist/commands/screenshot.js +50 -64
- package/dist/commands/semantic-observe.d.ts.map +1 -1
- package/dist/commands/semantic-observe.js +43 -0
- package/dist/library.d.ts +3 -1
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +3 -1
- package/dist/match-resolve-fill.d.ts +196 -0
- package/dist/match-resolve-fill.d.ts.map +1 -0
- package/dist/match-resolve-fill.js +700 -0
- package/dist/match-resolve-fill.test-support.d.ts +34 -0
- package/dist/match-resolve-fill.test-support.d.ts.map +1 -0
- package/dist/match-resolve-fill.test-support.js +81 -0
- package/dist/protected-fill.d.ts.map +1 -1
- package/dist/protected-fill.js +46 -7
- package/dist/runtime-protected-state.d.ts.map +1 -1
- package/dist/runtime-protected-state.js +12 -0
- package/dist/runtime-state.d.ts +6 -0
- package/dist/runtime-state.d.ts.map +1 -1
- package/dist/runtime-state.js +6 -0
- package/dist/secrets/form-matcher.d.ts.map +1 -1
- package/dist/secrets/form-matcher.js +76 -27
- package/dist/secrets/protected-exact-value-redaction.d.ts.map +1 -1
- package/dist/secrets/protected-exact-value-redaction.js +6 -0
- package/dist/secrets/protected-fill.js +3 -3
- package/dist/session.d.ts +3 -3
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +2 -2
- package/dist/solver/browser-launcher.d.ts.map +1 -1
- package/dist/solver/browser-launcher.js +2 -1
- package/dist/sticky-owner-host-entry.d.ts +2 -0
- package/dist/sticky-owner-host-entry.d.ts.map +1 -0
- package/dist/sticky-owner-host-entry.js +97 -0
- package/dist/sticky-owner.d.ts +15 -0
- package/dist/sticky-owner.d.ts.map +1 -0
- package/dist/sticky-owner.js +431 -0
- package/dist/testing.d.ts +1 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +1 -0
- package/docs/README.md +28 -11
- package/docs/api-reference.md +311 -19
- package/docs/assistive-runtime.md +41 -16
- package/docs/configuration.md +36 -4
- package/docs/getting-started.md +73 -5
- package/docs/integration-checklist.md +32 -3
- package/docs/match-resolve-fill.md +699 -0
- package/docs/protected-fill.md +373 -91
- package/docs/testing.md +147 -15
- package/docs/troubleshooting.md +47 -6
- package/examples/README.md +7 -0
- package/examples/match-resolve-fill.ts +107 -0
- package/package.json +4 -2
- package/dist/protected-fill-browser.d.ts +0 -22
- package/dist/protected-fill-browser.d.ts.map +0 -1
- package/dist/protected-fill-browser.js +0 -52
|
@@ -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;
|
|
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;AAmDhE,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,CA6F/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,CAsErB"}
|
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
import { ensureRuntimeState, markSurfaceLifecycle, markTargetLifecycle, replaceSurfacesForPage, setSurfaceAvailability, setTargetAvailability, } from '../runtime-state.js';
|
|
2
|
-
import { buildSyntheticFormSurfaceId, collectSurfaceDescriptors, pushUniqueLocatorCandidate, surfaceReplacementKey, } from './observe-surfaces.js';
|
|
2
|
+
import { buildExplicitSurfaceRef, buildSyntheticFormSurfaceId, collectSurfaceDescriptors, pushUniqueLocatorCandidate, surfaceReplacementKey, } from './observe-surfaces.js';
|
|
3
|
+
function shouldAddProxyOwnerLocatorCandidates(target) {
|
|
4
|
+
const isSelectionLikeControl = target.controlFamily === 'select' ||
|
|
5
|
+
target.controlFamily === 'datepicker' ||
|
|
6
|
+
target.acceptancePolicy === 'selection' ||
|
|
7
|
+
target.acceptancePolicy === 'date-selection';
|
|
8
|
+
if (!isSelectionLikeControl) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return target.states?.disabled === true || target.states?.readonly === true;
|
|
12
|
+
}
|
|
13
|
+
function pushProxyOwnerLocatorCandidates(locatorCandidates, target) {
|
|
14
|
+
if (!shouldAddProxyOwnerLocatorCandidates(target)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
for (const node of [
|
|
18
|
+
target.context?.item,
|
|
19
|
+
target.context?.group,
|
|
20
|
+
target.context?.container,
|
|
21
|
+
target.context?.landmark,
|
|
22
|
+
]) {
|
|
23
|
+
const selector = node?.selector?.trim();
|
|
24
|
+
if (!selector || selector === target.selector) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
pushUniqueLocatorCandidate(locatorCandidates, {
|
|
28
|
+
strategy: 'css',
|
|
29
|
+
value: selector,
|
|
30
|
+
scope: 'root',
|
|
31
|
+
activationOwner: true,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
3
35
|
export function toDomDescriptor(pageRef, target, surfaceRefMap) {
|
|
4
36
|
const locatorCandidates = [];
|
|
5
37
|
if (target.role && target.label) {
|
|
@@ -47,6 +79,7 @@ export function toDomDescriptor(pageRef, target, surfaceRefMap) {
|
|
|
47
79
|
scope: 'root',
|
|
48
80
|
});
|
|
49
81
|
}
|
|
82
|
+
pushProxyOwnerLocatorCandidates(locatorCandidates, target);
|
|
50
83
|
return {
|
|
51
84
|
pageRef,
|
|
52
85
|
framePath: target.framePath,
|
|
@@ -207,17 +240,27 @@ export function linkObservedSurfaceGraph(session, pageRef, domTargets, persisted
|
|
|
207
240
|
if (!domTarget) {
|
|
208
241
|
continue;
|
|
209
242
|
}
|
|
243
|
+
const explicitSurfaceId = buildExplicitSurfaceRef(domTarget);
|
|
244
|
+
const explicitSurfaceRef = explicitSurfaceId ? surfaceRefMap.get(explicitSurfaceId) : undefined;
|
|
210
245
|
const syntheticFormSurfaceId = buildSyntheticFormSurfaceId(domTarget);
|
|
211
246
|
const formSurfaceRef = syntheticFormSurfaceId
|
|
212
247
|
? surfaceRefMap.get(syntheticFormSurfaceId)
|
|
213
248
|
: undefined;
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
persistedTarget.surfaceRef
|
|
249
|
+
if (explicitSurfaceRef &&
|
|
250
|
+
persistedTarget.surfaceRef &&
|
|
251
|
+
persistedTarget.surfaceRef !== explicitSurfaceRef) {
|
|
252
|
+
parentBySurface.set(persistedTarget.surfaceRef, explicitSurfaceRef);
|
|
253
|
+
pushUniqueRef(childRefsByParent, explicitSurfaceRef, persistedTarget.surfaceRef);
|
|
254
|
+
}
|
|
255
|
+
const surfaceRefNeedingParent = explicitSurfaceRef ?? persistedTarget.surfaceRef;
|
|
256
|
+
if (!formSurfaceRef || !surfaceRefNeedingParent || surfaceRefNeedingParent === formSurfaceRef) {
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
if (parentBySurface.get(surfaceRefNeedingParent) === formSurfaceRef) {
|
|
217
260
|
continue;
|
|
218
261
|
}
|
|
219
|
-
parentBySurface.set(
|
|
220
|
-
pushUniqueRef(childRefsByParent, formSurfaceRef,
|
|
262
|
+
parentBySurface.set(surfaceRefNeedingParent, formSurfaceRef);
|
|
263
|
+
pushUniqueRef(childRefsByParent, formSurfaceRef, surfaceRefNeedingParent);
|
|
221
264
|
}
|
|
222
265
|
for (const surface of Object.values(runtime.surfaces)) {
|
|
223
266
|
if (surface.pageRef !== pageRef) {
|
|
@@ -22,12 +22,14 @@ export type GoalObserveTargetCandidate = DomObservedTarget & {
|
|
|
22
22
|
};
|
|
23
23
|
export type GoalObserveInventoryCandidate = GoalObserveTargetCandidate | GoalObserveScopeCandidate;
|
|
24
24
|
type AgentFacingTargetValidationEvidence = Omit<TargetValidationEvidence, 'required'>;
|
|
25
|
+
export declare function materializeObserveOutputTargets(domTargets: ReadonlyArray<DomObservedTarget>, allPersistedTargets: ReadonlyArray<TargetDescriptor>, outputTargets?: ReadonlyArray<TargetDescriptor>): TargetDescriptor[];
|
|
25
26
|
type ExpandWorkflowGraphTargetOptions = {
|
|
26
27
|
selectedSurfaceIds?: ReadonlySet<string>;
|
|
27
28
|
};
|
|
28
29
|
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' | 'selection' | 'validation' | 'context' | 'semantics' | 'structure' | 'capability' | 'availability' | 'surfaceRef'>>): Array<{
|
|
30
|
+
export declare function compactTargets(targets: ReadonlyArray<Pick<TargetDescriptor, 'ref' | 'pageRef' | 'kind' | 'label' | 'displayLabel' | 'placeholder' | 'inputName' | 'inputType' | 'autocomplete' | 'selection' | 'validation' | 'context' | 'semantics' | 'structure' | 'capability' | 'availability' | 'surfaceRef'>>): Array<{
|
|
30
31
|
ref: string;
|
|
32
|
+
pageRef: string;
|
|
31
33
|
kind?: string;
|
|
32
34
|
label?: string;
|
|
33
35
|
displayLabel?: string;
|
|
@@ -77,7 +79,9 @@ type BuildGroupedObserveScopesOptions = {
|
|
|
77
79
|
pageRef: string;
|
|
78
80
|
title?: string;
|
|
79
81
|
scopes: ReadonlyArray<Pick<SurfaceDescriptor, 'ref' | 'kind' | 'label' | 'availability' | 'parentSurfaceRef' | 'childSurfaceRefs' | 'extractScopeLifetime'>>;
|
|
80
|
-
targets: ReadonlyArray<Pick<TargetDescriptor, 'ref' | 'kind' | 'label' | 'displayLabel' | 'placeholder' | 'inputName' | 'inputType' | 'autocomplete' | 'selection' | 'validation' | 'context' | 'semantics' | 'structure' | 'capability' | 'availability' | 'surfaceRef'
|
|
82
|
+
targets: ReadonlyArray<Pick<TargetDescriptor, 'ref' | 'kind' | 'label' | 'displayLabel' | 'placeholder' | 'inputName' | 'inputType' | 'autocomplete' | 'selection' | 'validation' | 'context' | 'semantics' | 'structure' | 'capability' | 'availability' | 'surfaceRef'> & {
|
|
83
|
+
pageRef?: string;
|
|
84
|
+
}>;
|
|
81
85
|
};
|
|
82
86
|
export declare function buildGroupedObserveScopes(options: BuildGroupedObserveScopesOptions): CompactObservedScope[];
|
|
83
87
|
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;
|
|
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,q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;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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { buildObserveDisplayLabel } from './observe-display-label.js';
|
|
1
2
|
import { formGroupingKeyOf, isPrimaryFormControlTarget, normalizeSemanticDuplicateLabel, observedTargetKey, } from './observe-semantics.js';
|
|
2
|
-
import { buildSyntheticFormSurfaceId, OUTPUT_LEADING_TARGET_LIMIT, summarizeContext, } from './observe-surfaces.js';
|
|
3
|
+
import { buildExplicitSurfaceRef, buildSyntheticFormSurfaceId, OUTPUT_LEADING_TARGET_LIMIT, summarizeContext, } from './observe-surfaces.js';
|
|
3
4
|
const WORKFLOW_ROOT_KINDS = new Set([
|
|
4
5
|
'dialog',
|
|
5
6
|
'form',
|
|
@@ -78,10 +79,140 @@ function compactValidationEvidence(validation) {
|
|
|
78
79
|
};
|
|
79
80
|
return Object.values(compacted).some((value) => value !== undefined) ? compacted : undefined;
|
|
80
81
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
function normalizeOutputText(value) {
|
|
83
|
+
const normalized = value?.replace(/\s+/g, ' ').trim();
|
|
84
|
+
return normalized ? normalized : undefined;
|
|
85
|
+
}
|
|
86
|
+
const ACTION_STYLE_PLACEHOLDER_RE = /^(?:select|choose|pick|enter|set|search|find|click|tap|open)\b/i;
|
|
87
|
+
function workflowStateBaseLabelOf(target) {
|
|
88
|
+
const label = normalizeOutputText(target.label);
|
|
89
|
+
const placeholder = normalizeOutputText(target.placeholder);
|
|
90
|
+
const shouldUseContextLabel = (target.controlFamily === 'datepicker' || target.acceptancePolicy === 'date-selection') &&
|
|
91
|
+
Boolean(label) &&
|
|
92
|
+
Boolean(placeholder) &&
|
|
93
|
+
label === placeholder &&
|
|
94
|
+
ACTION_STYLE_PLACEHOLDER_RE.test(label ?? '');
|
|
95
|
+
if (!shouldUseContextLabel) {
|
|
96
|
+
return target.label;
|
|
97
|
+
}
|
|
98
|
+
for (const node of [
|
|
99
|
+
target.context?.item,
|
|
100
|
+
target.context?.group,
|
|
101
|
+
target.context?.container,
|
|
102
|
+
target.context?.landmark,
|
|
103
|
+
]) {
|
|
104
|
+
const contextLabel = normalizeOutputText(node?.label ?? node?.text);
|
|
105
|
+
if (!contextLabel || contextLabel === label) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
return contextLabel;
|
|
109
|
+
}
|
|
110
|
+
return target.label;
|
|
111
|
+
}
|
|
112
|
+
function workflowStateSignalOf(target) {
|
|
113
|
+
const displayLabel = normalizeOutputText(target.displayLabel);
|
|
114
|
+
if (displayLabel) {
|
|
115
|
+
return displayLabel;
|
|
116
|
+
}
|
|
117
|
+
if (target.controlFamily !== 'text-input' &&
|
|
118
|
+
target.controlFamily !== 'select' &&
|
|
119
|
+
target.controlFamily !== 'datepicker' &&
|
|
120
|
+
target.acceptancePolicy !== 'value-change' &&
|
|
121
|
+
target.acceptancePolicy !== 'selection' &&
|
|
122
|
+
target.acceptancePolicy !== 'date-selection') {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
return buildObserveDisplayLabel(workflowStateBaseLabelOf(target), target.currentValue);
|
|
126
|
+
}
|
|
127
|
+
function workflowStateRootSelectorsOf(target) {
|
|
128
|
+
const selectors = new Set();
|
|
129
|
+
const push = (value) => {
|
|
130
|
+
const normalized = normalizeOutputText(value);
|
|
131
|
+
if (normalized) {
|
|
132
|
+
selectors.add(normalized);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
push(target.context?.container?.selector);
|
|
136
|
+
for (const candidate of target.context?.ownerCandidates ?? []) {
|
|
137
|
+
push(candidate.selector);
|
|
138
|
+
}
|
|
139
|
+
return [...selectors];
|
|
140
|
+
}
|
|
141
|
+
function buildWorkflowStateSummaryByRootSelector(domTargets) {
|
|
142
|
+
const summaryPartsBySelector = new Map();
|
|
143
|
+
for (const target of domTargets) {
|
|
144
|
+
if ((target.acceptancePolicy ?? '').trim().toLowerCase() === 'submit') {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const signal = workflowStateSignalOf(target);
|
|
148
|
+
if (!signal) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
for (const selector of workflowStateRootSelectorsOf(target)) {
|
|
152
|
+
const parts = summaryPartsBySelector.get(selector) ?? [];
|
|
153
|
+
if (!parts.includes(signal)) {
|
|
154
|
+
parts.push(signal);
|
|
155
|
+
summaryPartsBySelector.set(selector, parts);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const summaries = new Map();
|
|
160
|
+
for (const [selector, parts] of summaryPartsBySelector.entries()) {
|
|
161
|
+
if (parts.length === 0) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
summaries.set(selector, parts.slice(0, 4).join(' / '));
|
|
165
|
+
}
|
|
166
|
+
return summaries;
|
|
167
|
+
}
|
|
168
|
+
function mergeWorkflowStateContext(context, summary) {
|
|
169
|
+
return {
|
|
170
|
+
...context,
|
|
171
|
+
container: {
|
|
172
|
+
...context?.container,
|
|
173
|
+
kind: context?.container?.kind ?? 'form',
|
|
174
|
+
label: summary,
|
|
175
|
+
text: summary,
|
|
176
|
+
},
|
|
177
|
+
hintText: summary,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
export function materializeObserveOutputTargets(domTargets, allPersistedTargets, outputTargets = allPersistedTargets) {
|
|
181
|
+
const domTargetByRef = new Map();
|
|
182
|
+
allPersistedTargets.forEach((target, index) => {
|
|
183
|
+
const domTarget = domTargets[index];
|
|
184
|
+
if (target.ref && domTarget) {
|
|
185
|
+
domTargetByRef.set(target.ref, domTarget);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
const workflowStateSummaryByRootSelector = buildWorkflowStateSummaryByRootSelector(domTargets);
|
|
189
|
+
return outputTargets.map((target) => {
|
|
190
|
+
const domTarget = domTargetByRef.get(target.ref);
|
|
191
|
+
if (!domTarget) {
|
|
192
|
+
return target;
|
|
193
|
+
}
|
|
194
|
+
let nextTarget = target;
|
|
195
|
+
const displayLabel = workflowStateSignalOf(domTarget);
|
|
196
|
+
if (displayLabel && displayLabel !== target.displayLabel) {
|
|
197
|
+
nextTarget = {
|
|
198
|
+
...nextTarget,
|
|
199
|
+
displayLabel,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
if ((domTarget.acceptancePolicy ?? '').trim().toLowerCase() !== 'submit') {
|
|
203
|
+
return nextTarget;
|
|
204
|
+
}
|
|
205
|
+
const summary = workflowStateRootSelectorsOf(domTarget)
|
|
206
|
+
.map((selector) => workflowStateSummaryByRootSelector.get(selector))
|
|
207
|
+
.find((value) => Boolean(value));
|
|
208
|
+
if (!summary) {
|
|
209
|
+
return nextTarget;
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
...nextTarget,
|
|
213
|
+
context: mergeWorkflowStateContext(nextTarget.context, summary),
|
|
214
|
+
};
|
|
215
|
+
});
|
|
85
216
|
}
|
|
86
217
|
function matchesSelectedSurfaceSeed(target, selectedSurfaceIds) {
|
|
87
218
|
if (selectedSurfaceIds.size === 0) {
|
|
@@ -94,6 +225,79 @@ function matchesSelectedSurfaceSeed(target, selectedSurfaceIds) {
|
|
|
94
225
|
const syntheticFormSurfaceId = buildSyntheticFormSurfaceId(target);
|
|
95
226
|
return syntheticFormSurfaceId ? selectedSurfaceIds.has(syntheticFormSurfaceId) : false;
|
|
96
227
|
}
|
|
228
|
+
function formRootKeysOf(target) {
|
|
229
|
+
const keys = new Set();
|
|
230
|
+
const formKey = formGroupingKeyOf(target);
|
|
231
|
+
if (formKey) {
|
|
232
|
+
keys.add(formKey);
|
|
233
|
+
}
|
|
234
|
+
const surfaceKind = normalizeClusterText(target.surfaceKind);
|
|
235
|
+
const surfaceSelector = normalizeWorkflowSurfaceSelector(target.surfaceSelector);
|
|
236
|
+
if (surfaceKind === 'form' && surfaceSelector) {
|
|
237
|
+
keys.add(`selector:${surfaceSelector}`);
|
|
238
|
+
}
|
|
239
|
+
const explicitSurfaceKind = normalizeClusterText(target.explicitSurfaceKind);
|
|
240
|
+
const explicitSurfaceSelector = normalizeWorkflowSurfaceSelector(target.explicitSurfaceSelector);
|
|
241
|
+
if (explicitSurfaceKind === 'form' && explicitSurfaceSelector) {
|
|
242
|
+
keys.add(`selector:${explicitSurfaceSelector}`);
|
|
243
|
+
}
|
|
244
|
+
const formLabel = normalizeClusterText(target.context?.landmark?.kind === 'form'
|
|
245
|
+
? (target.context.landmark.label ?? target.context.landmark.text)
|
|
246
|
+
: target.context?.group?.kind === 'form'
|
|
247
|
+
? (target.context.group.label ?? target.context.group.text)
|
|
248
|
+
: undefined);
|
|
249
|
+
if (formLabel) {
|
|
250
|
+
keys.add(`label:${formLabel}`);
|
|
251
|
+
}
|
|
252
|
+
return [...keys];
|
|
253
|
+
}
|
|
254
|
+
function matchesSelectedFormSurfaceSeed(target, selectedSurfaceIds) {
|
|
255
|
+
const surfaceKind = normalizeClusterText(target.surfaceKind);
|
|
256
|
+
const surfaceRef = target.surfaceRef?.trim();
|
|
257
|
+
if (surfaceKind === 'form' && surfaceRef && selectedSurfaceIds.has(surfaceRef)) {
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
const explicitSurfaceKind = normalizeClusterText(target.explicitSurfaceKind);
|
|
261
|
+
if (explicitSurfaceKind === 'form') {
|
|
262
|
+
const explicitSurfaceRef = buildExplicitSurfaceRef(target);
|
|
263
|
+
if (explicitSurfaceRef && selectedSurfaceIds.has(explicitSurfaceRef)) {
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
const syntheticFormSurfaceId = buildSyntheticFormSurfaceId(target);
|
|
268
|
+
return syntheticFormSurfaceId ? selectedSurfaceIds.has(syntheticFormSurfaceId) : false;
|
|
269
|
+
}
|
|
270
|
+
function selectedFormRootKeysOf(allTargets, seededTargets, selectedSurfaceIds) {
|
|
271
|
+
const selectedFormRootKeys = new Set();
|
|
272
|
+
const seededFormRootCounts = new Map();
|
|
273
|
+
for (const target of seededTargets) {
|
|
274
|
+
for (const formRootKey of formRootKeysOf(target)) {
|
|
275
|
+
seededFormRootCounts.set(formRootKey, (seededFormRootCounts.get(formRootKey) ?? 0) + 1);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
for (const [formRootKey, count] of seededFormRootCounts.entries()) {
|
|
279
|
+
if (count >= 2) {
|
|
280
|
+
selectedFormRootKeys.add(formRootKey);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
for (const target of allTargets) {
|
|
284
|
+
if (!matchesSelectedFormSurfaceSeed(target, selectedSurfaceIds)) {
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
for (const formRootKey of formRootKeysOf(target)) {
|
|
288
|
+
selectedFormRootKeys.add(formRootKey);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return selectedFormRootKeys;
|
|
292
|
+
}
|
|
293
|
+
function matchingSelectedFormRootKey(target, selectedFormRootKeys) {
|
|
294
|
+
for (const formRootKey of formRootKeysOf(target)) {
|
|
295
|
+
if (selectedFormRootKeys.has(formRootKey)) {
|
|
296
|
+
return formRootKey;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return undefined;
|
|
300
|
+
}
|
|
97
301
|
function workflowClusterKeyOf(target) {
|
|
98
302
|
const formKey = formGroupingKeyOf(target);
|
|
99
303
|
if (formKey) {
|
|
@@ -103,8 +307,7 @@ function workflowClusterKeyOf(target) {
|
|
|
103
307
|
if (surfaceRef) {
|
|
104
308
|
return `surface:${surfaceRef}`;
|
|
105
309
|
}
|
|
106
|
-
|
|
107
|
-
return surfaceSelector ? `selector:${surfaceSelector}` : undefined;
|
|
310
|
+
return undefined;
|
|
108
311
|
}
|
|
109
312
|
function matchesWorkflowCluster(target, clusterKey) {
|
|
110
313
|
return workflowClusterKeyOf(target) === clusterKey;
|
|
@@ -137,26 +340,16 @@ function isTerminalWorkflowActionTarget(target) {
|
|
|
137
340
|
const inputType = (target.inputType ?? '').trim().toLowerCase();
|
|
138
341
|
return acceptancePolicy === 'submit' || inputType === 'submit';
|
|
139
342
|
}
|
|
140
|
-
function canJoinSelectedWorkflowRoot(target
|
|
343
|
+
function canJoinSelectedWorkflowRoot(target) {
|
|
141
344
|
if (!isPrimaryFormControlTarget(target)) {
|
|
142
345
|
return false;
|
|
143
346
|
}
|
|
144
|
-
|
|
145
|
-
if (surfaceRef && selectedSurfaceRefs.has(surfaceRef)) {
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
const surfaceSelector = normalizeWorkflowSurfaceSelector(target.surfaceSelector);
|
|
149
|
-
if (surfaceSelector && selectedSurfaceSelectors.has(surfaceSelector)) {
|
|
150
|
-
return true;
|
|
151
|
-
}
|
|
152
|
-
const surfaceKind = normalizeClusterText(target.surfaceKind);
|
|
153
|
-
return surfaceKind === 'dialog' || surfaceKind === 'form' || (!surfaceRef && !surfaceSelector);
|
|
347
|
+
return Boolean(target.surfaceRef?.trim() || formGroupingKeyOf(target));
|
|
154
348
|
}
|
|
155
|
-
function shouldExpandAcrossWorkflowRoots(selectedPrimaryTargets
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return selectedPrimaryTargets.some((target) => Boolean(target.framePath?.length));
|
|
349
|
+
function shouldExpandAcrossWorkflowRoots(selectedPrimaryTargets) {
|
|
350
|
+
return selectedPrimaryTargets.some((target) => Boolean(target.framePath?.length) ||
|
|
351
|
+
Boolean(target.surfaceRef?.trim()) ||
|
|
352
|
+
Boolean(formGroupingKeyOf(target)));
|
|
160
353
|
}
|
|
161
354
|
export function expandWorkflowGraphTargets(allTargets, selectedTargets, options = {}) {
|
|
162
355
|
const selectedSurfaceIds = options.selectedSurfaceIds ?? new Set();
|
|
@@ -176,9 +369,9 @@ export function expandWorkflowGraphTargets(allTargets, selectedTargets, options
|
|
|
176
369
|
}
|
|
177
370
|
const seededTargets = [...expanded.values()];
|
|
178
371
|
const selectedSurfaceSelectors = selectedSurfaceSelectorsOf(seededTargets);
|
|
179
|
-
const selectedSurfaceRefs = selectedSurfaceRefsOf(seededTargets);
|
|
180
372
|
const selectedPrimaryTargets = seededTargets.filter(isPrimaryFormControlTarget);
|
|
181
373
|
const selectedClusterCounts = new Map();
|
|
374
|
+
const selectedFormRootKeys = selectedFormRootKeysOf(allTargets, seededTargets, selectedSurfaceIds);
|
|
182
375
|
for (const target of selectedPrimaryTargets) {
|
|
183
376
|
const clusterKey = workflowClusterKeyOf(target);
|
|
184
377
|
if (!clusterKey) {
|
|
@@ -197,6 +390,33 @@ export function expandWorkflowGraphTargets(allTargets, selectedTargets, options
|
|
|
197
390
|
}
|
|
198
391
|
expanded.set(key, target);
|
|
199
392
|
}
|
|
393
|
+
const formClosureCandidates = [];
|
|
394
|
+
const formTerminalCandidateCounts = new Map();
|
|
395
|
+
for (const target of allTargets) {
|
|
396
|
+
const key = observedTargetKey(target);
|
|
397
|
+
if (expanded.has(key) || !isPrimaryFormControlTarget(target)) {
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
const matchedFormRootKey = matchingSelectedFormRootKey(target, selectedFormRootKeys);
|
|
401
|
+
if (!matchedFormRootKey) {
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
formClosureCandidates.push({
|
|
405
|
+
key,
|
|
406
|
+
target,
|
|
407
|
+
closureKey: matchedFormRootKey,
|
|
408
|
+
});
|
|
409
|
+
if (isTerminalWorkflowActionTarget(target)) {
|
|
410
|
+
formTerminalCandidateCounts.set(matchedFormRootKey, (formTerminalCandidateCounts.get(matchedFormRootKey) ?? 0) + 1);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
for (const candidate of formClosureCandidates) {
|
|
414
|
+
if (isTerminalWorkflowActionTarget(candidate.target) &&
|
|
415
|
+
(formTerminalCandidateCounts.get(candidate.closureKey) ?? 0) > 1) {
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
expanded.set(candidate.key, candidate.target);
|
|
419
|
+
}
|
|
200
420
|
const expandableClusterKeys = new Set([...selectedClusterCounts.entries()]
|
|
201
421
|
.filter(([, count]) => count >= 2)
|
|
202
422
|
.map(([clusterKey]) => clusterKey));
|
|
@@ -226,7 +446,7 @@ export function expandWorkflowGraphTargets(allTargets, selectedTargets, options
|
|
|
226
446
|
.filter(([, count]) => count >= 2)
|
|
227
447
|
.map(([workflowRootKey]) => workflowRootKey));
|
|
228
448
|
if (selectedWorkflowRoots.size === 0 ||
|
|
229
|
-
!shouldExpandAcrossWorkflowRoots(expandedPrimaryTargets
|
|
449
|
+
!shouldExpandAcrossWorkflowRoots(expandedPrimaryTargets)) {
|
|
230
450
|
return sortObservedTargets([...expanded.values()]);
|
|
231
451
|
}
|
|
232
452
|
const rootClosureCandidates = [];
|
|
@@ -240,7 +460,7 @@ export function expandWorkflowGraphTargets(allTargets, selectedTargets, options
|
|
|
240
460
|
if (!workflowRootKey || !selectedWorkflowRoots.has(workflowRootKey)) {
|
|
241
461
|
continue;
|
|
242
462
|
}
|
|
243
|
-
if (!canJoinSelectedWorkflowRoot(target
|
|
463
|
+
if (!canJoinSelectedWorkflowRoot(target)) {
|
|
244
464
|
continue;
|
|
245
465
|
}
|
|
246
466
|
rootClosureCandidates.push({ key, target, workflowRootKey });
|
|
@@ -410,6 +630,7 @@ function sanitizeGoalTargetContext(target, siblingLabelsByCluster, transientAuto
|
|
|
410
630
|
export function compactTargets(targets) {
|
|
411
631
|
return targets.map((target) => ({
|
|
412
632
|
ref: target.ref,
|
|
633
|
+
pageRef: target.pageRef,
|
|
413
634
|
kind: target.kind,
|
|
414
635
|
label: target.label,
|
|
415
636
|
displayLabel: target.displayLabel,
|
|
@@ -448,7 +669,10 @@ function compactScopeSource(targets) {
|
|
|
448
669
|
return targets.find((target) => typeof target.source === 'string')?.source ?? 'dom';
|
|
449
670
|
}
|
|
450
671
|
export function buildGroupedObserveScopes(options) {
|
|
451
|
-
const compactedTargets = compactTargets(options.targets)
|
|
672
|
+
const compactedTargets = compactTargets(options.targets.map((target) => ({
|
|
673
|
+
...target,
|
|
674
|
+
pageRef: target.pageRef ?? options.pageRef,
|
|
675
|
+
})));
|
|
452
676
|
const scopeRefs = new Set(options.scopes.map((scope) => scope.ref));
|
|
453
677
|
const compactedTargetsByScope = new Map();
|
|
454
678
|
const leadingPageTargetRefs = new Set(compactedTargets
|
|
@@ -7,4 +7,5 @@ export declare function prioritizeGoalActionTargets(instruction: string, selecte
|
|
|
7
7
|
export declare function compressSemanticallyDuplicateTargets(targets: ReadonlyArray<DomObservedTarget>): DomObservedTarget[];
|
|
8
8
|
export declare function annotateDomTargets(targets: ReadonlyArray<DomObservedTarget>): DomObservedTarget[];
|
|
9
9
|
export declare function orderBySurfaceCompetition(targets: ReadonlyArray<DomObservedTarget>): DomObservedTarget[];
|
|
10
|
+
export declare function normalizePostEnrichmentDomTargets(targets: ReadonlyArray<DomObservedTarget>): DomObservedTarget[];
|
|
10
11
|
//# sourceMappingURL=observe-semantics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe-semantics.d.ts","sourceRoot":"","sources":["../../src/commands/observe-semantics.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"observe-semantics.d.ts","sourceRoot":"","sources":["../../src/commands/observe-semantics.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAA6B,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3F,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;AAyvBD,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;AA4OD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,EAAE,CAQjG;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,aAAa,CAAC,iBAAiB,CAAC,GACxC,iBAAiB,EAAE,CAsFrB;AAED,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,aAAa,CAAC,iBAAiB,CAAC,GACxC,iBAAiB,EAAE,CAIrB"}
|