@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,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ObservedFrameLike } from './observe-inventory.js';
|
|
2
2
|
export type ObservedPageSignal = {
|
|
3
3
|
kind: 'status' | 'alert' | 'dialog' | 'notice' | 'outcome';
|
|
4
4
|
text: string;
|
|
@@ -7,7 +7,7 @@ export type ObservedPageSignal = {
|
|
|
7
7
|
source: 'dom';
|
|
8
8
|
};
|
|
9
9
|
type SignalCollectionContext = {
|
|
10
|
-
evaluate
|
|
10
|
+
evaluate(pageFunction: string): Promise<unknown>;
|
|
11
11
|
};
|
|
12
12
|
export declare function inferObservedSignalKindFromFacts(facts: {
|
|
13
13
|
role?: string;
|
|
@@ -34,8 +34,8 @@ declare function collectPageSignalsFromDocument(context: SignalCollectionContext
|
|
|
34
34
|
frameUrl?: string;
|
|
35
35
|
}): Promise<ObservedPageSignal[]>;
|
|
36
36
|
export declare function collectPageSignals(page: {
|
|
37
|
-
evaluate
|
|
38
|
-
mainFrame?: () =>
|
|
37
|
+
evaluate(pageFunction: string): Promise<unknown>;
|
|
38
|
+
mainFrame?: () => ObservedFrameLike;
|
|
39
39
|
}): Promise<ObservedPageSignal[]>;
|
|
40
40
|
export declare const __testObserveSignals: {
|
|
41
41
|
collectPageSignalsFromDocument: typeof collectPageSignalsFromDocument;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe-signals.d.ts","sourceRoot":"","sources":["../../src/commands/observe-signals.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"observe-signals.d.ts","sourceRoot":"","sources":["../../src/commands/observe-signals.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAClD,CAAC;AAQF,wBAAgB,gCAAgC,CAAC,KAAK,EAAE;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAuB7B;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAQ7E;AAED,wBAAgB,uCAAuC,CAAC,KAAK,EAAE;IAC7D,+BAA+B,CAAC,EAAE,OAAO,CAAC;IAC1C,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,GAAG,OAAO,CAQV;AAED,wBAAgB,mCAAmC,CAAC,KAAK,EAAE;IACzD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,+BAA+B,CAAC,EAAE,OAAO,CAAC;IAC1C,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAoBV;AAqCD,iBAAe,8BAA8B,CAC3C,OAAO,EAAE,uBAAuB,EAChC,OAAO,CAAC,EAAE;IACR,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GACA,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAwU/B;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,SAAS,CAAC,EAAE,MAAM,iBAAiB,CAAC;CACrC,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA0DhC;AAED,eAAO,MAAM,oBAAoB;;;;;;CAMhC,CAAC"}
|
|
@@ -84,7 +84,7 @@ function applyInheritedSignalMetadata(signal, options) {
|
|
|
84
84
|
async function collectPageSignalsFromDocument(context, options) {
|
|
85
85
|
const inheritedFramePath = JSON.stringify(options?.framePath ?? []);
|
|
86
86
|
const inheritedFrameUrl = JSON.stringify(options?.frameUrl ?? '');
|
|
87
|
-
const observedSignals = await context.evaluate(String.raw `(() => {
|
|
87
|
+
const observedSignals = (await context.evaluate(String.raw `(() => {
|
|
88
88
|
const inheritedFramePath = ${inheritedFramePath};
|
|
89
89
|
const inheritedFrameUrl = ${inheritedFrameUrl};
|
|
90
90
|
const limit = ${DOM_SIGNAL_COLLECTION_LIMIT};
|
|
@@ -387,7 +387,7 @@ async function collectPageSignalsFromDocument(context, options) {
|
|
|
387
387
|
}
|
|
388
388
|
|
|
389
389
|
return signals;
|
|
390
|
-
})()`);
|
|
390
|
+
})()`));
|
|
391
391
|
if (!Array.isArray(observedSignals)) {
|
|
392
392
|
return [];
|
|
393
393
|
}
|
|
@@ -3,8 +3,9 @@ import type { DomObservedTarget } from './observe-inventory.js';
|
|
|
3
3
|
export declare const OUTPUT_LEADING_TARGET_LIMIT = 20;
|
|
4
4
|
export declare function selectScopesForOutput(scopes: ReadonlyArray<SurfaceDescriptor>, targets: ReadonlyArray<Pick<TargetDescriptor, 'surfaceRef' | 'allowedActions' | 'acceptancePolicy'>>, preferredScopeRefs?: ReadonlySet<string>): SurfaceDescriptor[];
|
|
5
5
|
export declare function buildSurfaceRef(target: DomObservedTarget): string | undefined;
|
|
6
|
+
export declare function buildExplicitSurfaceRef(target: DomObservedTarget): string | undefined;
|
|
6
7
|
export declare function buildSyntheticFormSurfaceId(target: Pick<DomObservedTarget, 'pageSignature' | 'framePath' | 'frameUrl' | 'formSelector' | 'context'>): string | undefined;
|
|
7
|
-
export declare function surfaceReplacementKey(surface: Pick<SurfaceDescriptor, 'pageRef' | 'pageSignature' | 'framePath' | 'kind' | 'label'>): string;
|
|
8
|
+
export declare function surfaceReplacementKey(surface: Pick<SurfaceDescriptor, 'surfaceId' | 'pageRef' | 'pageSignature' | 'framePath' | 'kind' | 'label'>): string;
|
|
8
9
|
export declare function summarizeContext(context: TargetContext | undefined): string | undefined;
|
|
9
10
|
export declare function pushUniqueLocatorCandidate(acc: LocatorCandidate[], candidate: LocatorCandidate | undefined): void;
|
|
10
11
|
export declare function collectSurfaceDescriptors(pageRef: string, targets: ReadonlyArray<DomObservedTarget>): Omit<SurfaceDescriptor, "ref">[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe-surfaces.d.ts","sourceRoot":"","sources":["../../src/commands/observe-surfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EAChB,iBAAiB,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MAAM,GAAG,SAAS,CA8BvF;AAED,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,gBAAgB,EAAE,EACvB,SAAS,EAAE,gBAAgB,GAAG,SAAS,GACtC,IAAI,CAON;AAqGD,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,aAAa,CAAC,iBAAiB,CAAC,oCA4F1C"}
|
|
@@ -25,6 +25,17 @@ const SNAPSHOT_SCOPE_KINDS = new Set([
|
|
|
25
25
|
'sticky-panel',
|
|
26
26
|
]);
|
|
27
27
|
export const OUTPUT_LEADING_TARGET_LIMIT = 20;
|
|
28
|
+
const EXPLICIT_PARENT_SCOPE_KINDS = new Set(HIGH_SIGNAL_SCOPE_KINDS);
|
|
29
|
+
function collectLinkedScopeRefsForOutput(targets) {
|
|
30
|
+
const linkedScopeRefs = new Set();
|
|
31
|
+
for (const target of targets) {
|
|
32
|
+
const surfaceRef = target.surfaceRef;
|
|
33
|
+
if (typeof surfaceRef === 'string' && surfaceRef.length > 0) {
|
|
34
|
+
linkedScopeRefs.add(surfaceRef);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return linkedScopeRefs;
|
|
38
|
+
}
|
|
28
39
|
function inferExtractScopeLifetime(kind, locatorCandidates) {
|
|
29
40
|
const normalizedKind = (kind ?? '').trim().toLowerCase();
|
|
30
41
|
if (SNAPSHOT_SCOPE_KINDS.has(normalizedKind)) {
|
|
@@ -39,10 +50,7 @@ export function selectScopesForOutput(scopes, targets, preferredScopeRefs) {
|
|
|
39
50
|
if (scopes.length === 0) {
|
|
40
51
|
return [];
|
|
41
52
|
}
|
|
42
|
-
const linkedScopeRefs =
|
|
43
|
-
.slice(0, OUTPUT_LEADING_TARGET_LIMIT)
|
|
44
|
-
.map((target) => target.surfaceRef)
|
|
45
|
-
.filter((value) => typeof value === 'string' && value.length > 0));
|
|
53
|
+
const linkedScopeRefs = collectLinkedScopeRefsForOutput(targets);
|
|
46
54
|
const explicitlyPreferredScopeRefs = new Set([...(preferredScopeRefs ?? [])].filter((value) => typeof value === 'string' && value.length > 0));
|
|
47
55
|
const scopeByRef = new Map(scopes.map((scope) => [scope.ref, scope]));
|
|
48
56
|
const includedScopeRefs = new Set([...linkedScopeRefs, ...explicitlyPreferredScopeRefs]);
|
|
@@ -52,8 +60,13 @@ export function selectScopesForOutput(scopes, targets, preferredScopeRefs) {
|
|
|
52
60
|
if (includedScopeRefs.has(parentSurfaceRef)) {
|
|
53
61
|
break;
|
|
54
62
|
}
|
|
63
|
+
const parentScope = scopeByRef.get(parentSurfaceRef);
|
|
64
|
+
const parentKind = (parentScope?.kind ?? '').toLowerCase();
|
|
65
|
+
if (!EXPLICIT_PARENT_SCOPE_KINDS.has(parentKind)) {
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
55
68
|
includedScopeRefs.add(parentSurfaceRef);
|
|
56
|
-
parentSurfaceRef =
|
|
69
|
+
parentSurfaceRef = parentScope?.parentSurfaceRef;
|
|
57
70
|
}
|
|
58
71
|
}
|
|
59
72
|
const scored = scopes
|
|
@@ -94,18 +107,42 @@ export function selectScopesForOutput(scopes, targets, preferredScopeRefs) {
|
|
|
94
107
|
}
|
|
95
108
|
return [];
|
|
96
109
|
}
|
|
97
|
-
|
|
98
|
-
if (!
|
|
110
|
+
function buildStableSurfaceId(input) {
|
|
111
|
+
if (!input.surfaceKind && !input.surfaceSelector && !input.surfaceLabel) {
|
|
99
112
|
return undefined;
|
|
100
113
|
}
|
|
101
|
-
const frameKey =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
114
|
+
const frameKey = input.framePath?.join('>') ??
|
|
115
|
+
(normalizeSurfaceText(input.frameUrl) ? `url:${normalizeSurfaceText(input.frameUrl)}` : 'top');
|
|
116
|
+
const pageKey = normalizeSurfaceText(input.pageSignature) ?? 'unknown-page';
|
|
117
|
+
const selectorKey = normalizeSurfaceText(input.surfaceSelector);
|
|
118
|
+
if (selectorKey) {
|
|
119
|
+
return `${pageKey}|${frameKey}|surface|${selectorKey}`;
|
|
120
|
+
}
|
|
121
|
+
const kindKey = normalizeSurfaceText(input.surfaceKind)?.toLowerCase() ?? 'surface';
|
|
122
|
+
const labelKey = normalizeSurfaceText(input.surfaceLabel)?.toLowerCase();
|
|
123
|
+
return labelKey
|
|
124
|
+
? `${pageKey}|${frameKey}|${kindKey}|${labelKey}`
|
|
125
|
+
: `${pageKey}|${frameKey}|${kindKey}`;
|
|
126
|
+
}
|
|
127
|
+
export function buildSurfaceRef(target) {
|
|
128
|
+
return buildStableSurfaceId({
|
|
129
|
+
pageSignature: target.pageSignature,
|
|
130
|
+
framePath: target.framePath,
|
|
131
|
+
frameUrl: target.frameUrl,
|
|
132
|
+
surfaceKind: target.surfaceKind,
|
|
133
|
+
surfaceSelector: target.surfaceSelector,
|
|
134
|
+
surfaceLabel: target.surfaceLabel,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
export function buildExplicitSurfaceRef(target) {
|
|
138
|
+
return buildStableSurfaceId({
|
|
139
|
+
pageSignature: target.pageSignature,
|
|
140
|
+
framePath: target.framePath,
|
|
141
|
+
frameUrl: target.frameUrl,
|
|
142
|
+
surfaceKind: target.explicitSurfaceKind,
|
|
143
|
+
surfaceSelector: target.explicitSurfaceSelector,
|
|
144
|
+
surfaceLabel: target.explicitSurfaceLabel,
|
|
145
|
+
});
|
|
109
146
|
}
|
|
110
147
|
function normalizeSurfaceText(value) {
|
|
111
148
|
const normalized = value?.replace(/\s+/g, ' ').trim();
|
|
@@ -146,6 +183,12 @@ export function surfaceReplacementKey(surface) {
|
|
|
146
183
|
const frameKey = surface.framePath?.join('>') ?? 'top';
|
|
147
184
|
const kindKey = (surface.kind ?? 'surface').toLowerCase();
|
|
148
185
|
const labelKey = (surface.label ?? '').trim().toLowerCase();
|
|
186
|
+
if (HIGH_SIGNAL_SCOPE_KINDS.has(kindKey) && labelKey) {
|
|
187
|
+
return `${pageKey}|${frameKey}|${kindKey}|${labelKey}`;
|
|
188
|
+
}
|
|
189
|
+
if (surface.surfaceId?.trim()) {
|
|
190
|
+
return surface.surfaceId.trim();
|
|
191
|
+
}
|
|
149
192
|
return `${pageKey}|${frameKey}|${kindKey}|${labelKey}`;
|
|
150
193
|
}
|
|
151
194
|
export function summarizeContext(context) {
|
|
@@ -209,8 +252,16 @@ function surfaceRoleFromKind(kind) {
|
|
|
209
252
|
}
|
|
210
253
|
}
|
|
211
254
|
function collectSurfaceLocatorCandidates(target) {
|
|
255
|
+
return collectSurfaceLocatorCandidatesFromInputs({
|
|
256
|
+
surfaceKind: target.surfaceKind,
|
|
257
|
+
surfaceLabel: target.surfaceLabel,
|
|
258
|
+
surfaceSelector: target.surfaceSelector,
|
|
259
|
+
surfaceSelectors: target.surfaceSelectors,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
function collectSurfaceLocatorCandidatesFromInputs(input) {
|
|
212
263
|
const candidates = [];
|
|
213
|
-
const selectors = [
|
|
264
|
+
const selectors = [input.surfaceSelector, ...(input.surfaceSelectors ?? [])].filter((value) => typeof value === 'string' && value.length > 0);
|
|
214
265
|
for (const selector of selectors) {
|
|
215
266
|
pushUniqueLocatorCandidate(candidates, {
|
|
216
267
|
strategy: selector.startsWith('xpath=') ? 'xpath' : 'css',
|
|
@@ -218,15 +269,39 @@ function collectSurfaceLocatorCandidates(target) {
|
|
|
218
269
|
scope: 'root',
|
|
219
270
|
});
|
|
220
271
|
}
|
|
221
|
-
const surfaceRole = surfaceRoleFromKind(
|
|
272
|
+
const surfaceRole = surfaceRoleFromKind(input.surfaceKind);
|
|
222
273
|
if (surfaceRole) {
|
|
223
|
-
pushUniqueLocatorCandidate(candidates,
|
|
224
|
-
? { strategy: 'role', value: surfaceRole, name:
|
|
274
|
+
pushUniqueLocatorCandidate(candidates, input.surfaceLabel
|
|
275
|
+
? { strategy: 'role', value: surfaceRole, name: input.surfaceLabel }
|
|
225
276
|
: undefined);
|
|
226
|
-
pushUniqueLocatorCandidate(candidates, {
|
|
277
|
+
pushUniqueLocatorCandidate(candidates, {
|
|
278
|
+
strategy: 'role',
|
|
279
|
+
value: surfaceRole,
|
|
280
|
+
});
|
|
227
281
|
}
|
|
228
282
|
return candidates;
|
|
229
283
|
}
|
|
284
|
+
function upsertSurfaceDescriptor(descriptors, surfaceId, descriptor) {
|
|
285
|
+
const existing = descriptors.get(surfaceId);
|
|
286
|
+
const locatorCandidates = existing ? [...existing.locatorCandidates] : [];
|
|
287
|
+
for (const candidate of descriptor.locatorCandidates) {
|
|
288
|
+
pushUniqueLocatorCandidate(locatorCandidates, candidate);
|
|
289
|
+
}
|
|
290
|
+
const kind = existing?.kind ?? descriptor.kind ?? 'surface';
|
|
291
|
+
descriptors.set(surfaceId, {
|
|
292
|
+
...descriptor,
|
|
293
|
+
locatorCandidates,
|
|
294
|
+
kind,
|
|
295
|
+
label: existing?.label && existing.label !== 'Active surface'
|
|
296
|
+
? existing.label
|
|
297
|
+
: (descriptor.label ?? existing?.label ?? 'Active surface'),
|
|
298
|
+
createdAt: existing?.createdAt ?? descriptor.createdAt,
|
|
299
|
+
pageSignature: existing?.pageSignature ?? descriptor.pageSignature,
|
|
300
|
+
framePath: existing?.framePath ?? descriptor.framePath,
|
|
301
|
+
frameUrl: existing?.frameUrl ?? descriptor.frameUrl,
|
|
302
|
+
extractScopeLifetime: inferExtractScopeLifetime(kind, locatorCandidates),
|
|
303
|
+
});
|
|
304
|
+
}
|
|
230
305
|
export function collectSurfaceDescriptors(pageRef, targets) {
|
|
231
306
|
const descriptors = new Map();
|
|
232
307
|
for (const target of targets) {
|
|
@@ -234,36 +309,59 @@ export function collectSurfaceDescriptors(pageRef, targets) {
|
|
|
234
309
|
if (!surfaceId) {
|
|
235
310
|
continue;
|
|
236
311
|
}
|
|
237
|
-
|
|
238
|
-
const locatorCandidates = existing ? [...existing.locatorCandidates] : [];
|
|
239
|
-
for (const candidate of collectSurfaceLocatorCandidates(target)) {
|
|
240
|
-
pushUniqueLocatorCandidate(locatorCandidates, candidate);
|
|
241
|
-
}
|
|
242
|
-
descriptors.set(surfaceId, {
|
|
312
|
+
upsertSurfaceDescriptor(descriptors, surfaceId, {
|
|
243
313
|
surfaceId,
|
|
244
314
|
pageRef,
|
|
245
|
-
framePath:
|
|
246
|
-
frameUrl:
|
|
247
|
-
kind:
|
|
248
|
-
label:
|
|
249
|
-
? existing.label
|
|
250
|
-
: (target.surfaceLabel ?? target.surfaceKind ?? existing?.label ?? 'Active surface'),
|
|
315
|
+
framePath: target.framePath,
|
|
316
|
+
frameUrl: target.frameUrl,
|
|
317
|
+
kind: target.surfaceKind ?? 'surface',
|
|
318
|
+
label: target.surfaceLabel ?? target.surfaceKind ?? 'Active surface',
|
|
251
319
|
lifecycle: 'live',
|
|
252
320
|
availability: { state: 'available' },
|
|
253
|
-
locatorCandidates,
|
|
254
|
-
createdAt:
|
|
255
|
-
pageSignature:
|
|
256
|
-
extractScopeLifetime:
|
|
321
|
+
locatorCandidates: collectSurfaceLocatorCandidates(target),
|
|
322
|
+
createdAt: Date.now(),
|
|
323
|
+
pageSignature: target.pageSignature,
|
|
324
|
+
extractScopeLifetime: undefined,
|
|
257
325
|
});
|
|
258
326
|
}
|
|
259
327
|
for (const target of targets) {
|
|
328
|
+
const explicitSurfaceId = buildExplicitSurfaceRef(target);
|
|
329
|
+
if (!explicitSurfaceId || explicitSurfaceId === target.surfaceRef) {
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
upsertSurfaceDescriptor(descriptors, explicitSurfaceId, {
|
|
333
|
+
surfaceId: explicitSurfaceId,
|
|
334
|
+
pageRef,
|
|
335
|
+
framePath: target.framePath,
|
|
336
|
+
frameUrl: target.frameUrl,
|
|
337
|
+
kind: target.explicitSurfaceKind ?? 'surface',
|
|
338
|
+
label: target.explicitSurfaceLabel ??
|
|
339
|
+
target.explicitFallbackSurfaceLabel ??
|
|
340
|
+
target.explicitSurfaceKind ??
|
|
341
|
+
'Active surface',
|
|
342
|
+
lifecycle: 'live',
|
|
343
|
+
availability: { state: 'available' },
|
|
344
|
+
locatorCandidates: collectSurfaceLocatorCandidatesFromInputs({
|
|
345
|
+
surfaceKind: target.explicitSurfaceKind,
|
|
346
|
+
surfaceLabel: target.explicitSurfaceLabel ?? target.explicitFallbackSurfaceLabel,
|
|
347
|
+
surfaceSelector: target.explicitSurfaceSelector,
|
|
348
|
+
surfaceSelectors: target.explicitSurfaceSelectors,
|
|
349
|
+
}),
|
|
350
|
+
createdAt: Date.now(),
|
|
351
|
+
pageSignature: target.pageSignature,
|
|
352
|
+
extractScopeLifetime: undefined,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
for (const target of targets) {
|
|
356
|
+
if ((target.explicitSurfaceKind ?? '').trim().toLowerCase() === 'form') {
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
260
359
|
const surfaceId = buildSyntheticFormSurfaceId(target);
|
|
261
360
|
if (!surfaceId) {
|
|
262
361
|
continue;
|
|
263
362
|
}
|
|
264
|
-
const existing = descriptors.get(surfaceId);
|
|
265
|
-
const locatorCandidates = existing ? [...existing.locatorCandidates] : [];
|
|
266
363
|
const formSelector = target.formSelector?.trim();
|
|
364
|
+
const locatorCandidates = [];
|
|
267
365
|
if (formSelector) {
|
|
268
366
|
pushUniqueLocatorCandidate(locatorCandidates, {
|
|
269
367
|
strategy: formSelector.startsWith('xpath=') ? 'xpath' : 'css',
|
|
@@ -271,19 +369,19 @@ export function collectSurfaceDescriptors(pageRef, targets) {
|
|
|
271
369
|
scope: 'root',
|
|
272
370
|
});
|
|
273
371
|
}
|
|
274
|
-
descriptors
|
|
372
|
+
upsertSurfaceDescriptor(descriptors, surfaceId, {
|
|
275
373
|
surfaceId,
|
|
276
374
|
pageRef,
|
|
277
|
-
framePath:
|
|
278
|
-
frameUrl:
|
|
375
|
+
framePath: target.framePath,
|
|
376
|
+
frameUrl: target.frameUrl,
|
|
279
377
|
kind: 'form',
|
|
280
|
-
label:
|
|
378
|
+
label: semanticFormContextLabel(target) ?? 'Form',
|
|
281
379
|
lifecycle: 'live',
|
|
282
380
|
availability: { state: 'available' },
|
|
283
381
|
locatorCandidates,
|
|
284
|
-
createdAt:
|
|
285
|
-
pageSignature:
|
|
286
|
-
extractScopeLifetime:
|
|
382
|
+
createdAt: Date.now(),
|
|
383
|
+
pageSignature: target.pageSignature,
|
|
384
|
+
extractScopeLifetime: undefined,
|
|
287
385
|
});
|
|
288
386
|
}
|
|
289
387
|
return [...descriptors.values()];
|
|
@@ -60,12 +60,16 @@ export type ObserveFailureResult = {
|
|
|
60
60
|
export type ObserveResult = ObserveSuccessResult | ObserveFailureResult;
|
|
61
61
|
export declare const __testDomTargetCollection: {
|
|
62
62
|
collectDomTargetsFromDocument: (context: {
|
|
63
|
-
evaluate
|
|
63
|
+
evaluate(pageFunction: string): Promise<unknown>;
|
|
64
64
|
}, options?: import("./observe-inventory.js").DomTargetCollectionOptions & {
|
|
65
65
|
framePath?: string[];
|
|
66
66
|
frameUrl?: string;
|
|
67
67
|
pageFormSelector?: string;
|
|
68
|
+
debugStructuralProfileStats?: boolean;
|
|
68
69
|
}) => Promise<import("./observe-inventory.js").DomObservedTarget[]>;
|
|
70
|
+
collectDomTargetsDebugFromDocument: (context: {
|
|
71
|
+
evaluate(pageFunction: string): Promise<unknown>;
|
|
72
|
+
}, options?: import("./observe-inventory.js").DomTargetCollectionOptions) => Promise<import("./observe-inventory.js").DomTargetCollectionDebugResult>;
|
|
69
73
|
inferStructuredCellVariantFromEvidence: typeof import("./observe-inventory.js").inferStructuredCellVariantFromEvidence;
|
|
70
74
|
inferDirectionalControlFallbackFromEvidence: typeof import("./observe-inventory.js").inferDirectionalControlFallbackFromEvidence;
|
|
71
75
|
locatorDomSignatureScript: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../../src/commands/observe.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK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