@enricai/barnacle 1.12.78 → 1.12.80
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/api/helpers/reply.d.ts.map +1 -1
- package/dist/api/helpers/reply.js +5 -2
- package/dist/api/helpers/reply.js.map +1 -1
- package/dist/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -1
- package/dist/lib/llm/judge.d.ts.map +1 -1
- package/dist/lib/llm/judge.js +6 -1
- package/dist/lib/llm/judge.js.map +1 -1
- package/dist/lib/llm/judges/verify-step-advanced.d.ts +30 -0
- package/dist/lib/llm/judges/verify-step-advanced.d.ts.map +1 -0
- package/dist/lib/llm/judges/verify-step-advanced.js +62 -0
- package/dist/lib/llm/judges/verify-step-advanced.js.map +1 -0
- package/dist/lib/llm/judges/verify-submit.d.ts +7 -1
- package/dist/lib/llm/judges/verify-submit.d.ts.map +1 -1
- package/dist/lib/llm/judges/verify-submit.js +29 -8
- package/dist/lib/llm/judges/verify-submit.js.map +1 -1
- package/dist/lib/llm/schemas.d.ts +8 -0
- package/dist/lib/llm/schemas.d.ts.map +1 -1
- package/dist/lib/llm/schemas.js +21 -13
- package/dist/lib/llm/schemas.js.map +1 -1
- package/dist/lib/logging.d.ts +7 -0
- package/dist/lib/logging.d.ts.map +1 -1
- package/dist/lib/logging.js +19 -1
- package/dist/lib/logging.js.map +1 -1
- package/dist/lib/pii-redaction.d.ts +104 -0
- package/dist/lib/pii-redaction.d.ts.map +1 -0
- package/dist/lib/pii-redaction.js +397 -0
- package/dist/lib/pii-redaction.js.map +1 -0
- package/dist/lib/random.d.ts +3 -1
- package/dist/lib/random.d.ts.map +1 -1
- package/dist/lib/random.js +7 -2
- package/dist/lib/random.js.map +1 -1
- package/dist/lib/telemetry/beacon-capture.d.ts.map +1 -1
- package/dist/lib/telemetry/beacon-capture.js +2 -0
- package/dist/lib/telemetry/beacon-capture.js.map +1 -1
- package/dist/lib/telemetry/call-capture.d.ts.map +1 -1
- package/dist/lib/telemetry/call-capture.js +4 -1
- package/dist/lib/telemetry/call-capture.js.map +1 -1
- package/dist/lib/telemetry/submission-capture.d.ts +11 -1
- package/dist/lib/telemetry/submission-capture.d.ts.map +1 -1
- package/dist/lib/telemetry/submission-capture.js +32 -3
- package/dist/lib/telemetry/submission-capture.js.map +1 -1
- package/dist/plugins/config-plugin.d.ts +8 -0
- package/dist/plugins/config-plugin.d.ts.map +1 -1
- package/dist/plugins/config-plugin.js +6 -1
- package/dist/plugins/config-plugin.js.map +1 -1
- package/dist/plugins/discover.d.ts.map +1 -1
- package/dist/plugins/discover.js +2 -0
- package/dist/plugins/discover.js.map +1 -1
- package/dist/plugins/loader.d.ts.map +1 -1
- package/dist/plugins/loader.js +23 -6
- package/dist/plugins/loader.js.map +1 -1
- package/dist/scraper/actionable-visibility-expr.d.ts +12 -0
- package/dist/scraper/actionable-visibility-expr.d.ts.map +1 -0
- package/dist/scraper/actionable-visibility-expr.js +22 -0
- package/dist/scraper/actionable-visibility-expr.js.map +1 -0
- package/dist/scraper/active-page.d.ts +18 -0
- package/dist/scraper/active-page.d.ts.map +1 -0
- package/dist/scraper/active-page.js +53 -0
- package/dist/scraper/active-page.js.map +1 -0
- package/dist/scraper/browser-click-expr.d.ts +1 -1
- package/dist/scraper/browser-click-expr.d.ts.map +1 -1
- package/dist/scraper/browser-click-expr.js +2 -6
- package/dist/scraper/browser-click-expr.js.map +1 -1
- package/dist/scraper/click-settle.d.ts +19 -0
- package/dist/scraper/click-settle.d.ts.map +1 -0
- package/dist/scraper/click-settle.js +65 -0
- package/dist/scraper/click-settle.js.map +1 -0
- package/dist/scraper/deep-locator-candidates.d.ts +20 -1
- package/dist/scraper/deep-locator-candidates.d.ts.map +1 -1
- package/dist/scraper/deep-locator-candidates.js +110 -22
- package/dist/scraper/deep-locator-candidates.js.map +1 -1
- package/dist/scraper/deep-locator-scan.d.ts +12 -0
- package/dist/scraper/deep-locator-scan.d.ts.map +1 -1
- package/dist/scraper/deep-locator-scan.js +42 -13
- package/dist/scraper/deep-locator-scan.js.map +1 -1
- package/dist/scraper/errors.d.ts +10 -0
- package/dist/scraper/errors.d.ts.map +1 -1
- package/dist/scraper/errors.js +19 -1
- package/dist/scraper/errors.js.map +1 -1
- package/dist/scraper/flow-runner.d.ts +355 -6
- package/dist/scraper/flow-runner.d.ts.map +1 -1
- package/dist/scraper/flow-runner.js +2255 -350
- package/dist/scraper/flow-runner.js.map +1 -1
- package/dist/scraper/navigate.d.ts +3 -3
- package/dist/scraper/navigate.js +4 -4
- package/dist/scraper/navigate.js.map +1 -1
- package/dist/scraper/phantom-click.d.ts +34 -2
- package/dist/scraper/phantom-click.d.ts.map +1 -1
- package/dist/scraper/phantom-click.js +80 -6
- package/dist/scraper/phantom-click.js.map +1 -1
- package/dist/scraper/pool.d.ts.map +1 -1
- package/dist/scraper/pool.js +8 -1
- package/dist/scraper/pool.js.map +1 -1
- package/dist/scraper/quoted-spans.d.ts +35 -0
- package/dist/scraper/quoted-spans.d.ts.map +1 -0
- package/dist/scraper/quoted-spans.js +83 -0
- package/dist/scraper/quoted-spans.js.map +1 -0
- package/dist/scraper/retry.d.ts +1 -1
- package/dist/scraper/retry.d.ts.map +1 -1
- package/dist/scraper/retry.js +5 -1
- package/dist/scraper/retry.js.map +1 -1
- package/dist/scraper/session-browserbase.d.ts +4 -2
- package/dist/scraper/session-browserbase.d.ts.map +1 -1
- package/dist/scraper/session-browserbase.js +63 -20
- package/dist/scraper/session-browserbase.js.map +1 -1
- package/dist/scraper/session-shared.d.ts +5 -0
- package/dist/scraper/session-shared.d.ts.map +1 -1
- package/dist/scraper/session-shared.js.map +1 -1
- package/dist/scraper/session-steel.d.ts.map +1 -1
- package/dist/scraper/session-steel.js +16 -2
- package/dist/scraper/session-steel.js.map +1 -1
- package/dist/scraper/session-teardown.d.ts +31 -1
- package/dist/scraper/session-teardown.d.ts.map +1 -1
- package/dist/scraper/session-teardown.js +60 -4
- package/dist/scraper/session-teardown.js.map +1 -1
- package/dist/scraper/spa-readiness.d.ts +13 -1
- package/dist/scraper/spa-readiness.d.ts.map +1 -1
- package/dist/scraper/spa-readiness.js +31 -1
- package/dist/scraper/spa-readiness.js.map +1 -1
- package/dist/scraper/stagehand-guard.d.ts +8 -3
- package/dist/scraper/stagehand-guard.d.ts.map +1 -1
- package/dist/scraper/stagehand-guard.js +181 -13
- package/dist/scraper/stagehand-guard.js.map +1 -1
- package/dist/scraper/submit-control.d.ts +2 -2
- package/dist/scraper/submit-control.d.ts.map +1 -1
- package/dist/scraper/submit-control.js +5 -21
- package/dist/scraper/submit-control.js.map +1 -1
- package/dist/scraper/target-resolution-diagnostic.d.ts.map +1 -1
- package/dist/scraper/target-resolution-diagnostic.js +6 -11
- package/dist/scraper/target-resolution-diagnostic.js.map +1 -1
- package/dist/scraper/transient-provider-error.d.ts +19 -0
- package/dist/scraper/transient-provider-error.d.ts.map +1 -0
- package/dist/scraper/transient-provider-error.js +59 -0
- package/dist/scraper/transient-provider-error.js.map +1 -0
- package/dist/scraper/trusted-click.d.ts +122 -0
- package/dist/scraper/trusted-click.d.ts.map +1 -0
- package/dist/scraper/trusted-click.js +201 -0
- package/dist/scraper/trusted-click.js.map +1 -0
- package/dist/scraper/upload-affordance-expr.d.ts +33 -0
- package/dist/scraper/upload-affordance-expr.d.ts.map +1 -0
- package/dist/scraper/upload-affordance-expr.js +91 -0
- package/dist/scraper/upload-affordance-expr.js.map +1 -0
- package/dist/scripts/recon-browser.d.ts +30 -2
- package/dist/scripts/recon-browser.d.ts.map +1 -1
- package/dist/scripts/recon-browser.js +133 -27
- package/dist/scripts/recon-browser.js.map +1 -1
- package/dist/scripts/recon-capture-rebind.d.ts +11 -0
- package/dist/scripts/recon-capture-rebind.d.ts.map +1 -0
- package/dist/scripts/recon-capture-rebind.js +26 -0
- package/dist/scripts/recon-capture-rebind.js.map +1 -0
- package/dist/scripts/recon-generate.d.ts +159 -8
- package/dist/scripts/recon-generate.d.ts.map +1 -1
- package/dist/scripts/recon-generate.js +998 -182
- package/dist/scripts/recon-generate.js.map +1 -1
- package/dist/scripts/recon-shared.d.ts +7 -0
- package/dist/scripts/recon-shared.d.ts.map +1 -1
- package/dist/scripts/recon-shared.js +19 -0
- package/dist/scripts/recon-shared.js.map +1 -1
- package/dist/site-plugin.d.ts +8 -0
- package/dist/site-plugin.d.ts.map +1 -1
- package/dist/types/pii-redaction.d.ts +39 -0
- package/dist/types/pii-redaction.d.ts.map +1 -0
- package/dist/types/pii-redaction.js +3 -0
- package/dist/types/pii-redaction.js.map +1 -0
- package/package.json +14 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared apply-page navigation helper. Centralises the two-step pattern that
|
|
3
3
|
* every site browser-flow repeats: await the active Stagehand page, then
|
|
4
|
-
* navigate to the apply URL with
|
|
5
|
-
*
|
|
4
|
+
* navigate to the apply URL with domcontentloaded. Chatty pages never reach
|
|
5
|
+
* networkidle, so hydration is left to waitForSpaReady in the caller.
|
|
6
6
|
*
|
|
7
7
|
* Scripts that interleave CDP listener wiring between awaitActivePage and goto
|
|
8
8
|
* (recon-browser.ts, recon-generate.ts, etc.) must NOT use this helper — they
|
|
@@ -12,7 +12,7 @@ import type { Page, Stagehand } from "@browserbasehq/stagehand";
|
|
|
12
12
|
import type { MetricsCollector } from "../lib/dispatch-metrics";
|
|
13
13
|
/**
|
|
14
14
|
* Awaits the active Stagehand page and navigates to `url` with
|
|
15
|
-
* `waitUntil: "
|
|
15
|
+
* `waitUntil: "domcontentloaded"`. When a `MetricsCollector` is supplied, wraps
|
|
16
16
|
* the goto in a `"navigate"` step so the caller's metrics include navigation
|
|
17
17
|
* timing without each site having to repeat the bookkeeping.
|
|
18
18
|
*/
|
package/dist/scraper/navigate.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Shared apply-page navigation helper. Centralises the two-step pattern that
|
|
4
4
|
* every site browser-flow repeats: await the active Stagehand page, then
|
|
5
|
-
* navigate to the apply URL with
|
|
6
|
-
*
|
|
5
|
+
* navigate to the apply URL with domcontentloaded. Chatty pages never reach
|
|
6
|
+
* networkidle, so hydration is left to waitForSpaReady in the caller.
|
|
7
7
|
*
|
|
8
8
|
* Scripts that interleave CDP listener wiring between awaitActivePage and goto
|
|
9
9
|
* (recon-browser.ts, recon-generate.ts, etc.) must NOT use this helper — they
|
|
@@ -13,7 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
exports.navigateActivePage = navigateActivePage;
|
|
14
14
|
/**
|
|
15
15
|
* Awaits the active Stagehand page and navigates to `url` with
|
|
16
|
-
* `waitUntil: "
|
|
16
|
+
* `waitUntil: "domcontentloaded"`. When a `MetricsCollector` is supplied, wraps
|
|
17
17
|
* the goto in a `"navigate"` step so the caller's metrics include navigation
|
|
18
18
|
* timing without each site having to repeat the bookkeeping.
|
|
19
19
|
*/
|
|
@@ -21,7 +21,7 @@ async function navigateActivePage(stagehand, url, collector, timeoutMs) {
|
|
|
21
21
|
const page = await stagehand.context.awaitActivePage();
|
|
22
22
|
collector?.startStep("navigate");
|
|
23
23
|
await page.goto(url, {
|
|
24
|
-
waitUntil: "
|
|
24
|
+
waitUntil: "domcontentloaded",
|
|
25
25
|
...(timeoutMs !== undefined && { timeoutMs }),
|
|
26
26
|
});
|
|
27
27
|
collector?.endStep("success");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigate.js","sourceRoot":"","sources":["../../src/scraper/navigate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAMH;;;;;GAKG;AACI,KAAK,6BACV,SAAoB,EACpB,GAAW,EACX,SAA4B,EAC5B,SAAkB;IAElB,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;IACvD,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IACjC,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;QACnB,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"navigate.js","sourceRoot":"","sources":["../../src/scraper/navigate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAMH;;;;;GAKG;AACI,KAAK,6BACV,SAAoB,EACpB,GAAW,EACX,SAA4B,EAC5B,SAAkB;IAElB,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;IACvD,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IACjC,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;QACnB,SAAS,EAAE,kBAAkB;QAC7B,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,CAAC;KAC9C,CAAC,CAAC;IACH,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -11,6 +11,8 @@ export interface PhantomClickSnapshot {
|
|
|
11
11
|
url: string;
|
|
12
12
|
/** `document.body.outerHTML.length`. */
|
|
13
13
|
bodyHtmlLength: number;
|
|
14
|
+
/** `<len>:<first-200-chars>` of visible text, as in flow-runner's StepSnapshot. */
|
|
15
|
+
visibleTextSignature?: string;
|
|
14
16
|
}
|
|
15
17
|
export interface PhantomClickAttempt {
|
|
16
18
|
/** Stagehand's own verdict for the attempt — did it believe it acted? */
|
|
@@ -39,6 +41,14 @@ export interface PhantomClickAttempt {
|
|
|
39
41
|
* so non-submit callers and existing tests are unchanged; defaults to false.
|
|
40
42
|
*/
|
|
41
43
|
isSubmitShapedStep?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* True when a submit-shaped step is NOT the flow's final submit (e.g. an
|
|
46
|
+
* account-creation transition in a wizard). Such a step is credited when
|
|
47
|
+
* {@link hasPageAdvanced} holds even with no network/URL/title signal.
|
|
48
|
+
* Implies `isSubmitShapedStep`: a mid-flow submit is submit-shaped by
|
|
49
|
+
* definition, so callers need not set both for it to be held to submit rules.
|
|
50
|
+
*/
|
|
51
|
+
isMidFlowSubmitStep?: boolean;
|
|
42
52
|
/**
|
|
43
53
|
* Mirrors flow-runner's own `isPlausibleStepDestination` gate on its
|
|
44
54
|
* `urlChanged`/`retryUrlChanged` signals: false when the post-URL landed
|
|
@@ -83,9 +93,12 @@ export declare function splitIntoActionClauses(instruction: string): string[];
|
|
|
83
93
|
* mistaken for a step that is itself about signing in. Fails open (returns
|
|
84
94
|
* true) on an unparseable postUrl, matching {@link hasOriginOrPathChanged}'s
|
|
85
95
|
* own try/catch style, since an unparseable URL gives no basis for a
|
|
86
|
-
* sign-in-shaped veto.
|
|
96
|
+
* sign-in-shaped veto. When `preUrl` is given and the origin/path did not
|
|
97
|
+
* change, the page did not navigate, so no destination veto applies: a
|
|
98
|
+
* mid-flow account-creation step on an unchanged sign-in URL is still judged
|
|
99
|
+
* on its own evidence.
|
|
87
100
|
*/
|
|
88
|
-
export declare function isPlausibleStepDestination(stepInstruction: string, postUrl: string): boolean;
|
|
101
|
+
export declare function isPlausibleStepDestination(stepInstruction: string, postUrl: string, preUrl?: string): boolean;
|
|
89
102
|
export type PhantomClickVerdict =
|
|
90
103
|
/** Stagehand reported success but pre/post shows no observable effect — a no-op click. */
|
|
91
104
|
"phantom"
|
|
@@ -101,6 +114,25 @@ export type PhantomClickVerdict =
|
|
|
101
114
|
* phantom, not effective.
|
|
102
115
|
*/
|
|
103
116
|
export declare const TRIVIAL_DOM_DELTA_BYTES = 500;
|
|
117
|
+
/** Minimum visible-text length change for a mid-flow submit to count as a page advance. */
|
|
118
|
+
export declare const PAGE_ADVANCE_MIN_TEXT_LENGTH_DELTA = 100;
|
|
119
|
+
/** Relative visible-text length change that also counts as an advance on a short page. */
|
|
120
|
+
export declare const PAGE_ADVANCE_MIN_TEXT_LENGTH_RATIO = 0.3;
|
|
121
|
+
/** Floor under the relative rule so a tooltip on a tiny page is not an advance. */
|
|
122
|
+
export declare const PAGE_ADVANCE_MIN_RELATIVE_TEXT_LENGTH_DELTA = 30;
|
|
123
|
+
/** Word-set similarity below which the visible-text head counts as replaced. */
|
|
124
|
+
export declare const PAGE_ADVANCE_MAX_HEAD_SIMILARITY = 0.5;
|
|
125
|
+
/**
|
|
126
|
+
* Decides whether the page demonstrably advanced (a wizard step swapped
|
|
127
|
+
* content) from pre/post snapshots alone, so a network-free, URL-stable
|
|
128
|
+
* transition is still credited. Visible text is the evidence: a wizard swap
|
|
129
|
+
* can leave the HTML size nearly unchanged (same-size markup, different
|
|
130
|
+
* copy), so byte delta is deliberately not required. The text must have
|
|
131
|
+
* moved substantially — a large absolute or relative length change, or a
|
|
132
|
+
* head whose words were mostly replaced — so a tooltip or inline validation
|
|
133
|
+
* line (small, mostly-shared text) is not an advance.
|
|
134
|
+
*/
|
|
135
|
+
export declare function hasPageAdvanced(pre: PhantomClickSnapshot, post: PhantomClickSnapshot): boolean;
|
|
104
136
|
/**
|
|
105
137
|
* Classifies one cascade attempt as `phantom` (Stagehand claimed success but
|
|
106
138
|
* pre/post shows zero network, zero URL change, and only trivial DOM
|
|
@@ -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,mFAAmF;IACnF,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G;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,oBAAoB,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAmB9F;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,mBAAmB,CA0BtF"}
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
* same way (see recon-submit-phantom-click bug report).
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.TRIVIAL_DOM_DELTA_BYTES = exports.SIGN_IN_PATTERNS = void 0;
|
|
10
|
+
exports.PAGE_ADVANCE_MAX_HEAD_SIMILARITY = exports.PAGE_ADVANCE_MIN_RELATIVE_TEXT_LENGTH_DELTA = exports.PAGE_ADVANCE_MIN_TEXT_LENGTH_RATIO = exports.PAGE_ADVANCE_MIN_TEXT_LENGTH_DELTA = exports.TRIVIAL_DOM_DELTA_BYTES = exports.SIGN_IN_PATTERNS = void 0;
|
|
11
11
|
exports.hasOriginOrPathChanged = hasOriginOrPathChanged;
|
|
12
12
|
exports.splitIntoActionClauses = splitIntoActionClauses;
|
|
13
13
|
exports.isPlausibleStepDestination = isPlausibleStepDestination;
|
|
14
|
+
exports.hasPageAdvanced = hasPageAdvanced;
|
|
14
15
|
exports.classifyPhantomClick = classifyPhantomClick;
|
|
15
16
|
function originAndPathOf(url) {
|
|
16
17
|
try {
|
|
@@ -119,9 +120,16 @@ function splitIntoActionClauses(instruction) {
|
|
|
119
120
|
* mistaken for a step that is itself about signing in. Fails open (returns
|
|
120
121
|
* true) on an unparseable postUrl, matching {@link hasOriginOrPathChanged}'s
|
|
121
122
|
* own try/catch style, since an unparseable URL gives no basis for a
|
|
122
|
-
* sign-in-shaped veto.
|
|
123
|
+
* sign-in-shaped veto. When `preUrl` is given and the origin/path did not
|
|
124
|
+
* change, the page did not navigate, so no destination veto applies: a
|
|
125
|
+
* mid-flow account-creation step on an unchanged sign-in URL is still judged
|
|
126
|
+
* on its own evidence.
|
|
123
127
|
*/
|
|
124
|
-
function isPlausibleStepDestination(stepInstruction, postUrl) {
|
|
128
|
+
function isPlausibleStepDestination(stepInstruction, postUrl, preUrl) {
|
|
129
|
+
// A click that never left its page cannot have bounced to an auth gate; an
|
|
130
|
+
// account-creation step on a sign-in URL is the page's own transition.
|
|
131
|
+
if (preUrl !== undefined && !hasOriginOrPathChanged(preUrl, postUrl))
|
|
132
|
+
return true;
|
|
125
133
|
const pathname = (() => {
|
|
126
134
|
try {
|
|
127
135
|
return new URL(postUrl).pathname;
|
|
@@ -146,6 +154,65 @@ function isPlausibleStepDestination(stepInstruction, postUrl) {
|
|
|
146
154
|
* phantom, not effective.
|
|
147
155
|
*/
|
|
148
156
|
exports.TRIVIAL_DOM_DELTA_BYTES = 500;
|
|
157
|
+
/** Minimum visible-text length change for a mid-flow submit to count as a page advance. */
|
|
158
|
+
exports.PAGE_ADVANCE_MIN_TEXT_LENGTH_DELTA = 100;
|
|
159
|
+
/** Relative visible-text length change that also counts as an advance on a short page. */
|
|
160
|
+
exports.PAGE_ADVANCE_MIN_TEXT_LENGTH_RATIO = 0.3;
|
|
161
|
+
/** Floor under the relative rule so a tooltip on a tiny page is not an advance. */
|
|
162
|
+
exports.PAGE_ADVANCE_MIN_RELATIVE_TEXT_LENGTH_DELTA = 30;
|
|
163
|
+
/** Word-set similarity below which the visible-text head counts as replaced. */
|
|
164
|
+
exports.PAGE_ADVANCE_MAX_HEAD_SIMILARITY = 0.5;
|
|
165
|
+
function textLengthOf(signature) {
|
|
166
|
+
if (signature === undefined)
|
|
167
|
+
return null;
|
|
168
|
+
const match = /^(\d+):/.exec(signature);
|
|
169
|
+
return match ? Number(match[1]) : null;
|
|
170
|
+
}
|
|
171
|
+
function textHeadWords(signature) {
|
|
172
|
+
const head = signature.slice(signature.indexOf(":") + 1).toLowerCase();
|
|
173
|
+
return new Set(head.split(/\W+/).filter((w) => w !== ""));
|
|
174
|
+
}
|
|
175
|
+
function headWordSimilarity(pre, post) {
|
|
176
|
+
const preWords = textHeadWords(pre);
|
|
177
|
+
const postWords = textHeadWords(post);
|
|
178
|
+
const union = new Set([...preWords, ...postWords]);
|
|
179
|
+
if (union.size === 0)
|
|
180
|
+
return 1;
|
|
181
|
+
const shared = [...preWords].filter((w) => postWords.has(w)).length;
|
|
182
|
+
return shared / union.size;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Decides whether the page demonstrably advanced (a wizard step swapped
|
|
186
|
+
* content) from pre/post snapshots alone, so a network-free, URL-stable
|
|
187
|
+
* transition is still credited. Visible text is the evidence: a wizard swap
|
|
188
|
+
* can leave the HTML size nearly unchanged (same-size markup, different
|
|
189
|
+
* copy), so byte delta is deliberately not required. The text must have
|
|
190
|
+
* moved substantially — a large absolute or relative length change, or a
|
|
191
|
+
* head whose words were mostly replaced — so a tooltip or inline validation
|
|
192
|
+
* line (small, mostly-shared text) is not an advance.
|
|
193
|
+
*/
|
|
194
|
+
function hasPageAdvanced(pre, post) {
|
|
195
|
+
const preSig = pre.visibleTextSignature;
|
|
196
|
+
const postSig = post.visibleTextSignature;
|
|
197
|
+
if (preSig === undefined || postSig === undefined || preSig === postSig)
|
|
198
|
+
return false;
|
|
199
|
+
const preLen = textLengthOf(preSig);
|
|
200
|
+
const postLen = textLengthOf(postSig);
|
|
201
|
+
if (preLen === null || postLen === null)
|
|
202
|
+
return false;
|
|
203
|
+
const lengthDelta = Math.abs(postLen - preLen);
|
|
204
|
+
if (lengthDelta >= exports.PAGE_ADVANCE_MIN_TEXT_LENGTH_DELTA)
|
|
205
|
+
return true;
|
|
206
|
+
const similarity = headWordSimilarity(preSig, postSig);
|
|
207
|
+
// Identical head words mean whitespace/layout reflow, not new copy.
|
|
208
|
+
if (similarity === 1)
|
|
209
|
+
return false;
|
|
210
|
+
if (lengthDelta >= exports.PAGE_ADVANCE_MIN_RELATIVE_TEXT_LENGTH_DELTA &&
|
|
211
|
+
lengthDelta / Math.max(preLen, 1) >= exports.PAGE_ADVANCE_MIN_TEXT_LENGTH_RATIO) {
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
return similarity < exports.PAGE_ADVANCE_MAX_HEAD_SIMILARITY;
|
|
215
|
+
}
|
|
149
216
|
/**
|
|
150
217
|
* Classifies one cascade attempt as `phantom` (Stagehand claimed success but
|
|
151
218
|
* pre/post shows zero network, zero URL change, and only trivial DOM
|
|
@@ -162,12 +229,19 @@ function classifyPhantomClick(attempt) {
|
|
|
162
229
|
if (!attempt.destinationPlausible)
|
|
163
230
|
return "phantom";
|
|
164
231
|
const urlChanged = hasOriginOrPathChanged(attempt.pre.url, attempt.post.url);
|
|
232
|
+
const midFlowSubmit = attempt.isMidFlowSubmitStep === true;
|
|
233
|
+
const submitShaped = attempt.isSubmitShapedStep === true || midFlowSubmit;
|
|
165
234
|
// Element-scoped selection flip; not on a submit-shaped step, which must
|
|
166
235
|
// prove itself via network/URL or the deep-submit escalation is defeated.
|
|
167
|
-
const elementStateChanged = !
|
|
236
|
+
const elementStateChanged = !submitShaped && attempt.elementStateChanged === true;
|
|
168
237
|
// A submit-shaped step likewise ignores a mere DOM-byte reflow.
|
|
169
|
-
const bytesChangedSignificantly = !
|
|
170
|
-
const
|
|
238
|
+
const bytesChangedSignificantly = !submitShaped && Math.abs(bytesDelta) >= exports.TRIVIAL_DOM_DELTA_BYTES;
|
|
239
|
+
const midFlowAdvanced = midFlowSubmit && hasPageAdvanced(attempt.pre, attempt.post);
|
|
240
|
+
const hasEffect = networkDelta !== 0 ||
|
|
241
|
+
urlChanged ||
|
|
242
|
+
elementStateChanged ||
|
|
243
|
+
bytesChangedSignificantly ||
|
|
244
|
+
midFlowAdvanced;
|
|
171
245
|
return hasEffect ? "effective" : "phantom";
|
|
172
246
|
}
|
|
173
247
|
//# 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;;;;;;;;AAyDH,SAAS,eAAe,CAAC,GAAW;IAClC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,gCAAuC,MAAc,EAAE,OAAe;IACpE,OAAO,eAAe,CAAC,MAAM,CAAC,KAAK,eAAe,CAAC,OAAO,CAAC,CAAC;AAC9D,CAAC;AAED,uEAAuE;AAC1D,QAAA,gBAAgB,GAAG,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAC;AAExE,uHAAuH;AACvH,SAAS,wBAAwB,CAAC,WAAmB;IACnD,OAAO,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAC/D,CAAC;AAED;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG;IACxB,OAAO;IACP,KAAK;IACL,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,SAAS;IACT,QAAQ;IACR,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,MAAM;IACN,QAAQ;IACR,UAAU;IACV,SAAS;IACT,OAAO;IACP,QAAQ;IACR,UAAU;CACX,CAAC;AAEF,MAAM,wBAAwB,GAAG,IAAI,MAAM,CAAC,SAAS,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAA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CAAC,kBAAkB,KAAK,IAAI,IAAI,aAAa,CAAC;IAC1E,yEAAyE;IACzE,0EAA0E;IAC1E,MAAM,mBAAmB,GAAG,CAAC,YAAY,IAAI,OAAO,CAAC,mBAAmB,KAAK,IAAI,CAAC;IAClF,gEAAgE;IAChE,MAAM,yBAAyB,GAC7B,CAAC,YAAY,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,QAAA,uBAAuB,CAAC;IAEnE,MAAM,eAAe,GAAG,aAAa,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpF,MAAM,SAAS,GACb,YAAY,KAAK,CAAC;QAClB,UAAU;QACV,mBAAmB;QACnB,yBAAyB;QACzB,eAAe,CAAC;IAClB,OAAO,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/scraper/pool.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,mBAAmB,CAAC;AAC9E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/scraper/pool.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,mBAAmB,CAAC;AAC9E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAsBtE;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,IAAI,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,EAC7C,YAAY,GAAE,IAAI,CAAC,YAAY,EAAE,kBAAkB,CAAM,EACzD,aAAa,SAAkB,EAC/B,WAAW,GAAE,IAAI,CAAC,qBAAqB,EAAE,UAAU,CAAM,GACxD,OAAO,CAAC,CAAC,CAAC,CAgDZ;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAMlF;AAED;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,SAAS,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAKjE"}
|
package/dist/scraper/pool.js
CHANGED
|
@@ -12,6 +12,7 @@ const logging_1 = require("../lib/logging");
|
|
|
12
12
|
const errors_1 = require("./errors");
|
|
13
13
|
const retry_1 = require("./retry");
|
|
14
14
|
const session_1 = require("./session");
|
|
15
|
+
const session_teardown_1 = require("./session-teardown");
|
|
15
16
|
const logger = (0, logging_1.getLogger)({ name: "scraper/pool" });
|
|
16
17
|
/**
|
|
17
18
|
* Per-task hard timeout default. A hung Stagehand operation (infinite network wait,
|
|
@@ -61,7 +62,13 @@ async function runWithSession(task, retryOptions = {}, taskTimeoutMs = TASK_TIME
|
|
|
61
62
|
const t = setTimeout(() => reject(new errors_1.SessionTimeoutError(`task exceeded ${taskTimeoutMs}ms`)), taskTimeoutMs);
|
|
62
63
|
t.unref();
|
|
63
64
|
});
|
|
64
|
-
|
|
65
|
+
try {
|
|
66
|
+
return await Promise.race([task(session), timeout]);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
// Must run before onSessionRestart: closeSession() nulls sessionRef.
|
|
70
|
+
throw (0, session_teardown_1.resolveSessionDeathError)(sessionRef.session ?? undefined, err);
|
|
71
|
+
}
|
|
65
72
|
}, {
|
|
66
73
|
...retryOptions,
|
|
67
74
|
onSessionRestart: async () => {
|
package/dist/scraper/pool.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/scraper/pool.ts"],"names":[],"mappings":";;;;;;;;AAAA,sDAA6B;AAE7B,qCAAkC;AAClC,2CAA0C;AAC1C,6CAAuD;AACvD,2CAAsE;AACtE,+CAA8E;
|
|
1
|
+
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/scraper/pool.ts"],"names":[],"mappings":";;;;;;;;AAAA,sDAA6B;AAE7B,qCAAkC;AAClC,2CAA0C;AAC1C,6CAAuD;AACvD,2CAAsE;AACtE,+CAA8E;AAE9E,iEAAsE;AAEtE,MAAM,MAAM,GAAG,IAAA,mBAAS,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,aAAa;AAEtD;;;;;GAKG;AACH,MAAM,KAAK,GAAG,IAAI,iBAAM,CAAC,EAAE,WAAW,EAAE,eAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;AAEnE;;;;;;;;;;GAUG;AACI,KAAK,yBACV,IAA6C,EAC7C,YAAY,GAA2C,EAAE,EACzD,aAAa,GAAG,eAAe,EAC/B,WAAW,GAA4C,EAAE;IAEzD,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;QAC1B,MAAM,UAAU,GAAuC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAEzE,MAAM,aAAa,GAAG,KAAK,IAA6B,EAAE;YACxD,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;gBACxB,UAAU,CAAC,OAAO,GAAG,MAAM,IAAA,8BAAoB,EAAC,WAAW,CAAC,CAAC;YAC/D,CAAC;YACD,OAAO,UAAU,CAAC,OAAO,CAAC;QAC5B,CAAC,CAAC;QAEF,MAAM,YAAY,GAAG,KAAK,IAAmB,EAAE;YAC7C,IAAI,UAAU,CAA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AAW,EAAE,KAAK,CAAC,WAAW;KAC/B,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACI,KAAK,oBAAoB,SAAS,GAAG,MAAM;IAChD,KAAK,CAAC,KAAK,EAAE,CAAC;IACd,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;IAC9B,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7F,KAAK,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface QuotedSpan {
|
|
2
|
+
text: string;
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Hides apostrophes that belong to a quoted value rather than delimiting it, so
|
|
8
|
+
* a runtime value spliced between quotes is read back in full: contractions and
|
|
9
|
+
* possessives (alphanumeric on both sides) plus a leading or trailing
|
|
10
|
+
* apostrophe of the value itself (`''Smith'`, `'Smith''`). Open/closed state is
|
|
11
|
+
* tracked across the text; the output has the same length as the input.
|
|
12
|
+
*/
|
|
13
|
+
export declare function maskApostrophes(text: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Reverses `maskApostrophes` on text captured from a masked string.
|
|
16
|
+
*/
|
|
17
|
+
export declare function restoreApostrophes(text: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Finds real single-quoted spans in instruction copy. `start`/`end` index the
|
|
20
|
+
* ORIGINAL string (delimiters inclusive) and `text` has apostrophes restored.
|
|
21
|
+
*/
|
|
22
|
+
export declare function findQuotedSpans(text: string): QuotedSpan[];
|
|
23
|
+
export interface AnchoredMatch {
|
|
24
|
+
/** Full match followed by capture groups, apostrophes restored; unmatched groups are `undefined`. */
|
|
25
|
+
groups: (string | undefined)[];
|
|
26
|
+
start: number;
|
|
27
|
+
end: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Runs an anchored-verb regex over the apostrophe-masked instruction so every
|
|
31
|
+
* parser shares one tokenizer: a letter-flanked apostrophe never ends a quoted
|
|
32
|
+
* span. `start`/`end` index the ORIGINAL string (masking preserves length).
|
|
33
|
+
*/
|
|
34
|
+
export declare function matchAnchored(text: string, pattern: RegExp): AnchoredMatch | null;
|
|
35
|
+
//# sourceMappingURL=quoted-spans.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quoted-spans.d.ts","sourceRoot":"","sources":["../../src/scraper/quoted-spans.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAMD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA0BpD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAM1D;AAED,MAAM,WAAW,aAAa;IAC5B,qGAAqG;IACrG,MAAM,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAWjF"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.maskApostrophes = maskApostrophes;
|
|
4
|
+
exports.restoreApostrophes = restoreApostrophes;
|
|
5
|
+
exports.findQuotedSpans = findQuotedSpans;
|
|
6
|
+
exports.matchAnchored = matchAnchored;
|
|
7
|
+
const APOSTROPHE_PLACEHOLDER = "\u0000";
|
|
8
|
+
const ALPHANUMERIC = /[A-Za-z0-9]/;
|
|
9
|
+
const SINGLE_QUOTED_SPAN = /'([^']+)'/g;
|
|
10
|
+
function isAlphanumeric(char) {
|
|
11
|
+
return char !== undefined && ALPHANUMERIC.test(char);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Hides apostrophes that belong to a quoted value rather than delimiting it, so
|
|
15
|
+
* a runtime value spliced between quotes is read back in full: contractions and
|
|
16
|
+
* possessives (alphanumeric on both sides) plus a leading or trailing
|
|
17
|
+
* apostrophe of the value itself (`''Smith'`, `'Smith''`). Open/closed state is
|
|
18
|
+
* tracked across the text; the output has the same length as the input.
|
|
19
|
+
*/
|
|
20
|
+
function maskApostrophes(text) {
|
|
21
|
+
const chars = [...text];
|
|
22
|
+
let inSpan = false;
|
|
23
|
+
let index = 0;
|
|
24
|
+
while (index < chars.length) {
|
|
25
|
+
if (chars[index] !== "'") {
|
|
26
|
+
index++;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
let end = index;
|
|
30
|
+
while (chars[end] === "'")
|
|
31
|
+
end++;
|
|
32
|
+
const run = end - index;
|
|
33
|
+
const nextIsValue = isAlphanumeric(chars[end]);
|
|
34
|
+
const interior = run === 1 && isAlphanumeric(chars[index - 1]) && nextIsValue;
|
|
35
|
+
const opens = !inSpan && !interior;
|
|
36
|
+
const closes = !interior && (inSpan ? !(run > 1 && nextIsValue) : run > 1 && !nextIsValue);
|
|
37
|
+
// The opening delimiter is the first quote of the run and the closing one
|
|
38
|
+
// the last; every other quote in the run is value content.
|
|
39
|
+
for (let at = index; at < end; at++) {
|
|
40
|
+
const isDelimiter = (opens && at === index) || (closes && at === end - 1);
|
|
41
|
+
if (!isDelimiter)
|
|
42
|
+
chars[at] = APOSTROPHE_PLACEHOLDER;
|
|
43
|
+
}
|
|
44
|
+
if (opens !== closes)
|
|
45
|
+
inSpan = !inSpan;
|
|
46
|
+
index = end;
|
|
47
|
+
}
|
|
48
|
+
return chars.join("");
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Reverses `maskApostrophes` on text captured from a masked string.
|
|
52
|
+
*/
|
|
53
|
+
function restoreApostrophes(text) {
|
|
54
|
+
return text.replaceAll(APOSTROPHE_PLACEHOLDER, "'");
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Finds real single-quoted spans in instruction copy. `start`/`end` index the
|
|
58
|
+
* ORIGINAL string (delimiters inclusive) and `text` has apostrophes restored.
|
|
59
|
+
*/
|
|
60
|
+
function findQuotedSpans(text) {
|
|
61
|
+
return Array.from(maskApostrophes(text).matchAll(SINGLE_QUOTED_SPAN), (match) => ({
|
|
62
|
+
text: restoreApostrophes(match[1] ?? ""),
|
|
63
|
+
start: match.index ?? 0,
|
|
64
|
+
end: (match.index ?? 0) + match[0].length,
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Runs an anchored-verb regex over the apostrophe-masked instruction so every
|
|
69
|
+
* parser shares one tokenizer: a letter-flanked apostrophe never ends a quoted
|
|
70
|
+
* span. `start`/`end` index the ORIGINAL string (masking preserves length).
|
|
71
|
+
*/
|
|
72
|
+
function matchAnchored(text, pattern) {
|
|
73
|
+
const match = pattern.exec(maskApostrophes(text));
|
|
74
|
+
if (!match)
|
|
75
|
+
return null;
|
|
76
|
+
const start = match.index;
|
|
77
|
+
return {
|
|
78
|
+
groups: Array.from(match, (group) => group === undefined ? undefined : restoreApostrophes(group)),
|
|
79
|
+
start,
|
|
80
|
+
end: start + match[0].length,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=quoted-spans.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quoted-spans.js","sourceRoot":"","sources":["../../src/scraper/quoted-spans.ts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AAC;IAC1B,OAAO;QACL,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAClC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAC5D;QACD,KAAK;QACL,GAAG,EAAE,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM;KAC7B,CAAC;AACJ,CAAC"}
|
package/dist/scraper/retry.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface RetryOptions {
|
|
|
16
16
|
* Wraps a scraper task with p-retry and a classification policy aligned
|
|
17
17
|
* with our ScraperError hierarchy:
|
|
18
18
|
*
|
|
19
|
-
* - CaptchaError + EmptyResultsError + StepVerificationError → AbortError, no retry.
|
|
19
|
+
* - CaptchaError + EmptyResultsError + StepVerificationError + SessionLifetimeExceededError → AbortError, no retry.
|
|
20
20
|
* - SessionTimeoutError + CdpTransportClosedError → invoke onSessionRestart before every retry, then retry up to maxAttempts.
|
|
21
21
|
* - SelectorFailureError + UnknownScraperError → retry up to maxAttempts.
|
|
22
22
|
* - Anything non-ScraperError → wrap in UnknownScraperError and retry.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/scraper/retry.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/scraper/retry.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,YAAY,EAKb,MAAM,kBAAkB,CAAC;AAI1B;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,mEAAmE;IACnE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1E;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACtB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,CAAC,CAAC,CA4DZ;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAmB/D"}
|
package/dist/scraper/retry.js
CHANGED
|
@@ -44,7 +44,7 @@ const logger = (0, logging_1.getLogger)({ name: "scraper/retry" });
|
|
|
44
44
|
* Wraps a scraper task with p-retry and a classification policy aligned
|
|
45
45
|
* with our ScraperError hierarchy:
|
|
46
46
|
*
|
|
47
|
-
* - CaptchaError + EmptyResultsError + StepVerificationError → AbortError, no retry.
|
|
47
|
+
* - CaptchaError + EmptyResultsError + StepVerificationError + SessionLifetimeExceededError → AbortError, no retry.
|
|
48
48
|
* - SessionTimeoutError + CdpTransportClosedError → invoke onSessionRestart before every retry, then retry up to maxAttempts.
|
|
49
49
|
* - SelectorFailureError + UnknownScraperError → retry up to maxAttempts.
|
|
50
50
|
* - Anything non-ScraperError → wrap in UnknownScraperError and retry.
|
|
@@ -75,6 +75,10 @@ async function withScraperRetry(task, options = {}) {
|
|
|
75
75
|
logger.warn(`step verification failed deterministically — aborting retry: ${err.message}`);
|
|
76
76
|
throw new p_retry_1.AbortError(err.message);
|
|
77
77
|
}
|
|
78
|
+
if ((0, errors_2.isSessionLifetimeExceededError)(raw)) {
|
|
79
|
+
logger.error(`session reached its configured lifetime — aborting retry: ${err.message}`);
|
|
80
|
+
throw new p_retry_1.AbortError(err.message);
|
|
81
|
+
}
|
|
78
82
|
if ((err instanceof errors_2.SessionTimeoutError || err instanceof errors_2.CdpTransportClosedError) &&
|
|
79
83
|
options.onSessionRestart) {
|
|
80
84
|
await options.onSessionRestart();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/scraper/retry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA6C;AAE7C,yCAA8C;AAC9C,2CAA0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/scraper/retry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA6C;AAE7C,yCAA8C;AAC9C,2CAA0C;AAC1C,6CAU0B;AAE1B,MAAM,MAAM,GAAG,IAAA,mBAAS,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;AAgBpD;;;;;;;;;;;GAWG;AACI,KAAK,2BACV,IAAsB,EACtB,OAAO,GAAiB,EAAE;IAE1B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC;IAE7C,OAAO,IAAA,iBAAM,EACX,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,EAAE,CAAC;QACtB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,GAAG,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;YAEtC,IAAI,GAAG,YAAY,qBAAY,EAAE,CAAC;gBAChC,+DAA+D;gBAC/D,6DAA6D;gBAC7D,2DAA2D;gBAC3D,MAAM,CAAC,KAAK,CAAC,4DAA4D,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;gBACxF,MAAM,IAAI,oBAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACpC,CAAC;YACD,IAAI,GAAG,YAAY,0BAAiB,EAAE,CAAC;gBACrC,MAAM,CAAC,IAAI,CAAC,oDAAoD,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC/E,MAAM,IAAI,oBAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACpC,CAAC;Y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AqC,GAAY;IAC/C,IAAI,GAAG,YAAY,qBAAY;QAAE,OAAO,GAAG,CAAC;IAC5C,MAAM,OAAO,GAAG,IAAA,uBAAc,EAAC,GAAG,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACpC,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,qBAAY,CAAC,OAAO,CAAC,CAAC;IAChE,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7D,OAAO,IAAI,4BAAmB,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IACD,IACE,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC1B,KAAK,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QAChC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,EAC3B,CAAC;QACD,OAAO,IAAI,6BAAoB,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC5D,OAAO,IAAI,0BAAiB,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,IAAI,4BAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -71,8 +71,10 @@ export declare function makeOutboundIpAccessor(resolve: () => Promise<string | n
|
|
|
71
71
|
* code path Stagehand validates first.
|
|
72
72
|
*
|
|
73
73
|
* Session lifecycle: Stagehand owns Browserbase session creation when
|
|
74
|
-
* `env: "BROWSERBASE"` is set
|
|
75
|
-
*
|
|
74
|
+
* `env: "BROWSERBASE"` is set, but because the session is created with
|
|
75
|
+
* `keepAlive: true`, `stagehand.close()` does NOT release it. `close()`
|
|
76
|
+
* therefore explicitly issues `sessions.update(..., REQUEST_RELEASE)` through
|
|
77
|
+
* the Browserbase SDK; a failed release is logged and never aborts teardown.
|
|
76
78
|
*
|
|
77
79
|
* Viewport rotation: forwarded via `fingerprint.screen.{min,max}{Width,Height}`
|
|
78
80
|
* pinned to the chosen viewport. The min/max bracket forces Browserbase's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-browserbase.d.ts","sourceRoot":"","sources":["../../src/scraper/session-browserbase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session-browserbase.d.ts","sourceRoot":"","sources":["../../src/scraper/session-browserbase.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAG3B,MAAM,0BAA0B,CAAC;AAOlC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAa9C;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG;IAC/D,QAAQ,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC3C,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,kBAAkB,EAAE,MAAM,MAAM,CAAC;CAClC,CA6BA;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EACrC,IAAI,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GACzB,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAS9B;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,+BAA+B,CACnD,IAAI,CAAC,EAAE,IAAI,CAAC,qBAAqB,EAAE,iBAAiB,GAAG,gCAAgC,CAAC,GACvF,OAAO,CAAC,cAAc,CAAC,CAqOzB"}
|