@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
|
@@ -37,16 +37,25 @@
|
|
|
37
37
|
* `node_modules/@browserbasehq/stagehand/dist/esm/lib/v3/zodCompat.d.ts`).
|
|
38
38
|
* Barnacle uses Zod v4 via the `zod/v4` subpath export; that's compatible.
|
|
39
39
|
*/
|
|
40
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
+
};
|
|
40
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.StagehandSchemaError = exports.ACT_RESULT_SCHEMA = exports.ACTION_SCHEMA = void 0;
|
|
44
|
+
exports.StagehandSchemaError = exports.ACT_RESULT_SCHEMA = exports.ACTION_SCHEMA = exports.CLICK_INTENT_RE = void 0;
|
|
42
45
|
exports.guardedAct = guardedAct;
|
|
43
46
|
exports.guardedObserve = guardedObserve;
|
|
44
47
|
exports.guardedExtract = guardedExtract;
|
|
45
48
|
const node_crypto_1 = require("node:crypto");
|
|
49
|
+
const p_retry_1 = __importDefault(require("p-retry"));
|
|
46
50
|
const v4_1 = require("zod/v4");
|
|
51
|
+
const errors_1 = require("../lib/errors");
|
|
52
|
+
const logging_1 = require("../lib/logging");
|
|
53
|
+
const pii_redaction_1 = require("../lib/pii-redaction");
|
|
47
54
|
const call_capture_1 = require("../lib/telemetry/call-capture");
|
|
48
55
|
const call_types_1 = require("../lib/telemetry/call-types");
|
|
49
56
|
const frame_target_1 = require("./frame-target");
|
|
57
|
+
const transient_provider_error_1 = require("./transient-provider-error");
|
|
58
|
+
const trusted_click_1 = require("./trusted-click");
|
|
50
59
|
const watchdog_1 = require("./watchdog");
|
|
51
60
|
/**
|
|
52
61
|
* Fallback watchdog bound for a guarded call whose caller passes no
|
|
@@ -55,6 +64,28 @@ const watchdog_1 = require("./watchdog");
|
|
|
55
64
|
* `guardedObserve` from this module, so importing back would cycle.
|
|
56
65
|
*/
|
|
57
66
|
const DEFAULT_GUARD_TIMEOUT_MS = 120_000;
|
|
67
|
+
const logger = (0, logging_1.getLogger)({ name: "scraper/stagehand-guard" });
|
|
68
|
+
/** Instructions that name a click; only these are worth an observe to find a click point. */
|
|
69
|
+
exports.CLICK_INTENT_RE = /\bclick\b/i;
|
|
70
|
+
const TRANSIENT_RETRIES = 2;
|
|
71
|
+
const TRANSIENT_RETRY_MIN_TIMEOUT_MS = 500;
|
|
72
|
+
/**
|
|
73
|
+
* Retries a Stagehand call that failed with a transient provider error so a
|
|
74
|
+
* blip is not recorded as a failed technique. Wrap it OUTSIDE `withWatchdog`:
|
|
75
|
+
* each try gets its own watchdog timeout and the backoff is not charged to it.
|
|
76
|
+
* Safe for `act` because the provider 5xx is raised during Stagehand's
|
|
77
|
+
* inference request, before it performs any page action; the narrow
|
|
78
|
+
* classifier never matches selector, timeout, or schema errors raised after
|
|
79
|
+
* one.
|
|
80
|
+
*/
|
|
81
|
+
function retryTransient(call) {
|
|
82
|
+
return (0, p_retry_1.default)(call, {
|
|
83
|
+
retries: TRANSIENT_RETRIES,
|
|
84
|
+
minTimeout: TRANSIENT_RETRY_MIN_TIMEOUT_MS,
|
|
85
|
+
randomize: false,
|
|
86
|
+
shouldRetry: ({ error }) => (0, transient_provider_error_1.isTransientProviderError)(error),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
58
89
|
/**
|
|
59
90
|
* Zod parallel of Stagehand's public `Action` shape (from
|
|
60
91
|
* `@browserbasehq/stagehand/.../public/methods.d.ts`):
|
|
@@ -127,6 +158,41 @@ function safeStringify(value, cap = 4000) {
|
|
|
127
158
|
function actInstructionOf(input) {
|
|
128
159
|
return typeof input === "string" ? input : input.description;
|
|
129
160
|
}
|
|
161
|
+
function mergeVariables(options, variables) {
|
|
162
|
+
if (Object.keys(variables).length === 0)
|
|
163
|
+
return options;
|
|
164
|
+
return { ...options, variables: { ...options?.variables, ...variables } };
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Observe only needs the token names for its prompt (it never performs the
|
|
168
|
+
* action, so never substitutes): withhold the values so they are not shipped
|
|
169
|
+
* to the Stagehand API either. Plain strings, not the `{ value, description }`
|
|
170
|
+
* form, so the call stays inside the wire shape already proven against the API.
|
|
171
|
+
*/
|
|
172
|
+
function withheldVariables(variables) {
|
|
173
|
+
return Object.fromEntries(Object.keys(variables).map((name) => [name, ""]));
|
|
174
|
+
}
|
|
175
|
+
function detokenizeAction(action, variables) {
|
|
176
|
+
if (Object.keys(variables).length === 0)
|
|
177
|
+
return action;
|
|
178
|
+
return {
|
|
179
|
+
...action,
|
|
180
|
+
description: (0, pii_redaction_1.detokenize)(action.description, variables),
|
|
181
|
+
...(action.arguments
|
|
182
|
+
? { arguments: action.arguments.map((arg) => (0, pii_redaction_1.detokenize)(arg, variables)) }
|
|
183
|
+
: {}),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function detokenizeActResult(result, variables) {
|
|
187
|
+
if (Object.keys(variables).length === 0)
|
|
188
|
+
return result;
|
|
189
|
+
return {
|
|
190
|
+
...result,
|
|
191
|
+
message: (0, pii_redaction_1.detokenize)(result.message, variables),
|
|
192
|
+
actionDescription: (0, pii_redaction_1.detokenize)(result.actionDescription, variables),
|
|
193
|
+
actions: result.actions.map((action) => detokenizeAction(action, variables)),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
130
196
|
/**
|
|
131
197
|
* Merges `frameTarget.frameSelector` into `options.selector` for
|
|
132
198
|
* `ObserveOptions`/`ExtractOptions`, composed as Stagehand `">>"` hop
|
|
@@ -144,6 +210,79 @@ function frameScopedOptions(options, frameTarget) {
|
|
|
144
210
|
return options;
|
|
145
211
|
return { ...options, selector: (0, frame_target_1.buildHopSelector)(frameTarget.frameSelector, "*") };
|
|
146
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Resolves a string act instruction to the Action Stagehand would click so it
|
|
215
|
+
* can be centred first. Scoped to the step's frame the same way
|
|
216
|
+
* `guardedObserve` is, so an in-frame control is not resolved against the top
|
|
217
|
+
* document. Resolution is best-effort: when `observe` is unavailable, throws,
|
|
218
|
+
* or finds nothing, Stagehand's own string `act` resolves internally exactly
|
|
219
|
+
* as before.
|
|
220
|
+
*/
|
|
221
|
+
async function resolveClickAction(stagehand, instruction, options, frameTarget) {
|
|
222
|
+
if (typeof stagehand.observe !== "function" || !exports.CLICK_INTENT_RE.test(instruction)) {
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
const observeOptions = frameScopedOptions(options?.timeout ? { timeout: options.timeout } : {}, frameTarget);
|
|
226
|
+
const observed = await (0, watchdog_1.withWatchdog)(() => stagehand.observe(instruction, observeOptions), {
|
|
227
|
+
timeoutMs: options?.timeout ?? DEFAULT_GUARD_TIMEOUT_MS,
|
|
228
|
+
label: "stagehand-observe",
|
|
229
|
+
});
|
|
230
|
+
return observed[0];
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Stagehand's `act` clicks the content-box centre after only a
|
|
234
|
+
* `scrollIntoViewIfNeeded`, so a sticky overlay swallows the click. Centre +
|
|
235
|
+
* hit-test the click target first so Stagehand's own scroll is a no-op. String
|
|
236
|
+
* instructions are resolved via `observe` for the pre-centring only and still
|
|
237
|
+
* reach `act` as the original string, so downstream method/argument handling
|
|
238
|
+
* is unchanged. Frame-hop (`>>`) selectors are centred in the child frame they
|
|
239
|
+
* resolve to. Best-effort by design: a target that cannot be resolved or
|
|
240
|
+
* centred is logged and left to Stagehand's own delivery, because a click that
|
|
241
|
+
* lands on an overlay is caught as a phantom by the healing ladder and retried
|
|
242
|
+
* through the centred trusted-click path, whereas failing here would turn an
|
|
243
|
+
* act that would have run into a hard attempt failure. Non-click actions are
|
|
244
|
+
* skipped since there is no click point to clear.
|
|
245
|
+
*/
|
|
246
|
+
async function preCentreClickTarget(stagehand, input, options, frameTarget) {
|
|
247
|
+
try {
|
|
248
|
+
const page = typeof stagehand.context?.activePage === "function"
|
|
249
|
+
? stagehand.context.activePage()
|
|
250
|
+
: undefined;
|
|
251
|
+
const target = frameTarget ?? (page ? (0, frame_target_1.mainFrameTarget)(page) : undefined);
|
|
252
|
+
if (!target)
|
|
253
|
+
return;
|
|
254
|
+
const action = typeof input === "string"
|
|
255
|
+
? await resolveClickAction(stagehand, input, options, frameTarget)
|
|
256
|
+
: input;
|
|
257
|
+
if (action?.method !== "click")
|
|
258
|
+
return;
|
|
259
|
+
await centreAction(page, target, action);
|
|
260
|
+
}
|
|
261
|
+
catch (err) {
|
|
262
|
+
logger.warn(`pre-centring skipped: ${(0, errors_1.toErrorMessage)(err)}`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Centres and hit-tests an Action's click target, resolving a `>>` frame hop
|
|
267
|
+
* to the child frame the tail selector lives in.
|
|
268
|
+
*/
|
|
269
|
+
async function centreAction(page, target, action) {
|
|
270
|
+
const hopAt = action.selector.lastIndexOf(">>");
|
|
271
|
+
if (hopAt === -1) {
|
|
272
|
+
await (0, trusted_click_1.centreSelectorForClick)(target, action.selector, { label: action.selector });
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (!page) {
|
|
276
|
+
throw new Error(`no active page to resolve frame hop for ${action.selector}`);
|
|
277
|
+
}
|
|
278
|
+
const hopTarget = await (0, frame_target_1.resolveFrameTarget)(page, action.selector.slice(0, hopAt).trim());
|
|
279
|
+
if (hopTarget.declaredFrameSelector) {
|
|
280
|
+
throw new Error(`frame ${hopTarget.declaredFrameSelector} not attached; cannot centre click`);
|
|
281
|
+
}
|
|
282
|
+
await (0, trusted_click_1.centreSelectorForClick)(hopTarget, action.selector.slice(hopAt + 2).trim(), {
|
|
283
|
+
label: action.selector,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
147
286
|
/**
|
|
148
287
|
* Schema-guarded wrapper around Stagehand's `act`. Same signature as the
|
|
149
288
|
* underlying call: accepts either an instruction string or a structured
|
|
@@ -156,8 +295,11 @@ function frameScopedOptions(options, frameTarget) {
|
|
|
156
295
|
* receives the same `timeout` as before, but a call that ignores it and hangs
|
|
157
296
|
* now fails the attempt instead of blocking the step forever.
|
|
158
297
|
*
|
|
159
|
-
*
|
|
160
|
-
* `
|
|
298
|
+
* Click targets are centred and hit-tested before Stagehand acts (see
|
|
299
|
+
* `preCentreClickTarget`); a given `frameTarget` scopes that pass, and
|
|
300
|
+
* `preCentred` skips it when the caller already resolved and centred the
|
|
301
|
+
* target, so one click does not cost two observe calls. The
|
|
302
|
+
* trailing `frameTarget` param is not forwarded into
|
|
161
303
|
* `ActOptions` — `ActOptions` has no `selector` field, and its `page`
|
|
162
304
|
* override only accepts a full Playwright/Puppeteer/Patchright/understudy
|
|
163
305
|
* `Page`, not the `Frame` handle `FrameTarget.frame` exposes (the
|
|
@@ -168,11 +310,19 @@ function frameScopedOptions(options, frameTarget) {
|
|
|
168
310
|
* that `Action` — the `observe(...)[0] -> act(target)` pattern already used
|
|
169
311
|
* throughout `flow-runner.ts`.
|
|
170
312
|
*/
|
|
171
|
-
async function guardedAct(stagehand, input, options, captureFn,
|
|
313
|
+
async function guardedAct(stagehand, input, options, captureFn, frameTarget, preCentred = false) {
|
|
172
314
|
const callId = (0, node_crypto_1.randomUUID)();
|
|
173
|
-
|
|
315
|
+
// Request values travel as Stagehand `variables`, substituted only when
|
|
316
|
+
// the action is performed. An `Action` (from observe) is replayed without
|
|
317
|
+
// an LLM, so it keeps its literal arguments.
|
|
318
|
+
const tokenized = typeof input === "string" ? (0, pii_redaction_1.tokenizeSensitiveValues)(input) : { text: "", variables: {} };
|
|
319
|
+
const sendInput = typeof input === "string" ? tokenized.text : input;
|
|
320
|
+
const sendOptions = mergeVariables(options, tokenized.variables);
|
|
321
|
+
const userContent = actInstructionOf(sendInput);
|
|
174
322
|
const t0 = performance.now();
|
|
175
323
|
try {
|
|
324
|
+
if (!preCentred)
|
|
325
|
+
await preCentreClickTarget(stagehand, sendInput, sendOptions, frameTarget);
|
|
176
326
|
// Stagehand's `act` has two overloads (string and Action) that share the
|
|
177
327
|
// same runtime implementation (dispatch is via `isObserveResult` inside
|
|
178
328
|
// Stagehand). The two branches LOOK identical but TS can't resolve the
|
|
@@ -180,7 +330,9 @@ async function guardedAct(stagehand, input, options, captureFn, _frameTarget) {
|
|
|
180
330
|
// `stagehand.act` to a variable then calling it as a standalone function
|
|
181
331
|
// loses `this` in strict mode, which crashes inside Stagehand's
|
|
182
332
|
// `withInstanceLogContext(this.instanceId, ...)` wrapper on entry.
|
|
183
|
-
const raw = await (0, watchdog_1.withWatchdog)(() => typeof
|
|
333
|
+
const raw = await retryTransient(() => (0, watchdog_1.withWatchdog)(() => typeof sendInput === "string"
|
|
334
|
+
? stagehand.act(sendInput, sendOptions)
|
|
335
|
+
: stagehand.act(sendInput, sendOptions), { timeoutMs: options?.timeout ?? DEFAULT_GUARD_TIMEOUT_MS, label: "stagehand-act" }));
|
|
184
336
|
const latencyMs = performance.now() - t0;
|
|
185
337
|
const parsed = exports.ACT_RESULT_SCHEMA.safeParse(raw);
|
|
186
338
|
if (!parsed.success) {
|
|
@@ -208,7 +360,7 @@ async function guardedAct(stagehand, input, options, captureFn, _frameTarget) {
|
|
|
208
360
|
errorMessage: null,
|
|
209
361
|
failureKind: null,
|
|
210
362
|
}, captureFn);
|
|
211
|
-
return parsed.data;
|
|
363
|
+
return detokenizeActResult(parsed.data, tokenized.variables);
|
|
212
364
|
}
|
|
213
365
|
catch (err) {
|
|
214
366
|
if (err instanceof StagehandSchemaError)
|
|
@@ -250,17 +402,22 @@ async function guardedAct(stagehand, input, options, captureFn, _frameTarget) {
|
|
|
250
402
|
*/
|
|
251
403
|
async function guardedObserve(stagehand, instruction, options, captureFn, frameTarget) {
|
|
252
404
|
const callId = (0, node_crypto_1.randomUUID)();
|
|
253
|
-
const
|
|
405
|
+
const tokenized = instruction === undefined ? { text: "", variables: {} } : (0, pii_redaction_1.tokenizeSensitiveValues)(instruction);
|
|
406
|
+
const sendInstruction = instruction === undefined ? undefined : tokenized.text;
|
|
407
|
+
const userContent = sendInstruction ?? "";
|
|
254
408
|
const t0 = performance.now();
|
|
255
|
-
const scopedOptions = frameScopedOptions(options, frameTarget);
|
|
409
|
+
const scopedOptions = mergeVariables(frameScopedOptions(options, frameTarget), withheldVariables(tokenized.variables));
|
|
256
410
|
try {
|
|
257
411
|
// Match Stagehand's overloads: pass instruction only when defined, so
|
|
258
412
|
// the SDK falls through to its no-arg/options-only path otherwise.
|
|
259
|
-
const raw = await (0, watchdog_1.withWatchdog)(() =>
|
|
413
|
+
const raw = await retryTransient(() => (0, watchdog_1.withWatchdog)(() => sendInstruction === undefined
|
|
260
414
|
? scopedOptions === undefined
|
|
261
415
|
? stagehand.observe()
|
|
262
416
|
: stagehand.observe(scopedOptions)
|
|
263
|
-
: stagehand.observe(
|
|
417
|
+
: stagehand.observe(sendInstruction, scopedOptions), {
|
|
418
|
+
timeoutMs: scopedOptions?.timeout ?? DEFAULT_GUARD_TIMEOUT_MS,
|
|
419
|
+
label: "stagehand-observe",
|
|
420
|
+
}));
|
|
264
421
|
const latencyMs = performance.now() - t0;
|
|
265
422
|
const parsed = v4_1.z.array(exports.ACTION_SCHEMA).safeParse(raw);
|
|
266
423
|
if (!parsed.success) {
|
|
@@ -288,7 +445,13 @@ async function guardedObserve(stagehand, instruction, options, captureFn, frameT
|
|
|
288
445
|
errorMessage: null,
|
|
289
446
|
failureKind: null,
|
|
290
447
|
}, captureFn);
|
|
291
|
-
|
|
448
|
+
// Callers replay these actions directly (no substitution on that path),
|
|
449
|
+
// so tokens are resolved here; an action carrying a token the LLM
|
|
450
|
+
// invented would type it verbatim and is dropped.
|
|
451
|
+
return parsed.data
|
|
452
|
+
.map((action) => detokenizeAction(action, tokenized.variables))
|
|
453
|
+
.filter((action) => Object.keys(tokenized.variables).length === 0 ||
|
|
454
|
+
(action.arguments ?? []).every((arg) => (0, pii_redaction_1.unresolvedTokens)(arg, tokenized.variables).length === 0));
|
|
292
455
|
}
|
|
293
456
|
catch (err) {
|
|
294
457
|
if (err instanceof StagehandSchemaError)
|
|
@@ -336,7 +499,7 @@ async function guardedExtract(stagehand, instruction, schema, options, captureFn
|
|
|
336
499
|
// the cleanest public-API way to express "whatever overload-2 expects."
|
|
337
500
|
// The `as unknown` step is needed because TS won't accept a single
|
|
338
501
|
// direct cast across the entire overload set.
|
|
339
|
-
const raw = await (0, watchdog_1.withWatchdog)(() => stagehand.extract(instruction, schema, frameScopedOptions(options, frameTarget)), { timeoutMs: options?.timeout ?? DEFAULT_GUARD_TIMEOUT_MS, label: "stagehand-extract" });
|
|
502
|
+
const raw = await retryTransient(() => (0, watchdog_1.withWatchdog)(() => stagehand.extract(instruction, schema, frameScopedOptions(options, frameTarget)), { timeoutMs: options?.timeout ?? DEFAULT_GUARD_TIMEOUT_MS, label: "stagehand-extract" }));
|
|
340
503
|
const latencyMs = performance.now() - t0;
|
|
341
504
|
const parsed = schema.safeParse(raw);
|
|
342
505
|
if (!parsed.success) {
|
|
@@ -392,8 +555,13 @@ async function guardedExtract(stagehand, instruction, schema, options, captureFn
|
|
|
392
555
|
* `LlmCallInput` contract (which already supports null for those fields).
|
|
393
556
|
*/
|
|
394
557
|
async function captureCall(partial, captureFn = call_capture_1.captureLlmCall) {
|
|
558
|
+
// Replayed observe `Action`s keep literal arguments, so scrub here rather
|
|
559
|
+
// than relying on every caller-supplied sink to do it.
|
|
395
560
|
await captureFn({
|
|
396
561
|
...partial,
|
|
562
|
+
userContent: (0, pii_redaction_1.redactPii)(partial.userContent),
|
|
563
|
+
responseContent: partial.responseContent === null ? null : (0, pii_redaction_1.redactPii)(partial.responseContent),
|
|
564
|
+
errorMessage: partial.errorMessage === null ? null : (0, pii_redaction_1.redactPii)(partial.errorMessage),
|
|
397
565
|
model: "stagehand-internal",
|
|
398
566
|
systemPrompt: null,
|
|
399
567
|
inputTokens: null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stagehand-guard.js","sourceRoot":"","sources":["../../src/scraper/stagehand-guard.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;;;;;;AAEH,6CAAyC;AAUzC,+BAA2B;AAE3B,+DAIsC;AACtC,2DAIoC;AACpC,yDAA4E;AAC5E,iDAAkD;AAWlD;;;;;GAKG;AACH,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAEzC;;;;;;;;;;;;;;GAcG;AACU,QAAA,aAAa,GAAG,MAAC,CAAC,MAAM,CAAC;IACpC,QAAQ,EAAE,MAAC,CAAC,MAAM,EAAE;IACpB,WAAW,EAAE,MAAC,CAAC,MAAM,EAAE;IACvB,MAAM,EAAE,MAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,SAAS,EAAE,MAAC,CAAC,KAAK,CAAC,MAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC1C,CAAC,CAAC;AAEH;;;;;GAKG;AACU,QAAA,iBAAiB,GAAG,MAAC,CAAC,MAAM,CAAC;IACxC,OAAO,EAAE,MAAC,CAAC,OAAO,EAAE;IACpB,OAAO,EAAE,MAAC,CAAC,MAAM,EAAE;IACnB,iBAAiB,EAAE,MAAC,CAAC,MAAM,EAAE;IAC7B,OAAO,EAAE,MAAC,CAAC,KAAK,CAAC,QAAA,aAAa,CAAC;IAC/B,WAAW,EAAE,MAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,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AAE,IAAI;KACnB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -66,7 +66,7 @@ export declare const SUBMIT_SHAPE_EXPR = "((el) => {\n if (!el || !el.tagName)
|
|
|
66
66
|
* match no positive tier — including anything caught by
|
|
67
67
|
* {@link NEGATIVE_TEXT_EXPR} — are excluded entirely rather than ranked
|
|
68
68
|
* last, so the caller never has to guess where the "safe" cutoff is. Same
|
|
69
|
-
* treatment for a node that fails {@link
|
|
69
|
+
* treatment for a node that fails {@link ACTIONABLE_VISIBILITY_EXPR}: a hidden
|
|
70
70
|
* per-step submit button in a wizard (0x0 layout box, `display:none`) is
|
|
71
71
|
* dropped before ranking so it can never outrank the rendered one and win
|
|
72
72
|
* a click that would silently no-op. Same treatment again for a node that
|
|
@@ -100,7 +100,7 @@ export declare function buildRankSubmitCandidatesExpr(root?: string): string;
|
|
|
100
100
|
* out of range for the current DOM (e.g. the page changed between the
|
|
101
101
|
* locate and click calls), and `{ clicked: false, reason: "not-actionable" }`
|
|
102
102
|
* without dispatching any event if the element at that index fails
|
|
103
|
-
* {@link
|
|
103
|
+
* {@link ACTIONABLE_VISIBILITY_EXPR} or {@link IS_DISABLED_EXPR} — a node with no
|
|
104
104
|
* layout box makes a real click throw a CDP `-32000 Node does not have a
|
|
105
105
|
* layout object` error, and a disabled node accepts a synthetic click as a
|
|
106
106
|
* silent no-op, so this check reports the same outcome as data instead.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit-control.d.ts","sourceRoot":"","sources":["../../src/scraper/submit-control.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"submit-control.d.ts","sourceRoot":"","sources":["../../src/scraper/submit-control.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,sOAG5B,CAAC;AA0CJ;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,0BAA0B,s4CAyBpC,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iBAAiB,uoEAQ3B,CAAC;AA+CJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,SAAa,GAAG,MAAM,CA0BvE;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,SAAa,GAAG,MAAM,CAYtF;AAED,2HAA2H;AAC3H,MAAM,MAAM,mBAAmB,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAElD,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;IACjB,oKAAoK;IACpK,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B"}
|
|
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
exports.SUBMIT_SHAPE_EXPR = exports.SUBMIT_SHAPE_FALLBACK_EXPR = exports.NEGATIVE_TEXT_EXPR = void 0;
|
|
14
14
|
exports.buildRankSubmitCandidatesExpr = buildRankSubmitCandidatesExpr;
|
|
15
15
|
exports.buildClickByDeepIndexExpr = buildClickByDeepIndexExpr;
|
|
16
|
+
const actionable_visibility_expr_1 = require("./actionable-visibility-expr");
|
|
16
17
|
const browser_click_expr_1 = require("./browser-click-expr");
|
|
17
18
|
/**
|
|
18
19
|
* Verbs that identify a control as NOT the submit action even when it is
|
|
@@ -43,23 +44,6 @@ const ACCESSIBLE_NAME_EXPR = `((el) => {
|
|
|
43
44
|
const fallback = tag === "input" ? el.value : el.textContent;
|
|
44
45
|
return norm(el.getAttribute("aria-label") || fallback || "");
|
|
45
46
|
})`;
|
|
46
|
-
/**
|
|
47
|
-
* Visibility check: a node with a 0x0 layout box, or a computed
|
|
48
|
-
* `display:none`/`visibility:hidden`, can never be the target of a real
|
|
49
|
-
* click. Duplicated from `deep-locator-scan.ts`'s private `IS_VISIBLE_EXPR`
|
|
50
|
-
* rather than imported — both are browser-context expression strings
|
|
51
|
-
* composed by string interpolation, matching the convention this module
|
|
52
|
-
* already follows for {@link DEEP_ELEMENTS_EXPR}. Applied both when ranking
|
|
53
|
-
* (so an unrendered node never outranks a rendered one) and when clicking
|
|
54
|
-
* (so a node that became hidden between the rank and click calls is
|
|
55
|
-
* reported as not-actionable instead of dispatching a no-op click).
|
|
56
|
-
*/
|
|
57
|
-
const IS_VISIBLE_EXPR = `((el) => {
|
|
58
|
-
const rect = el.getBoundingClientRect();
|
|
59
|
-
if (rect.width === 0 && rect.height === 0) return false;
|
|
60
|
-
const style = getComputedStyle(el);
|
|
61
|
-
return style.display !== "none" && style.visibility !== "hidden";
|
|
62
|
-
})`;
|
|
63
47
|
/**
|
|
64
48
|
* Disabled check: a candidate carrying the native `disabled` property or
|
|
65
49
|
* `aria-disabled="true"` — on itself or an ancestor within
|
|
@@ -207,7 +191,7 @@ const RANK_TIERS_EXPR = `((el, name) => {
|
|
|
207
191
|
* match no positive tier — including anything caught by
|
|
208
192
|
* {@link NEGATIVE_TEXT_EXPR} — are excluded entirely rather than ranked
|
|
209
193
|
* last, so the caller never has to guess where the "safe" cutoff is. Same
|
|
210
|
-
* treatment for a node that fails {@link
|
|
194
|
+
* treatment for a node that fails {@link ACTIONABLE_VISIBILITY_EXPR}: a hidden
|
|
211
195
|
* per-step submit button in a wizard (0x0 layout box, `display:none`) is
|
|
212
196
|
* dropped before ranking so it can never outrank the rendered one and win
|
|
213
197
|
* a click that would silently no-op. Same treatment again for a node that
|
|
@@ -233,7 +217,7 @@ function buildRankSubmitCandidatesExpr(root = "document") {
|
|
|
233
217
|
return `(() => {
|
|
234
218
|
const accessibleName = ${ACCESSIBLE_NAME_EXPR};
|
|
235
219
|
const rankTier = ${RANK_TIERS_EXPR};
|
|
236
|
-
const isVisible = ${
|
|
220
|
+
const isVisible = ${actionable_visibility_expr_1.ACTIONABLE_VISIBILITY_EXPR};
|
|
237
221
|
const isDisabled = ${IS_DISABLED_EXPR};
|
|
238
222
|
const deepElements = ${browser_click_expr_1.DEEP_ELEMENTS_EXPR};
|
|
239
223
|
const all = deepElements(${root});
|
|
@@ -267,7 +251,7 @@ function buildRankSubmitCandidatesExpr(root = "document") {
|
|
|
267
251
|
* out of range for the current DOM (e.g. the page changed between the
|
|
268
252
|
* locate and click calls), and `{ clicked: false, reason: "not-actionable" }`
|
|
269
253
|
* without dispatching any event if the element at that index fails
|
|
270
|
-
* {@link
|
|
254
|
+
* {@link ACTIONABLE_VISIBILITY_EXPR} or {@link IS_DISABLED_EXPR} — a node with no
|
|
271
255
|
* layout box makes a real click throw a CDP `-32000 Node does not have a
|
|
272
256
|
* layout object` error, and a disabled node accepts a synthetic click as a
|
|
273
257
|
* silent no-op, so this check reports the same outcome as data instead.
|
|
@@ -282,7 +266,7 @@ function buildRankSubmitCandidatesExpr(root = "document") {
|
|
|
282
266
|
*/
|
|
283
267
|
function buildClickByDeepIndexExpr(deepIndex, root = "document") {
|
|
284
268
|
return `(() => {
|
|
285
|
-
const isVisible = ${
|
|
269
|
+
const isVisible = ${actionable_visibility_expr_1.ACTIONABLE_VISIBILITY_EXPR};
|
|
286
270
|
const isDisabled = ${IS_DISABLED_EXPR};
|
|
287
271
|
const deepElements = ${browser_click_expr_1.DEEP_ELEMENTS_EXPR};
|
|
288
272
|
const all = deepElements(${root});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit-control.js","sourceRoot":"","sources":["../../src/scraper/submit-control.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;AAEH,qEAIsC;AAEtC;;;;;;;;;GASG;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AkB;+BACd,IAAI;qBACd,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;;;MAGxC,IAAA,wCAAmB,EAAC,IAAI,CAAC;;OAExB,CAAC;AACR,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"target-resolution-diagnostic.d.ts","sourceRoot":"","sources":["../../src/scraper/target-resolution-diagnostic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"target-resolution-diagnostic.d.ts","sourceRoot":"","sources":["../../src/scraper/target-resolution-diagnostic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAIrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAC;AAoBlC,uIAAuI;AACvI,MAAM,WAAW,2BAA2B;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,oFAAoF;AACpF,MAAM,WAAW,kCAAkC;IACjD,0KAA0K;IAC1K,UAAU,EAAE,2BAA2B,EAAE,CAAC;IAC1C,4KAA4K;IAC5K,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAiED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,yCAAyC,CAC7D,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,IAAI,EAAE,IAAI,EACV,iBAAiB,CAAC,EAAE,eAAe,EAAE,GAAG,IAAI,GAC3C,OAAO,CAAC,kCAAkC,GAAG,IAAI,CAAC,CAyCpD"}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.captureTargetResolutionDiagnosticSnapshot = captureTargetResolutionDiagnosticSnapshot;
|
|
16
16
|
const logging_1 = require("../lib/logging");
|
|
17
|
+
const actionable_visibility_expr_1 = require("./actionable-visibility-expr");
|
|
17
18
|
const submit_control_1 = require("./submit-control");
|
|
18
19
|
const logger = (0, logging_1.getLogger)({ name: "scraper/target-resolution-diagnostic" });
|
|
19
20
|
/** Cap on the number of ranked candidates kept in a snapshot. */
|
|
@@ -31,11 +32,10 @@ const MAX_SNAPSHOT_JSON_LENGTH = 20_000;
|
|
|
31
32
|
const MAX_EXCERPT_LENGTH = 2_000;
|
|
32
33
|
/**
|
|
33
34
|
* Re-walks the light DOM plus every open shadow root (same traversal shape
|
|
34
|
-
* as `submit-control.ts`'s private `DEEP_ELEMENTS_EXPR
|
|
35
|
-
* than imported
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* shared) to read the role/visible/disabled/excerpt fields the ranking
|
|
35
|
+
* as `submit-control.ts`'s private `DEEP_ELEMENTS_EXPR`, duplicated rather
|
|
36
|
+
* than imported; visibility comes from the shared
|
|
37
|
+
* {@link ACTIONABLE_VISIBILITY_EXPR} so an `aria-hidden` decoy is never
|
|
38
|
+
* reported visible) to read the role/visible/disabled/excerpt fields the ranking
|
|
39
39
|
* expression itself doesn't return, and to build a short accessible-name
|
|
40
40
|
* excerpt around the top-ranked candidate. Runs as a single `page.evaluate`
|
|
41
41
|
* round trip so the DOM observed here always matches the one
|
|
@@ -55,12 +55,7 @@ function buildCandidateDetailExpr(root, deepIndices) {
|
|
|
55
55
|
walk(rootEl);
|
|
56
56
|
return out;
|
|
57
57
|
})(${root});
|
|
58
|
-
const isVisible =
|
|
59
|
-
const rect = el.getBoundingClientRect();
|
|
60
|
-
if (rect.width === 0 && rect.height === 0) return false;
|
|
61
|
-
const style = getComputedStyle(el);
|
|
62
|
-
return style.display !== "none" && style.visibility !== "hidden";
|
|
63
|
-
};
|
|
58
|
+
const isVisible = ${actionable_visibility_expr_1.ACTIONABLE_VISIBILITY_EXPR};
|
|
64
59
|
const isDisabled = (el) => {
|
|
65
60
|
for (let depth = 0, node = el; depth < 8 && node; depth++) {
|
|
66
61
|
if (node.disabled === true) return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"target-resolution-diagnostic.js","sourceRoot":"","sources":["../../src/scraper/target-resolution-diagnostic.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAIH,2CAA0C;
|
|
1
|
+
{"version":3,"file":"target-resolution-diagnostic.js","sourceRoot":"","sources":["../../src/scraper/target-resolution-diagnostic.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAIH,2CAA0C;AAC1C,qFAAkF;AAElF,6DAIkC;AAElC,MAAM,MAAM,GAAG,IAAA,mBAAS,EAAC,EAAE,IAAI,EAAE,sCAAsC,EAAE,CAAC,CAAC;AAE3E,iEAAiE;AACjE,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC;;;;;;;GAOG;AACH,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAExC,mFAAmF;AACnF,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAoBjC;;;;;;;;;;GAUG;AACH,SAAS,wBAAwB,CAAC,IAAY,EAAE,WAA8B;IAC5E,OAAO;;;;;;;;;;;;SAYA,IAAI;wBACW,uDAA0B;;;;;;;;;;;;;;;;;;sBAkB5B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;;;;;;;;;;;;;;oBAc7B,kBAAkB;;;OAG/B,CAAC;AACR,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACI,KAAK,oDACV,MAA+B,EAC/B,IAAU,EACV,iBAA4C;IAE5C,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,IAAI,IAAI,CAAC;Q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,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;YAC/E,oBAAoB,EAAE,QAAQ,CAAC,oBAAoB;SACpD,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,4DAA4D,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzF,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One site-agnostic definition of a transient model-provider failure (5xx,
|
|
3
|
+
* overload, connection reset raised at inference) so the call guard and the
|
|
4
|
+
* replan guard agree. Structured status/code fields win; message text is a
|
|
5
|
+
* fallback only for provider-wrapped errors that carry no status.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isTransientProviderError(err: unknown): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Tells whether a failure dump's attempts[] errorMessage values are
|
|
10
|
+
* transient, so the replan guard can avoid treating a provider outage as a
|
|
11
|
+
* verdict about the step. `all` requires at least one message.
|
|
12
|
+
*/
|
|
13
|
+
export declare function summarizeAttemptTransience(attempts: ReadonlyArray<{
|
|
14
|
+
errorMessage?: string | null;
|
|
15
|
+
}>): {
|
|
16
|
+
all: boolean;
|
|
17
|
+
any: boolean;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=transient-provider-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transient-provider-error.d.ts","sourceRoot":"","sources":["../../src/scraper/transient-provider-error.ts"],"names":[],"mappings":"AAuBA;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAc9D;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,aAAa,CAAC;IAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,GACxD;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,OAAO,CAAA;CAAE,CAMhC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTransientProviderError = isTransientProviderError;
|
|
4
|
+
exports.summarizeAttemptTransience = summarizeAttemptTransience;
|
|
5
|
+
const TRANSIENT_STATUS_CODES = new Set([429, 529]);
|
|
6
|
+
const TRANSIENT_ERROR_CODES = new Set([
|
|
7
|
+
"ECONNRESET",
|
|
8
|
+
"ETIMEDOUT",
|
|
9
|
+
"EPIPE",
|
|
10
|
+
"ECONNREFUSED",
|
|
11
|
+
"EAI_AGAIN",
|
|
12
|
+
]);
|
|
13
|
+
const TRANSIENT_MESSAGE_RX = /internal server error|\boverloaded\b|bad gateway|service unavailable|gateway time-?out|socket hang up|\bECONNRESET\b|connection reset|\b(?:5\d\d)\s+(?:internal|bad|service|gateway)/i;
|
|
14
|
+
function readStatus(obj) {
|
|
15
|
+
for (const key of ["status", "statusCode"]) {
|
|
16
|
+
const value = obj[key];
|
|
17
|
+
if (typeof value === "number")
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
function readCode(obj) {
|
|
23
|
+
return typeof obj.code === "string" ? obj.code : null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* One site-agnostic definition of a transient model-provider failure (5xx,
|
|
27
|
+
* overload, connection reset raised at inference) so the call guard and the
|
|
28
|
+
* replan guard agree. Structured status/code fields win; message text is a
|
|
29
|
+
* fallback only for provider-wrapped errors that carry no status.
|
|
30
|
+
*/
|
|
31
|
+
function isTransientProviderError(err) {
|
|
32
|
+
if (typeof err === "object" && err !== null) {
|
|
33
|
+
const obj = err;
|
|
34
|
+
const status = readStatus(obj);
|
|
35
|
+
if (status !== null)
|
|
36
|
+
return (status >= 500 && status < 600) || TRANSIENT_STATUS_CODES.has(status);
|
|
37
|
+
const code = readCode(obj);
|
|
38
|
+
if (code !== null && TRANSIENT_ERROR_CODES.has(code))
|
|
39
|
+
return true;
|
|
40
|
+
if (obj.cause !== undefined && obj.cause !== err && isTransientProviderError(obj.cause)) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const message = err instanceof Error ? err.message : typeof err === "string" ? err : "";
|
|
45
|
+
return TRANSIENT_MESSAGE_RX.test(message);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Tells whether a failure dump's attempts[] errorMessage values are
|
|
49
|
+
* transient, so the replan guard can avoid treating a provider outage as a
|
|
50
|
+
* verdict about the step. `all` requires at least one message.
|
|
51
|
+
*/
|
|
52
|
+
function summarizeAttemptTransience(attempts) {
|
|
53
|
+
const messages = attempts
|
|
54
|
+
.map((a) => a.errorMessage)
|
|
55
|
+
.filter((m) => typeof m === "string" && m.length > 0);
|
|
56
|
+
const flags = messages.map((m) => isTransientProviderError(new Error(m)));
|
|
57
|
+
return { all: flags.length > 0 && flags.every(Boolean), any: flags.some(Boolean) };
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=transient-provider-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transient-provider-error.js","sourceRoot":"","sources":["../../src/scraper/transient-provider-error.ts"],"names":[],"mappings":";;;;AAAA,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AACxE,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAC;IACzD,YAAY;IACZ,WAAW;IACX,OAAO;IACP,cAAc;IACd,WAAW;CACZ,CAAC,CAAC;AACH,MAAM,oBAAoB,GACxB,uLAAuL,CAAC;AAE1L,SAAS,UAAU,CAAC,GAA4B;IAC9C,KAAK,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC;QAC3C,MAAM,KAAK,G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