@enricai/barnacle 1.6.1 → 1.6.3
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/README.md +36 -29
- package/dist/api/errors.d.ts +3 -3
- package/dist/api/errors.d.ts.map +1 -1
- package/dist/api/errors.js +4 -4
- package/dist/api/errors.js.map +1 -1
- package/dist/api/helpers/reply.d.ts +1 -1
- package/dist/api/helpers/reply.js +1 -1
- package/dist/cache/keyed-ttl-cache.d.ts +4 -4
- package/dist/cache/keyed-ttl-cache.js +2 -2
- package/dist/lib/applicant-payload.d.ts +4 -4
- package/dist/lib/applicant-payload.js +4 -4
- package/dist/lib/application-address.d.ts +3 -3
- package/dist/lib/application-address.js +5 -5
- package/dist/lib/application-address.js.map +1 -1
- package/dist/lib/application-resume.d.ts +4 -4
- package/dist/lib/application-resume.js +4 -4
- package/dist/lib/dispatch-metrics.js +1 -1
- package/dist/lib/llm/judges/verify-submit.d.ts +1 -1
- package/dist/lib/llm/judges/verify-submit.js +1 -1
- package/dist/lib/llm/schemas.js +3 -3
- package/dist/lib/phone.d.ts +1 -1
- package/dist/lib/phone.js +1 -1
- package/dist/lib/telemetry/call-types.d.ts +1 -1
- package/dist/lib/telemetry/call-types.js +1 -1
- package/dist/lib/tracking-click.d.ts +5 -3
- package/dist/lib/tracking-click.d.ts.map +1 -1
- package/dist/lib/tracking-click.js +5 -3
- package/dist/lib/tracking-click.js.map +1 -1
- package/dist/lib/us-states.d.ts +1 -1
- package/dist/lib/us-states.js +1 -1
- package/dist/plugins/loader.js +2 -2
- package/dist/scraper/cookie-jar.d.ts +2 -2
- package/dist/scraper/cookie-jar.js +2 -2
- package/dist/scraper/deep-query.d.ts +36 -0
- package/dist/scraper/deep-query.d.ts.map +1 -0
- package/dist/scraper/deep-query.js +87 -0
- package/dist/scraper/deep-query.js.map +1 -0
- package/dist/scraper/errors.d.ts +12 -14
- package/dist/scraper/errors.d.ts.map +1 -1
- package/dist/scraper/errors.js +12 -17
- package/dist/scraper/errors.js.map +1 -1
- package/dist/scraper/flow-runner.d.ts +97 -30
- package/dist/scraper/flow-runner.d.ts.map +1 -1
- package/dist/scraper/flow-runner.js +304 -104
- package/dist/scraper/flow-runner.js.map +1 -1
- package/dist/scraper/http-client.d.ts +11 -1
- package/dist/scraper/http-client.d.ts.map +1 -1
- package/dist/scraper/http-client.js +90 -3
- package/dist/scraper/http-client.js.map +1 -1
- package/dist/scraper/phantom-click.d.ts +45 -0
- package/dist/scraper/phantom-click.d.ts.map +1 -0
- package/dist/scraper/phantom-click.js +37 -0
- package/dist/scraper/phantom-click.js.map +1 -0
- package/dist/scraper/raw-fetch.d.ts +2 -2
- package/dist/scraper/raw-fetch.js +1 -1
- package/dist/scraper/require-response-field.d.ts +1 -1
- package/dist/scraper/require-response-field.js +1 -1
- package/dist/scraper/session-browserbase.d.ts +48 -0
- package/dist/scraper/session-browserbase.d.ts.map +1 -1
- package/dist/scraper/session-browserbase.js +10 -5
- package/dist/scraper/session-browserbase.js.map +1 -1
- package/dist/scraper/session-shared.d.ts +6 -0
- package/dist/scraper/session-shared.d.ts.map +1 -1
- package/dist/scraper/session-shared.js.map +1 -1
- package/dist/scraper/session-warmup.d.ts +1 -1
- package/dist/scraper/session-warmup.js +1 -1
- package/dist/scraper/submit-control.d.ts +51 -0
- package/dist/scraper/submit-control.d.ts.map +1 -0
- package/dist/scraper/submit-control.js +142 -0
- package/dist/scraper/submit-control.js.map +1 -0
- package/dist/scripts/migrate-telemetry-dir-names.d.ts +2 -2
- package/dist/scripts/migrate-telemetry-dir-names.d.ts.map +1 -1
- package/dist/scripts/migrate-telemetry-dir-names.js +1 -1
- package/dist/scripts/recon-browser.d.ts +25 -20
- package/dist/scripts/recon-browser.d.ts.map +1 -1
- package/dist/scripts/recon-browser.js +65 -56
- package/dist/scripts/recon-browser.js.map +1 -1
- package/dist/scripts/recon-generate.d.ts +52 -7
- package/dist/scripts/recon-generate.d.ts.map +1 -1
- package/dist/scripts/recon-generate.js +73 -31
- package/dist/scripts/recon-generate.js.map +1 -1
- package/dist/scripts/recon-http.d.ts +36 -5
- package/dist/scripts/recon-http.d.ts.map +1 -1
- package/dist/scripts/recon-http.js +77 -47
- package/dist/scripts/recon-http.js.map +1 -1
- package/dist/scripts/recon-replay-jobs.d.ts +32 -3
- package/dist/scripts/recon-replay-jobs.d.ts.map +1 -1
- package/dist/scripts/recon-replay-jobs.js +46 -29
- package/dist/scripts/recon-replay-jobs.js.map +1 -1
- package/dist/scripts/recon-shared.d.ts +45 -0
- package/dist/scripts/recon-shared.d.ts.map +1 -1
- package/dist/scripts/recon-shared.js +117 -0
- package/dist/scripts/recon-shared.js.map +1 -1
- package/dist/scripts/recon-summarize.d.ts +5 -1
- package/dist/scripts/recon-summarize.d.ts.map +1 -1
- package/dist/scripts/recon-summarize.js +19 -7
- package/dist/scripts/recon-summarize.js.map +1 -1
- package/dist/site-plugin.d.ts +4 -4
- package/dist/testing/persona-fixture.d.ts +4 -4
- package/dist/testing/persona-fixture.d.ts.map +1 -1
- package/dist/testing/persona-fixture.js +4 -4
- package/dist/testing/persona-fixture.js.map +1 -1
- package/dist/types/dispatch-metrics.d.ts +1 -1
- package/dist/types/dispatch-metrics.js +1 -1
- package/package.json +1 -1
|
@@ -83,6 +83,58 @@ function extractCookieValue(setCookieHeaders, cookieName) {
|
|
|
83
83
|
}
|
|
84
84
|
return undefined;
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Finds a header's value by case-insensitive key lookup — `baseHeaders` and
|
|
88
|
+
* `init.headers` are operator-supplied with arbitrary casing (unlike
|
|
89
|
+
* `boundHeaders`, which is normalized via `targetHeaderCasing`), so a plain
|
|
90
|
+
* `headers["Cookie"]` lookup would miss a `"cookie"` or `"COOKIE"` key.
|
|
91
|
+
*/
|
|
92
|
+
function findHeaderCaseInsensitive(headers, name) {
|
|
93
|
+
const lower = name.toLowerCase();
|
|
94
|
+
const key = Object.keys(headers).find((k) => k.toLowerCase() === lower);
|
|
95
|
+
return key === undefined ? undefined : headers[key];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Parses a `name=value; name=value` Cookie header string into per-cookie
|
|
99
|
+
* entries, mirroring the pair-splitting `extractCookieValue` already does
|
|
100
|
+
* for `Set-Cookie`. Skips malformed segments (no `=`) rather than throwing —
|
|
101
|
+
* an operator-authored `baseHeaders` or per-call `init.headers` Cookie value
|
|
102
|
+
* is untrusted input, not a value this module produced.
|
|
103
|
+
*/
|
|
104
|
+
function parseCookiePairs(cookieHeader) {
|
|
105
|
+
return cookieHeader
|
|
106
|
+
.split(";")
|
|
107
|
+
.map((pair) => pair.trim())
|
|
108
|
+
.filter(Boolean)
|
|
109
|
+
.flatMap((pair) => {
|
|
110
|
+
const eq = pair.indexOf("=");
|
|
111
|
+
return eq === -1 ? [] : [[pair.slice(0, eq).trim(), pair.slice(eq + 1).trim()]];
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Merges the Cookie header across `baseHeaders`, the live `boundHeaders`
|
|
116
|
+
* accumulator, and per-call `init.headers` by individual cookie name instead
|
|
117
|
+
* of the last-wins overwrite plain object spread gives every other header —
|
|
118
|
+
* see the http-client.ts module docblock and CLAUDE.md "battle-tested
|
|
119
|
+
* libraries only" for why the Cookie header specifically needs pair-level
|
|
120
|
+
* merging. Precedence on a name collision: a freshly bound value (the live
|
|
121
|
+
* session state a response just handed back) wins over a per-call override,
|
|
122
|
+
* which wins over the plugin's static default — bound values are the most
|
|
123
|
+
* current source of truth for a cookie in active rotation.
|
|
124
|
+
*/
|
|
125
|
+
function mergeCookieHeader(baseHeaders, boundHeaders, initHeaders) {
|
|
126
|
+
const merged = new Map();
|
|
127
|
+
for (const source of [baseHeaders, initHeaders, boundHeaders]) {
|
|
128
|
+
const cookieHeader = findHeaderCaseInsensitive(source, "Cookie");
|
|
129
|
+
if (cookieHeader === undefined)
|
|
130
|
+
continue;
|
|
131
|
+
for (const [name, value] of parseCookiePairs(cookieHeader))
|
|
132
|
+
merged.set(name, value);
|
|
133
|
+
}
|
|
134
|
+
if (merged.size === 0)
|
|
135
|
+
return undefined;
|
|
136
|
+
return [...merged.entries()].map(([name, value]) => `${name}=${value}`).join("; ");
|
|
137
|
+
}
|
|
86
138
|
/**
|
|
87
139
|
* Resolves one {@link HttpResponseBinding} against a response's headers.
|
|
88
140
|
* Returns `undefined` on a miss (source header/cookie absent) so the caller
|
|
@@ -125,10 +177,33 @@ function createHttpClient(options) {
|
|
|
125
177
|
// targetHeader. Lives for the lifetime of this client instance so a later
|
|
126
178
|
// call can pick up what an earlier call captured — see HttpResponseBinding.
|
|
127
179
|
const boundHeaders = {};
|
|
180
|
+
// Per-cookie values for targetHeaders that carry multiple cookies (e.g.
|
|
181
|
+
// "Cookie"), keyed by targetHeader.toLowerCase() then cookieName so
|
|
182
|
+
// several bindings sharing one targetHeader — even across differing
|
|
183
|
+
// casing, since HTTP header names are case-insensitive — accumulate
|
|
184
|
+
// instead of overwriting or splitting into two outbound headers — see
|
|
185
|
+
// HttpResponseBinding.targetHeader. Materialized into boundHeaders
|
|
186
|
+
// (joined by "; ") whenever an entry changes.
|
|
187
|
+
const boundCookiesByTarget = new Map();
|
|
188
|
+
// Canonical (first-seen) casing of each targetHeader, keyed by
|
|
189
|
+
// targetHeader.toLowerCase() — lets both branches below write
|
|
190
|
+
// boundHeaders under one stable key regardless of which casing a later
|
|
191
|
+
// binding declares.
|
|
192
|
+
const targetHeaderCasing = new Map();
|
|
128
193
|
return async (url, init = {}) => {
|
|
129
194
|
return bottleneck.schedule(() => (0, p_retry_1.default)(async () => {
|
|
130
195
|
const method = init.method ?? "GET";
|
|
131
|
-
const
|
|
196
|
+
const initHeaders = init.headers ?? {};
|
|
197
|
+
const mergedCookie = mergeCookieHeader(baseHeaders, boundHeaders, initHeaders);
|
|
198
|
+
const headers = {
|
|
199
|
+
...baseHeaders,
|
|
200
|
+
...boundHeaders,
|
|
201
|
+
...initHeaders,
|
|
202
|
+
};
|
|
203
|
+
if (mergedCookie !== undefined) {
|
|
204
|
+
const cookieKey = Object.keys(headers).find((k) => k.toLowerCase() === "cookie") ?? "Cookie";
|
|
205
|
+
headers[cookieKey] = mergedCookie;
|
|
206
|
+
}
|
|
132
207
|
let response;
|
|
133
208
|
try {
|
|
134
209
|
response = await fetch(url, {
|
|
@@ -157,9 +232,21 @@ function createHttpClient(options) {
|
|
|
157
232
|
// clearing it — and if nothing has ever been bound, the target
|
|
158
233
|
// header stays absent from `boundHeaders` entirely, so later
|
|
159
234
|
// requests never send it as an empty string.
|
|
160
|
-
if (value
|
|
161
|
-
|
|
235
|
+
if (value === undefined)
|
|
236
|
+
continue;
|
|
237
|
+
const targetKey = binding.targetHeader.toLowerCase();
|
|
238
|
+
const canonicalTarget = targetHeaderCasing.get(targetKey) ?? binding.targetHeader;
|
|
239
|
+
targetHeaderCasing.set(targetKey, canonicalTarget);
|
|
240
|
+
if (binding.cookieName === undefined) {
|
|
241
|
+
boundHeaders[canonicalTarget] = value;
|
|
242
|
+
continue;
|
|
162
243
|
}
|
|
244
|
+
const cookies = boundCookiesByTarget.get(targetKey) ?? new Map();
|
|
245
|
+
cookies.set(binding.cookieName, value);
|
|
246
|
+
boundCookiesByTarget.set(targetKey, cookies);
|
|
247
|
+
boundHeaders[canonicalTarget] = [...cookies.entries()]
|
|
248
|
+
.map(([name, cookieValue]) => `${name}=${cookieValue}`)
|
|
249
|
+
.join("; ");
|
|
163
250
|
}
|
|
164
251
|
if (response.status === 401 || response.status === 403) {
|
|
165
252
|
// Bot challenge / auth wall — not a transient failure, abort retry.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../src/scraper/http-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAmD;AACnD,yCAAiC;AAGjC,mDAA6C;AAG7C,2CAA0C;AAC1C,6CAO0B;AAE1B,MAAM,MAAM,GAAG,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,OAAO,CAAC,KAAK,CAAC,OAAO,KAAK,OAAO,CAAC,WAAW,eAAe,CACvH,CAAC;YACJ,CAAC;SACF,CACF,CACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure phantom-click predicate. `describeAttemptEffectSignals` (flow-runner.ts)
|
|
3
|
+
* renders pre/post deltas into a diagnostic string for LLM consumption; this
|
|
4
|
+
* module renders the same shape of data into a decision so the cascade can
|
|
5
|
+
* escalate immediately instead of repeating techniques that all no-op the
|
|
6
|
+
* same way (see recon-submit-phantom-click bug report).
|
|
7
|
+
*/
|
|
8
|
+
/** Cheap snapshot of side effects — field names mirror flow-runner's StepSnapshot. */
|
|
9
|
+
export interface PhantomClickSnapshot {
|
|
10
|
+
networkCount: number;
|
|
11
|
+
url: string;
|
|
12
|
+
/** `document.body.outerHTML.length`. */
|
|
13
|
+
bodyHtmlLength: number;
|
|
14
|
+
}
|
|
15
|
+
export interface PhantomClickAttempt {
|
|
16
|
+
/** Stagehand's own verdict for the attempt — did it believe it acted? */
|
|
17
|
+
actResultSuccess: boolean | null;
|
|
18
|
+
pre: PhantomClickSnapshot;
|
|
19
|
+
post: PhantomClickSnapshot;
|
|
20
|
+
}
|
|
21
|
+
export type PhantomClickVerdict =
|
|
22
|
+
/** Stagehand reported success but pre/post shows no observable effect — a no-op click. */
|
|
23
|
+
"phantom"
|
|
24
|
+
/** Stagehand reported success and pre/post shows a real effect. */
|
|
25
|
+
| "effective"
|
|
26
|
+
/** Stagehand couldn't resolve a target at all (error / null) — distinct from a phantom click: nothing was clicked, vs. something was clicked that did nothing. */
|
|
27
|
+
| "unresolved";
|
|
28
|
+
/**
|
|
29
|
+
* Bytes of body-HTML growth treated as noise rather than a real DOM effect.
|
|
30
|
+
* Reused from `describeAttemptEffectSignals`'s dom-grew-without-network
|
|
31
|
+
* boundary (flow-runner.ts) so both signals agree on what counts as
|
|
32
|
+
* "trivial" — e.g. the bug report's attempt 5 (+30B) must classify as
|
|
33
|
+
* phantom, not effective.
|
|
34
|
+
*/
|
|
35
|
+
export declare const TRIVIAL_DOM_DELTA_BYTES = 500;
|
|
36
|
+
/**
|
|
37
|
+
* Classifies one cascade attempt as `phantom` (Stagehand claimed success but
|
|
38
|
+
* pre/post shows zero network, zero URL change, and only trivial DOM
|
|
39
|
+
* growth), `unresolved` (Stagehand never resolved/executed the action), or
|
|
40
|
+
* `effective` (a real, observable change occurred). The cascade uses this to
|
|
41
|
+
* escalate off a phantom click immediately instead of burning all five
|
|
42
|
+
* techniques on the same no-op.
|
|
43
|
+
*/
|
|
44
|
+
export declare function classifyPhantomClick(attempt: PhantomClickAttempt): PhantomClickVerdict;
|
|
45
|
+
//# sourceMappingURL=phantom-click.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phantom-click.d.ts","sourceRoot":"","sources":["../../src/scraper/phantom-click.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,sFAAsF;AACtF,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,wCAAwC;IACxC,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,yEAAyE;IACzE,gBAAgB,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,GAAG,EAAE,oBAAoB,CAAC;IAC1B,IAAI,EAAE,oBAAoB,CAAC;CAC5B;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,CAStF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Pure phantom-click predicate. `describeAttemptEffectSignals` (flow-runner.ts)
|
|
4
|
+
* renders pre/post deltas into a diagnostic string for LLM consumption; this
|
|
5
|
+
* module renders the same shape of data into a decision so the cascade can
|
|
6
|
+
* escalate immediately instead of repeating techniques that all no-op the
|
|
7
|
+
* same way (see recon-submit-phantom-click bug report).
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.TRIVIAL_DOM_DELTA_BYTES = void 0;
|
|
11
|
+
exports.classifyPhantomClick = classifyPhantomClick;
|
|
12
|
+
/**
|
|
13
|
+
* Bytes of body-HTML growth treated as noise rather than a real DOM effect.
|
|
14
|
+
* Reused from `describeAttemptEffectSignals`'s dom-grew-without-network
|
|
15
|
+
* boundary (flow-runner.ts) so both signals agree on what counts as
|
|
16
|
+
* "trivial" — e.g. the bug report's attempt 5 (+30B) must classify as
|
|
17
|
+
* phantom, not effective.
|
|
18
|
+
*/
|
|
19
|
+
exports.TRIVIAL_DOM_DELTA_BYTES = 500;
|
|
20
|
+
/**
|
|
21
|
+
* Classifies one cascade attempt as `phantom` (Stagehand claimed success but
|
|
22
|
+
* pre/post shows zero network, zero URL change, and only trivial DOM
|
|
23
|
+
* growth), `unresolved` (Stagehand never resolved/executed the action), or
|
|
24
|
+
* `effective` (a real, observable change occurred). The cascade uses this to
|
|
25
|
+
* escalate off a phantom click immediately instead of burning all five
|
|
26
|
+
* techniques on the same no-op.
|
|
27
|
+
*/
|
|
28
|
+
function classifyPhantomClick(attempt) {
|
|
29
|
+
if (attempt.actResultSuccess !== true)
|
|
30
|
+
return "unresolved";
|
|
31
|
+
const networkDelta = attempt.post.networkCount - attempt.pre.networkCount;
|
|
32
|
+
const bytesDelta = attempt.post.bodyHtmlLength - attempt.pre.bodyHtmlLength;
|
|
33
|
+
const urlChanged = attempt.post.url !== attempt.pre.url;
|
|
34
|
+
const hasEffect = networkDelta !== 0 || urlChanged || bytesDelta >= exports.TRIVIAL_DOM_DELTA_BYTES;
|
|
35
|
+
return hasEffect ? "effective" : "phantom";
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=phantom-click.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phantom-click.js","sourceRoot":"","sources":["../../src/scraper/phantom-click.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAyBH;;;;;;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;IAExD,MAAM,SAAS,GAAG,YAAY,KAAK,CAAC,IAAI,UAAU,IAAI,UAAU,IAAI,QAAA,uBAAuB,CAAC;IAC5F,OAAO,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7C,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Site-agnostic fetch scaffold shared by plugins that cannot use
|
|
3
3
|
* `createHttpClient` — typically because they need multipart Buffer bodies
|
|
4
|
-
* or per-response header rotation (
|
|
4
|
+
* or per-response header rotation (per-site token churn). Owns the
|
|
5
5
|
* try/catch network-error conversion, the onResponse hook, and the
|
|
6
6
|
* classifyHttpStatus call so callers only supply the what (URL, headers,
|
|
7
7
|
* body) and the where (their token-rotation / audit hook and context label).
|
|
@@ -47,7 +47,7 @@ export interface RawFetchOptions {
|
|
|
47
47
|
onResponse: (headers: Headers) => void;
|
|
48
48
|
/**
|
|
49
49
|
* Short label used in error messages from `classifyHttpStatus`, e.g.
|
|
50
|
-
* `"
|
|
50
|
+
* `"<site> /integrated_questions"`. Should identify the endpoint so
|
|
51
51
|
* logs and error surfaces are actionable.
|
|
52
52
|
*/
|
|
53
53
|
contextLabel: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Site-agnostic fetch scaffold shared by plugins that cannot use
|
|
4
4
|
* `createHttpClient` — typically because they need multipart Buffer bodies
|
|
5
|
-
* or per-response header rotation (
|
|
5
|
+
* or per-response header rotation (per-site token churn). Owns the
|
|
6
6
|
* try/catch network-error conversion, the onResponse hook, and the
|
|
7
7
|
* classifyHttpStatus call so callers only supply the what (URL, headers,
|
|
8
8
|
* body) and the where (their token-rotation / audit hook and context label).
|
|
@@ -14,7 +14,7 @@ export declare function requireResponseField<T>(obj: Record<string, unknown>, ke
|
|
|
14
14
|
/**
|
|
15
15
|
* Returns `resp.items[0][key]` cast to `T`. Throws {@link HttpSchemaError}
|
|
16
16
|
* when `items` is absent or empty, or when the field itself is nullish.
|
|
17
|
-
* Covers the
|
|
17
|
+
* Covers the `?finder=...` pattern used by some ATS APIs where results arrive as
|
|
18
18
|
* `{ items: [...] }` and the first element carries the required field.
|
|
19
19
|
*/
|
|
20
20
|
export declare function requireFirstItemField<T>(resp: {
|
|
@@ -25,7 +25,7 @@ function requireResponseField(obj, key, contextLabel) {
|
|
|
25
25
|
/**
|
|
26
26
|
* Returns `resp.items[0][key]` cast to `T`. Throws {@link HttpSchemaError}
|
|
27
27
|
* when `items` is absent or empty, or when the field itself is nullish.
|
|
28
|
-
* Covers the
|
|
28
|
+
* Covers the `?finder=...` pattern used by some ATS APIs where results arrive as
|
|
29
29
|
* `{ items: [...] }` and the first element carries the required field.
|
|
30
30
|
*/
|
|
31
31
|
function requireFirstItemField(resp, key, contextLabel) {
|
|
@@ -1,4 +1,52 @@
|
|
|
1
1
|
import { type BrowserSession, type BrowserSessionOptions } from "../scraper/session-shared";
|
|
2
|
+
import type { Logger } from "../types/logging";
|
|
3
|
+
/**
|
|
4
|
+
* Shape of the LogLine objects Stagehand passes to its `logger` callback.
|
|
5
|
+
* We declare a minimal local subset rather than importing from Stagehand
|
|
6
|
+
* because the type isn't re-exported from the package's top-level entrypoint.
|
|
7
|
+
*/
|
|
8
|
+
export interface StagehandLogLine {
|
|
9
|
+
message: string;
|
|
10
|
+
category?: string;
|
|
11
|
+
level?: number;
|
|
12
|
+
auxiliary?: Record<string, {
|
|
13
|
+
value: string;
|
|
14
|
+
type: string;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Build a custom Stagehand logger that filters out the noisy upstream
|
|
19
|
+
* `AI_TypeValidationError` schema-validation spam. The errors come from
|
|
20
|
+
* Stagehand's internal Haiku LLM returning bare integers like "4671"
|
|
21
|
+
* when its Zod schema requires "N-N" format (regex /^\\d+-\\d+$/ at
|
|
22
|
+
* stagehand inference.js:147+240). Each error stack-trace is ~500 bytes
|
|
23
|
+
* of pino I/O — verified at 118 occurrences in run 1781485435455
|
|
24
|
+
* (2026-06-14), totaling ~5-7 min of wasted wall clock.
|
|
25
|
+
*
|
|
26
|
+
* The existing cascade Fix 1B (resolvedAction-null fast-skip) already
|
|
27
|
+
* handles the consequence: when Stagehand returns success=false due to
|
|
28
|
+
* this schema error, attempt 1 short-circuits cleanly and attempt 2
|
|
29
|
+
* (observe-act) runs on a structured target instead. The error log
|
|
30
|
+
* lines are pure noise.
|
|
31
|
+
*
|
|
32
|
+
* Filter is precise — only matches when category is "AISDK error"
|
|
33
|
+
* AND the cause body contains both `AI_TypeValidationError` and
|
|
34
|
+
* `elementId`. Other AISDK errors (rate limits, malformed requests,
|
|
35
|
+
* server errors) pass through unchanged. Site-agnostic — the
|
|
36
|
+
* upstream Stagehand bug is universal across tenants.
|
|
37
|
+
*
|
|
38
|
+
* Returns the callback + a `reportSuppressed` function that the
|
|
39
|
+
* session teardown calls to log the final suppression count, plus a
|
|
40
|
+
* `getSuppressedCount` live accessor so callers can read the running
|
|
41
|
+
* total while a step is still executing — e.g. treating "resolver
|
|
42
|
+
* threw on this step" as evidence a reported-success click was
|
|
43
|
+
* phantom, without waiting for teardown.
|
|
44
|
+
*/
|
|
45
|
+
export declare function makeFilteredStagehandLogger(pinoLogger: Logger): {
|
|
46
|
+
callback: (line: StagehandLogLine) => void;
|
|
47
|
+
reportSuppressed: () => void;
|
|
48
|
+
getSuppressedCount: () => number;
|
|
49
|
+
};
|
|
2
50
|
/**
|
|
3
51
|
* Spins up one Browserbase cloud session with the configured Stagehand LLM.
|
|
4
52
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-browserbase.d.ts","sourceRoot":"","sources":["../../src/scraper/session-browserbase.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAG3B,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"session-browserbase.d.ts","sourceRoot":"","sources":["../../src/scraper/session-browserbase.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAG3B,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAI9C;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,+BAA+B,CACnD,IAAI,CAAC,EAAE,IAAI,CAAC,qBAAqB,EAAE,iBAAiB,GAAG,gCAAgC,CAAC,GACvF,OAAO,CAAC,cAAc,CAAC,CAsHzB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeFilteredStagehandLogger = makeFilteredStagehandLogger;
|
|
3
4
|
exports.createBrowserbaseBrowserSession = createBrowserbaseBrowserSession;
|
|
4
5
|
const stagehand_1 = require("@browserbasehq/stagehand");
|
|
5
6
|
const config_1 = require("../config");
|
|
@@ -31,9 +32,11 @@ const logger = (0, logging_1.getLogger)({ name: "scraper/session-browserbase" })
|
|
|
31
32
|
* upstream Stagehand bug is universal across tenants.
|
|
32
33
|
*
|
|
33
34
|
* Returns the callback + a `reportSuppressed` function that the
|
|
34
|
-
* session teardown calls to log the final suppression count
|
|
35
|
-
*
|
|
36
|
-
*
|
|
35
|
+
* session teardown calls to log the final suppression count, plus a
|
|
36
|
+
* `getSuppressedCount` live accessor so callers can read the running
|
|
37
|
+
* total while a step is still executing — e.g. treating "resolver
|
|
38
|
+
* threw on this step" as evidence a reported-success click was
|
|
39
|
+
* phantom, without waiting for teardown.
|
|
37
40
|
*/
|
|
38
41
|
function makeFilteredStagehandLogger(pinoLogger) {
|
|
39
42
|
let suppressedCount = 0;
|
|
@@ -62,7 +65,8 @@ function makeFilteredStagehandLogger(pinoLogger) {
|
|
|
62
65
|
pinoLogger.info(`stagehand-logger: suppressed ${suppressedCount} AISDK elementId-regex errors (upstream Stagehand bug; cascade Fix 1B handles consequence)`);
|
|
63
66
|
}
|
|
64
67
|
};
|
|
65
|
-
|
|
68
|
+
const getSuppressedCount = () => suppressedCount;
|
|
69
|
+
return { callback, reportSuppressed, getSuppressedCount };
|
|
66
70
|
}
|
|
67
71
|
/**
|
|
68
72
|
* Spins up one Browserbase cloud session with the configured Stagehand LLM.
|
|
@@ -151,7 +155,7 @@ async function createBrowserbaseBrowserSession(opts) {
|
|
|
151
155
|
operatingSystems: ["windows"],
|
|
152
156
|
}
|
|
153
157
|
: baseFingerprint;
|
|
154
|
-
const { callback: stagehandLoggerCallback, reportSuppressed: reportSuppressedAisdkErrors } = makeFilteredStagehandLogger(logger);
|
|
158
|
+
const { callback: stagehandLoggerCallback, reportSuppressed: reportSuppressedAisdkErrors, getSuppressedCount: getSuppressedAisdkElementIdErrorCount, } = makeFilteredStagehandLogger(logger);
|
|
155
159
|
let stagehand;
|
|
156
160
|
try {
|
|
157
161
|
stagehand = new stagehand_1.Stagehand({
|
|
@@ -215,6 +219,7 @@ async function createBrowserbaseBrowserSession(opts) {
|
|
|
215
219
|
sessionId,
|
|
216
220
|
provider: "browserbase",
|
|
217
221
|
close,
|
|
222
|
+
getSuppressedAisdkElementIdErrorCount,
|
|
218
223
|
};
|
|
219
224
|
}
|
|
220
225
|
//# sourceMappingURL=session-browserbase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-browserbase.js","sourceRoot":"","sources":["../../src/scraper/session-browserbase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session-browserbase.js","sourceRoot":"","sources":["../../src/scraper/session-browserbase.ts"],"names":[],"mappings":";;;;AAAA,wDAA2F;AAE3F,qCAAkC;AAClC,2CAAmD;AACnD,yCAA8C;AAC9C,2CAA0C;AAC1C,6DAKkC;AAClC,iDAA0D;AAG1D,MAAM,MAAM,GAAG,IAAA,mBAAS,EAAC,EAAE,IAAI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GAAG,CAAC,EAAE,CAAC,CAAC;QACzF,CAAC;QACD,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,2BAA2B,EAAE,CAAC;IAChC,CAAC,CAAC;IAEF,OAAO;QACL,SAAS;QACT,OAAO;QACP,SAAS;QACT,QAAQ,EAAE,aAAa;QACvB,KAAK;QACL,qCAAqC;KACtC,CAAC;AACJ,CAAC"}
|
|
@@ -31,6 +31,12 @@ export interface BrowserSession {
|
|
|
31
31
|
/** Which provider produced this session — informational, useful for logs. */
|
|
32
32
|
provider: ProviderName;
|
|
33
33
|
close(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Live count of suppressed AISDK elementId-regex errors so far this
|
|
36
|
+
* session. Only present on providers that filter Stagehand's logger for
|
|
37
|
+
* this upstream error (currently Browserbase); absent on Steel.
|
|
38
|
+
*/
|
|
39
|
+
getSuppressedAisdkElementIdErrorCount?: () => number;
|
|
34
40
|
}
|
|
35
41
|
/**
|
|
36
42
|
* Returns a fetch wrapper that aborts after `timeoutMs` milliseconds.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-shared.d.ts","sourceRoot":"","sources":["../../src/scraper/session-shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AAIzC,8BAA8B;AAC9B,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,OAAO,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,MAAM,8BAA8B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACrE,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC3C,CAAC;AAEF,uDAAuD;AACvD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,eAAe,CAA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kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,KAAK,CAYlE;AAaD,wBAAgB,kBAAkB,IAAI;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAEtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-shared.js","sourceRoot":"","sources":["../../src/scraper/session-shared.ts"],"names":[],"mappings":";;;;AAGA,yCAA0C;
|
|
1
|
+
{"version":3,"file":"session-shared.js","sourceRoot":"","sources":["../../src/scraper/session-shared.ts"],"names":[],"mappings":";;;;AAGA,yCAA0C;AA4C1C;;;;GAIG;AACH,4BAAmC,SAAiB;IAClD,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACnB,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;QAC9D,kFAAkF;QAClF,gDAAgD;QAChD,MAAM,OAAO,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,CACtD,CAAC,CAAC,EAAoB,EAAE,CAAC,CAAC,YAAY,WAAW,CAClD,CAAC;QACF,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1E,OAAO,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5E,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,SAAS,GAAG;IAChB,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE;IAC5B,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE;IAC5B,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE;IAC5B,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;CACrB,CAAC;AAEX;IACE,OAAO,IAAA,mBAAU,EAAC,SAAS,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* the caller-supplied pRetry options. On exhaustion, wraps the last error in
|
|
6
6
|
* the caller-supplied `exhaustionError`.
|
|
7
7
|
*
|
|
8
|
-
* Extracted from
|
|
8
|
+
* Extracted from a plugin's token warmup so any future recon→generate warmup
|
|
9
9
|
* flow can reuse the session-lifecycle shell without re-hand-rolling pRetry +
|
|
10
10
|
* finally-close + error-mapping each time.
|
|
11
11
|
*/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* the caller-supplied pRetry options. On exhaustion, wraps the last error in
|
|
7
7
|
* the caller-supplied `exhaustionError`.
|
|
8
8
|
*
|
|
9
|
-
* Extracted from
|
|
9
|
+
* Extracted from a plugin's token warmup so any future recon→generate warmup
|
|
10
10
|
* flow can reuse the session-lifecycle shell without re-hand-rolling pRetry +
|
|
11
11
|
* finally-close + error-mapping each time.
|
|
12
12
|
*/
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Submit-control locator: ranks every submit-shaped candidate the deep
|
|
3
|
+
* resolver (`deep-query.ts`) can reach — piercing open shadow roots — so
|
|
4
|
+
* the cascade can act on the best-ranked candidate and retry the runner-up
|
|
5
|
+
* if the first click phantoms. A false-positive submit click on a real run
|
|
6
|
+
* (e.g. clicking "Save draft") is worse than the current failure, since it
|
|
7
|
+
* could submit a half-filled application — so ranking is deliberately
|
|
8
|
+
* conservative: only tiers with strong, unambiguous submit signal are
|
|
9
|
+
* included, and "Back"/"Cancel"/"Save draft"-shaped controls never appear.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Builds a self-contained `page.evaluate` expression string that walks the
|
|
13
|
+
* whole document (light DOM plus every open shadow root, arbitrarily deep)
|
|
14
|
+
* and returns every submit-shaped candidate ranked by confidence tier,
|
|
15
|
+
* highest first. Ties within a tier keep document order. Elements that
|
|
16
|
+
* match no positive tier — including anything caught by
|
|
17
|
+
* {@link NEGATIVE_TEXT_EXPR} — are excluded entirely rather than ranked
|
|
18
|
+
* last, so the caller never has to guess where the "safe" cutoff is.
|
|
19
|
+
*
|
|
20
|
+
* Each returned candidate carries `deepIndex`, the candidate's position in
|
|
21
|
+
* this same deterministic deep-traversal order. {@link buildClickByDeepIndexExpr}
|
|
22
|
+
* re-runs the identical traversal and clicks the element at that index, so
|
|
23
|
+
* the caller can locate once, decide which candidate to try, then click by
|
|
24
|
+
* index without holding a live element handle across the two round trips.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildRankSubmitCandidatesExpr(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Builds a self-contained `page.evaluate` expression string that re-runs
|
|
29
|
+
* the same deterministic deep traversal as {@link buildRankSubmitCandidatesExpr}
|
|
30
|
+
* and clicks the element at `deepIndex` (dispatching focus + bubbling
|
|
31
|
+
* mousedown/mouseup/click, matching `deep-query.ts`'s controlled-state click
|
|
32
|
+
* convention). Returns `{ clicked: false }` without throwing if the index is
|
|
33
|
+
* out of range for the current DOM (e.g. the page changed between the
|
|
34
|
+
* locate and click calls).
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildClickByDeepIndexExpr(deepIndex: number): string;
|
|
37
|
+
/** Confidence tier for a ranked submit candidate — higher is more confident. See {@link buildRankSubmitCandidatesExpr}. */
|
|
38
|
+
export type SubmitCandidateTier = 1 | 2 | 3;
|
|
39
|
+
/** One ranked candidate returned by {@link buildRankSubmitCandidatesExpr}'s `page.evaluate` call. */
|
|
40
|
+
export interface SubmitCandidate {
|
|
41
|
+
/** Position in the deterministic deep-traversal order; pass to {@link buildClickByDeepIndexExpr} to click this exact candidate. */
|
|
42
|
+
deepIndex: number;
|
|
43
|
+
tier: SubmitCandidateTier;
|
|
44
|
+
tag: string;
|
|
45
|
+
accessibleName: string;
|
|
46
|
+
}
|
|
47
|
+
/** Result of {@link buildClickByDeepIndexExpr}'s `page.evaluate` call. */
|
|
48
|
+
export interface ClickByDeepIndexResult {
|
|
49
|
+
clicked: boolean;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=submit-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submit-control.d.ts","sourceRoot":"","sources":["../../src/scraper/submit-control.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAyEH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,6BAA6B,IAAI,MAAM,CAsBtD;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAYnE;AAED,2HAA2H;AAC3H,MAAM,MAAM,mBAAmB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE5C,qGAAqG;AACrG,MAAM,WAAW,eAAe;IAC9B,mIAAmI;IACnI,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,0EAA0E;AAC1E,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;CAClB"}
|