@nuanu-ai/agentbrowse 0.2.40 → 0.2.41
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.
|
@@ -5,6 +5,7 @@ type ClickRetryOptions = {
|
|
|
5
5
|
beforeRetry?: () => Promise<void>;
|
|
6
6
|
guards?: ActionExecutionGuards;
|
|
7
7
|
clickActivationStrategy?: ClickActivationStrategy;
|
|
8
|
+
focusStrategy?: 'iframe-only' | 'active-control';
|
|
8
9
|
};
|
|
9
10
|
export declare function applyEditableClickAction(page: Page, locator: Locator, attempts: string[], options?: ClickRetryOptions): Promise<boolean>;
|
|
10
11
|
export declare function applyTriggerAction(page: Page, locator: Locator, attempts: string[], options?: ClickRetryOptions): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"click-action-executor.d.ts","sourceRoot":"","sources":["../../src/commands/click-action-executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAMrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAA2B,KAAK,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAEnG,KAAK,iBAAiB,GAAG;IACvB,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"click-action-executor.d.ts","sourceRoot":"","sources":["../../src/commands/click-action-executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAMrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAA2B,KAAK,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAEnG,KAAK,iBAAiB,GAAG;IACvB,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAC/B,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAClD,aAAa,CAAC,EAAE,aAAa,GAAG,gBAAgB,CAAC;CAClD,CAAC;AA0LF,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,OAAO,CAAC,CAKlB;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,OAAO,CAAC,CAKlB"}
|
|
@@ -1,21 +1,74 @@
|
|
|
1
1
|
import { LOCATOR_CLICK_TIMEOUT_MS, dismissBlockingOverlay, looksLikeOverlayInterference, } from './action-executor-helpers.js';
|
|
2
2
|
import { runActionExecutionGuard } from './action-execution-guards.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
const DEFAULT_FOCUS_ALIGNMENT_RESULT = {
|
|
4
|
+
focused: false,
|
|
5
|
+
kind: null,
|
|
6
|
+
};
|
|
7
|
+
function normalizeFocusAlignmentResult(result) {
|
|
8
|
+
if (result === true) {
|
|
9
|
+
return {
|
|
10
|
+
focused: true,
|
|
11
|
+
kind: 'iframe',
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
if (!result || typeof result !== 'object') {
|
|
15
|
+
return DEFAULT_FOCUS_ALIGNMENT_RESULT;
|
|
16
|
+
}
|
|
17
|
+
const candidate = result;
|
|
18
|
+
const focused = candidate.focused === true;
|
|
19
|
+
if (!focused) {
|
|
20
|
+
return DEFAULT_FOCUS_ALIGNMENT_RESULT;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
focused: true,
|
|
24
|
+
kind: candidate.kind === 'iframe' || candidate.kind === 'control' ? candidate.kind : 'control',
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
async function alignTargetFocusBeforeClick(locator, attempts, focusStrategy) {
|
|
28
|
+
const focusProbeResult = await (focusStrategy === 'iframe-only'
|
|
29
|
+
? locator.evaluate((element) => {
|
|
30
|
+
if (!(element instanceof HTMLElement)) {
|
|
31
|
+
return { focused: false, kind: null };
|
|
32
|
+
}
|
|
33
|
+
const active = element.ownerDocument.activeElement;
|
|
34
|
+
if (!(active instanceof HTMLElement) || active === element) {
|
|
35
|
+
return { focused: false, kind: null };
|
|
36
|
+
}
|
|
37
|
+
if (active === element.ownerDocument.body ||
|
|
38
|
+
active === element.ownerDocument.documentElement ||
|
|
39
|
+
!(active instanceof HTMLIFrameElement)) {
|
|
40
|
+
return { focused: false, kind: null };
|
|
41
|
+
}
|
|
42
|
+
element.focus();
|
|
43
|
+
return {
|
|
44
|
+
focused: element.ownerDocument.activeElement === element,
|
|
45
|
+
kind: 'iframe',
|
|
46
|
+
};
|
|
47
|
+
})
|
|
48
|
+
: locator.evaluate((element) => {
|
|
49
|
+
if (!(element instanceof HTMLElement)) {
|
|
50
|
+
return { focused: false, kind: null };
|
|
51
|
+
}
|
|
52
|
+
const active = element.ownerDocument.activeElement;
|
|
53
|
+
if (!(active instanceof HTMLElement) || active === element) {
|
|
54
|
+
return { focused: false, kind: null };
|
|
55
|
+
}
|
|
56
|
+
if (active === element.ownerDocument.body ||
|
|
57
|
+
active === element.ownerDocument.documentElement) {
|
|
58
|
+
return { focused: false, kind: null };
|
|
59
|
+
}
|
|
60
|
+
const kind = active instanceof HTMLIFrameElement ? 'iframe' : 'control';
|
|
61
|
+
element.focus();
|
|
62
|
+
return {
|
|
63
|
+
focused: element.ownerDocument.activeElement === element,
|
|
64
|
+
kind,
|
|
65
|
+
};
|
|
66
|
+
})).catch(() => DEFAULT_FOCUS_ALIGNMENT_RESULT);
|
|
67
|
+
const focusResult = normalizeFocusAlignmentResult(focusProbeResult);
|
|
68
|
+
if (focusResult.focused) {
|
|
69
|
+
attempts.push(focusResult.kind === 'iframe'
|
|
70
|
+
? 'locator.focus.handoff-from-iframe'
|
|
71
|
+
: 'locator.focus.before-click');
|
|
19
72
|
}
|
|
20
73
|
}
|
|
21
74
|
async function ensureLocatorRetryReady(locator, error, options) {
|
|
@@ -27,7 +80,7 @@ async function ensureLocatorRetryReady(locator, error, options) {
|
|
|
27
80
|
}
|
|
28
81
|
}
|
|
29
82
|
async function applyClickSequence(page, locator, attempts, options) {
|
|
30
|
-
await
|
|
83
|
+
await alignTargetFocusBeforeClick(locator, attempts, options?.focusStrategy ?? 'iframe-only');
|
|
31
84
|
if (options?.clickActivationStrategy === 'dom') {
|
|
32
85
|
await runActionExecutionGuard(options?.guards, 'click.evaluate.primary');
|
|
33
86
|
attempts.push('locator.evaluate.click.primary');
|
|
@@ -91,8 +144,14 @@ async function applyClickSequence(page, locator, attempts, options) {
|
|
|
91
144
|
}
|
|
92
145
|
}
|
|
93
146
|
export async function applyEditableClickAction(page, locator, attempts, options) {
|
|
94
|
-
return applyClickSequence(page, locator, attempts,
|
|
147
|
+
return applyClickSequence(page, locator, attempts, {
|
|
148
|
+
...options,
|
|
149
|
+
focusStrategy: options?.focusStrategy ?? 'iframe-only',
|
|
150
|
+
});
|
|
95
151
|
}
|
|
96
152
|
export async function applyTriggerAction(page, locator, attempts, options) {
|
|
97
|
-
return applyClickSequence(page, locator, attempts,
|
|
153
|
+
return applyClickSequence(page, locator, attempts, {
|
|
154
|
+
...options,
|
|
155
|
+
focusStrategy: options?.focusStrategy ?? 'active-control',
|
|
156
|
+
});
|
|
98
157
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-launcher.d.ts","sourceRoot":"","sources":["../../src/solver/browser-launcher.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAsB,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"browser-launcher.d.ts","sourceRoot":"","sources":["../../src/solver/browser-launcher.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAsB,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAkBjF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC,CAAC;AAuBF,wBAAsB,YAAY,CAChC,OAAO,EAAE,WAAW,EACpB,IAAI,CAAC,EAAE,aAAa,GACnB,OAAO,CAAC,aAAa,CAAC,CAmExB;AAkUD,wBAAgB,wBAAwB,CACtC,QAAQ,GAAE,MAAM,CAAC,QAA2B,EAC5C,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,EAAE,CAGV"}
|
|
@@ -9,6 +9,8 @@ const enhancedPuppeteer = puppeteerExtra;
|
|
|
9
9
|
const solverStealthPlugin = StealthPlugin();
|
|
10
10
|
// Some iframe-backed checkout flows break when this evasion runs on a connected real Chrome.
|
|
11
11
|
solverStealthPlugin.enabledEvasions.delete('iframe.contentWindow');
|
|
12
|
+
// We already pin the browser UA at launch time; this evasion races popup teardown on CI.
|
|
13
|
+
solverStealthPlugin.enabledEvasions.delete('user-agent-override');
|
|
12
14
|
enhancedPuppeteer.use(solverStealthPlugin);
|
|
13
15
|
const AUTO_CDP_PORT = 0;
|
|
14
16
|
const CDP_DISCOVERY_TIMEOUT_MS = 30_000;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuanu-ai/agentbrowse",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.41",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Browser automation CLI for AI agents: control a CDP browser, observe UI surfaces, act on refs, extract data, capture screenshots, complete protected fills, and solve captchas",
|
|
6
6
|
"keywords": [
|