@enricai/barnacle 1.9.9 → 1.9.10
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/dist/scraper/flow-runner.d.ts +65 -1
- package/dist/scraper/flow-runner.d.ts.map +1 -1
- package/dist/scraper/flow-runner.js +106 -11
- package/dist/scraper/flow-runner.js.map +1 -1
- package/dist/scraper/phantom-click.d.ts +26 -0
- package/dist/scraper/phantom-click.d.ts.map +1 -1
- package/dist/scraper/phantom-click.js +17 -1
- package/dist/scraper/phantom-click.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,12 +11,38 @@ export interface PhantomClickSnapshot {
|
|
|
11
11
|
url: string;
|
|
12
12
|
/** `document.body.outerHTML.length`. */
|
|
13
13
|
bodyHtmlLength: number;
|
|
14
|
+
/**
|
|
15
|
+
* Fingerprint of client-side selection state across selection-bearing
|
|
16
|
+
* controls — `aria-pressed`/`aria-checked`/`aria-selected`, `data-state`
|
|
17
|
+
* (excluding `open`/`closed` disclosure values), `data-selected`/
|
|
18
|
+
* `data-checked`, and a selected/active/checked class-token hit on an
|
|
19
|
+
* interactive element. A multi-select toggle (React state flip) moves this
|
|
20
|
+
* without moving network, URL, or byte size — often a NEGATIVE byte delta
|
|
21
|
+
* (an `aria-pressed="false"`→`"true"` flip shrinks the HTML), which the
|
|
22
|
+
* byte-floor branch can never catch. A pure `disabled`→`enabled` gate with
|
|
23
|
+
* no accompanying selection-marker change is intentionally NOT tracked.
|
|
24
|
+
* Optional so pre-`selectionStateSignature` snapshots (and this module's own
|
|
25
|
+
* tests) stay valid; a defined pre/post pair that differs is a real effect
|
|
26
|
+
* (see {@link classifyPhantomClick}). The producer is `snapshotPage`'s
|
|
27
|
+
* `DOM_SNAPSHOT_EXPR` in `flow-runner.ts`, which documents the exact shape.
|
|
28
|
+
*/
|
|
29
|
+
selectionStateSignature?: string;
|
|
14
30
|
}
|
|
15
31
|
export interface PhantomClickAttempt {
|
|
16
32
|
/** Stagehand's own verdict for the attempt — did it believe it acted? */
|
|
17
33
|
actResultSuccess: boolean | null;
|
|
18
34
|
pre: PhantomClickSnapshot;
|
|
19
35
|
post: PhantomClickSnapshot;
|
|
36
|
+
/**
|
|
37
|
+
* True when the step is submit-shaped (a final/submit click). A submit must
|
|
38
|
+
* show a REAL effect (network/URL) to count as effective — a mere selection-
|
|
39
|
+
* state flip (e.g. the submit button toggling its own `aria-pressed`, or a
|
|
40
|
+
* validation render nudging some control) must NOT lift the verdict off
|
|
41
|
+
* `phantom`, because the cascade's submit-escalation to `deep-submit-locator`
|
|
42
|
+
* keys on a `phantom` verdict here (see `executeStepWithHealing`). Optional
|
|
43
|
+
* so non-submit callers and existing tests are unchanged; defaults to false.
|
|
44
|
+
*/
|
|
45
|
+
isSubmitShapedStep?: boolean;
|
|
20
46
|
}
|
|
21
47
|
export type PhantomClickVerdict =
|
|
22
48
|
/** Stagehand reported success but pre/post shows no observable effect — a no-op click. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phantom-click.d.ts","sourceRoot":"","sources":["../../src/scraper/phantom-click.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,qFAAqF;AACrF,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,wCAAwC;IACxC,cAAc,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"phantom-click.d.ts","sourceRoot":"","sources":["../../src/scraper/phantom-click.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,qFAAqF;AACrF,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,wCAAwC;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB;;;;;;;;;;;;;;OAcG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,mBAAmB;IAClC,yEAAyE;IACzE,gBAAgB,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,GAAG,EAAE,oBAAoB,CAAC;IAC1B,IAAI,EAAE,oBAAoB,CAAC;IAC3B;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,MAAM,mBAAmB;AAC7B,0FAA0F;AACxF,SAAS;AACX,mEAAmE;GACjE,WAAW;AACb,kKAAkK;GAChK,YAAY,CAAC;AAEjB;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,mBAAmB,CA2BtF"}
|
|
@@ -31,7 +31,23 @@ function classifyPhantomClick(attempt) {
|
|
|
31
31
|
const networkDelta = attempt.post.networkCount - attempt.pre.networkCount;
|
|
32
32
|
const bytesDelta = attempt.post.bodyHtmlLength - attempt.pre.bodyHtmlLength;
|
|
33
33
|
const urlChanged = attempt.post.url !== attempt.pre.url;
|
|
34
|
-
|
|
34
|
+
// A client-side selection toggle (aria-pressed/checked/selected, data-state,
|
|
35
|
+
// or a selected/active/checked class) is a real effect regardless of byte
|
|
36
|
+
// size — the byte floor below rejects it because the delta is trivial or
|
|
37
|
+
// negative. Only credit when BOTH signatures are defined (an older snapshot
|
|
38
|
+
// without the field mustn't read undefined === undefined as a change) and
|
|
39
|
+
// they differ. NOT on a submit-shaped step: a submit must prove itself via
|
|
40
|
+
// network/URL, and letting a stray selection flip mark it "effective" would
|
|
41
|
+
// defeat the cascade's phantom-verdict-driven escalation to the deep submit
|
|
42
|
+
// locator.
|
|
43
|
+
const selectionStateChanged = !attempt.isSubmitShapedStep &&
|
|
44
|
+
attempt.pre.selectionStateSignature !== undefined &&
|
|
45
|
+
attempt.post.selectionStateSignature !== undefined &&
|
|
46
|
+
attempt.pre.selectionStateSignature !== attempt.post.selectionStateSignature;
|
|
47
|
+
const hasEffect = networkDelta !== 0 ||
|
|
48
|
+
urlChanged ||
|
|
49
|
+
selectionStateChanged ||
|
|
50
|
+
bytesDelta >= exports.TRIVIAL_DOM_DELTA_BYTES;
|
|
35
51
|
return hasEffect ? "effective" : "phantom";
|
|
36
52
|
}
|
|
37
53
|
//# sourceMappingURL=phantom-click.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phantom-click.js","sourceRoot":"","sources":["../../src/scraper/phantom-click.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;
|
|
1
|
+
{"version":3,"file":"phantom-click.js","sourceRoot":"","sources":["../../src/scraper/phantom-click.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAmDH;;;;;;GAMG;AACU,QAAA,uBAAuB,GAAG,GAAG,CAAC;AAE3C;;;;;;;GAOG;AACH,8BAAqC,OAA4B;IAC/D,IAAI,OAAO,CAAC,gBAAgB,KAAK,IAAI;QAAE,OAAO,YAAY,CAAC;IAE3D,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IAC1E,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAC5E,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IACxD,6EAA6E;IAC7E,0EAA0E;IAC1E,yEAAyE;IACzE,4EAA4E;IAC5E,0EAA0E;IAC1E,2EAA2E;IAC3E,4EAA4E;IAC5E,4EAA4E;IAC5E,WAAW;IACX,MAAM,qBAAqB,GACzB,CAAC,OAAO,CAAC,kBAAkB;QAC3B,OAAO,CAAC,GAAG,CAAC,uBAAuB,KAAK,SAAS;QACjD,OAAO,CAAC,IAAI,CAAC,uBAAuB,KAAK,SAAS;QAClD,OAAO,CAAC,GAAG,CAAC,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC;IAE/E,MAAM,SAAS,GACb,YAAY,KAAK,CAAC;QAClB,UAAU;QACV,qBAAqB;QACrB,UAAU,IAAI,QAAA,uBAAuB,CAAC;IACxC,OAAO,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enricai/barnacle",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.10",
|
|
4
4
|
"description": "Site-agnostic browser automation engine. POST a structured payload to a typed endpoint; Barnacle drives a Steel + Stagehand session through the target site and returns a structured result.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Enricai",
|