@enricai/barnacle 1.6.9 → 1.6.11

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.
Files changed (93) hide show
  1. package/README.md +71 -3
  2. package/dist/api/routes/submissions.d.ts +21 -0
  3. package/dist/api/routes/submissions.d.ts.map +1 -0
  4. package/dist/api/routes/submissions.js +48 -0
  5. package/dist/api/routes/submissions.js.map +1 -0
  6. package/dist/api/schemas/submissions.d.ts +110 -0
  7. package/dist/api/schemas/submissions.d.ts.map +1 -0
  8. package/dist/api/schemas/submissions.js +77 -0
  9. package/dist/api/schemas/submissions.js.map +1 -0
  10. package/dist/config.d.ts +34 -0
  11. package/dist/config.d.ts.map +1 -1
  12. package/dist/config.js +5 -0
  13. package/dist/config.js.map +1 -1
  14. package/dist/lib/telemetry/beacon-capture.d.ts +37 -0
  15. package/dist/lib/telemetry/beacon-capture.d.ts.map +1 -0
  16. package/dist/lib/telemetry/beacon-capture.js +47 -0
  17. package/dist/lib/telemetry/beacon-capture.js.map +1 -0
  18. package/dist/lib/telemetry/reconciliation-record.d.ts +105 -0
  19. package/dist/lib/telemetry/reconciliation-record.d.ts.map +1 -0
  20. package/dist/lib/telemetry/reconciliation-record.js +76 -0
  21. package/dist/lib/telemetry/reconciliation-record.js.map +1 -0
  22. package/dist/lib/telemetry/reconciliation-source.d.ts +33 -0
  23. package/dist/lib/telemetry/reconciliation-source.d.ts.map +1 -0
  24. package/dist/lib/telemetry/reconciliation-source.js +91 -0
  25. package/dist/lib/telemetry/reconciliation-source.js.map +1 -0
  26. package/dist/lib/telemetry/s3-sink.d.ts.map +1 -1
  27. package/dist/lib/telemetry/s3-sink.js +1 -2
  28. package/dist/lib/telemetry/s3-sink.js.map +1 -1
  29. package/dist/lib/telemetry/submission-capture.d.ts +30 -9
  30. package/dist/lib/telemetry/submission-capture.d.ts.map +1 -1
  31. package/dist/lib/telemetry/submission-capture.js +32 -21
  32. package/dist/lib/telemetry/submission-capture.js.map +1 -1
  33. package/dist/lib/telemetry/submission-query.d.ts +32 -0
  34. package/dist/lib/telemetry/submission-query.d.ts.map +1 -0
  35. package/dist/lib/telemetry/submission-query.js +49 -0
  36. package/dist/lib/telemetry/submission-query.js.map +1 -0
  37. package/dist/lib/telemetry/submission-reader.d.ts +52 -0
  38. package/dist/lib/telemetry/submission-reader.d.ts.map +1 -0
  39. package/dist/lib/telemetry/submission-reader.js +111 -0
  40. package/dist/lib/telemetry/submission-reader.js.map +1 -0
  41. package/dist/lib/telemetry/submissions-s3-objects.d.ts +23 -0
  42. package/dist/lib/telemetry/submissions-s3-objects.d.ts.map +1 -0
  43. package/dist/lib/telemetry/submissions-s3-objects.js +132 -0
  44. package/dist/lib/telemetry/submissions-s3-objects.js.map +1 -0
  45. package/dist/lib/telemetry/submissions-s3-reader.d.ts +25 -0
  46. package/dist/lib/telemetry/submissions-s3-reader.d.ts.map +1 -0
  47. package/dist/lib/telemetry/submissions-s3-reader.js +63 -0
  48. package/dist/lib/telemetry/submissions-s3-reader.js.map +1 -0
  49. package/dist/lib/tracking-click.d.ts +13 -2
  50. package/dist/lib/tracking-click.d.ts.map +1 -1
  51. package/dist/lib/tracking-click.js +42 -4
  52. package/dist/lib/tracking-click.js.map +1 -1
  53. package/dist/plugins/loader.d.ts +17 -3
  54. package/dist/plugins/loader.d.ts.map +1 -1
  55. package/dist/plugins/loader.js +59 -6
  56. package/dist/plugins/loader.js.map +1 -1
  57. package/dist/scraper/cookie-jar.d.ts +10 -4
  58. package/dist/scraper/cookie-jar.d.ts.map +1 -1
  59. package/dist/scraper/cookie-jar.js +10 -5
  60. package/dist/scraper/cookie-jar.js.map +1 -1
  61. package/dist/scraper/deep-locator-candidates.d.ts +84 -0
  62. package/dist/scraper/deep-locator-candidates.d.ts.map +1 -0
  63. package/dist/scraper/deep-locator-candidates.js +206 -0
  64. package/dist/scraper/deep-locator-candidates.js.map +1 -0
  65. package/dist/scraper/deep-locator-fake.d.ts +116 -0
  66. package/dist/scraper/deep-locator-fake.d.ts.map +1 -0
  67. package/dist/scraper/deep-locator-fake.js +128 -0
  68. package/dist/scraper/deep-locator-fake.js.map +1 -0
  69. package/dist/scraper/flow-runner.d.ts +28 -1
  70. package/dist/scraper/flow-runner.d.ts.map +1 -1
  71. package/dist/scraper/flow-runner.js +204 -14
  72. package/dist/scraper/flow-runner.js.map +1 -1
  73. package/dist/scraper/frame-target.d.ts +60 -14
  74. package/dist/scraper/frame-target.d.ts.map +1 -1
  75. package/dist/scraper/frame-target.js +126 -38
  76. package/dist/scraper/frame-target.js.map +1 -1
  77. package/dist/scraper/stagehand-guard.d.ts +14 -0
  78. package/dist/scraper/stagehand-guard.d.ts.map +1 -1
  79. package/dist/scraper/stagehand-guard.js +28 -8
  80. package/dist/scraper/stagehand-guard.js.map +1 -1
  81. package/dist/scraper/watchdog.d.ts +38 -0
  82. package/dist/scraper/watchdog.d.ts.map +1 -0
  83. package/dist/scraper/watchdog.js +54 -0
  84. package/dist/scraper/watchdog.js.map +1 -0
  85. package/dist/scripts/recon-browser.d.ts.map +1 -1
  86. package/dist/scripts/recon-browser.js +14 -3
  87. package/dist/scripts/recon-browser.js.map +1 -1
  88. package/dist/server.d.ts.map +1 -1
  89. package/dist/server.js +2 -0
  90. package/dist/server.js.map +1 -1
  91. package/dist/site-plugin.d.ts +12 -0
  92. package/dist/site-plugin.d.ts.map +1 -1
  93. package/package.json +1 -1
@@ -26,6 +26,20 @@ export interface FrameTarget {
26
26
  readonly frame: StagehandFrame | null;
27
27
  /** CSS selector for the Stagehand scope hint (`ObserveOptions.selector` / `ExtractOptions.selector`), or `null` for the main frame. */
28
28
  readonly frameSelector: string | null;
29
+ /**
30
+ * The frame selector a caller originally asked `resolveFrameTarget` to bind
31
+ * to, kept even when resolution fails and this target falls back to the
32
+ * main frame (`frameSelector: null`). `frameSelector` stays `null` on a
33
+ * failed resolution because it un-scopes `ObserveOptions.selector` via
34
+ * `stagehand-guard`'s `frameScopedOptions` — that contract must not change.
35
+ * This field is the separate, additive signal a caller can use to notice
36
+ * "the frame I asked for didn't attach" and retry resolution later, e.g.
37
+ * right before a deepLocator candidate probe. `undefined` on targets built
38
+ * outside `resolveFrameTarget` (hand-constructed test fakes, older call
39
+ * sites) rather than a required field, so it never forces every existing
40
+ * `FrameTarget` literal to be updated.
41
+ */
42
+ readonly declaredFrameSelector?: string | null;
29
43
  /** Evaluate a function or expression against the resolved frame (or the main frame when unresolved). */
30
44
  evaluate<R = unknown, Arg = unknown>(pageFunctionOrExpression: string | ((arg: Arg) => R | Promise<R>), arg?: Arg): Promise<R>;
31
45
  /** Build a Locator scoped to the resolved frame (or the main frame when unresolved). */
@@ -36,17 +50,24 @@ export interface FrameTarget {
36
50
  title(): Promise<string>;
37
51
  }
38
52
  /**
39
- * Builds the main-frame `FrameTarget`: every method delegates straight to
40
- * `Page`, matching today's behavior for every site whose ATS form never
41
- * leaves the top window. Exported so call sites that have not yet resolved
42
- * a `FrameTarget` from `deps.frameSelector` can still pass a target-shaped
43
- * value to helpers that now require one.
53
+ * Builds the main-frame `FrameTarget`: every method delegates to `Page`,
54
+ * matching today's behavior for every site whose ATS form never leaves the
55
+ * top window. `evaluate`/`title` are bounded by a watchdog a wedged CDP
56
+ * call (e.g. a racy Browserbase session) must fail the caller's await
57
+ * instead of hanging it, since `evaluate`/`url` are the first awaits inside
58
+ * `flow-runner.ts`'s per-attempt snapshot, ahead of any attempt log.
59
+ * Exported so call sites that have not yet resolved a `FrameTarget` from
60
+ * `deps.frameSelector` can still pass a target-shaped value to helpers that
61
+ * now require one.
44
62
  */
45
- export declare function mainFrameTarget(page: Page): FrameTarget;
63
+ export declare function mainFrameTarget(page: Page, opts?: {
64
+ declaredFrameSelector?: string | null;
65
+ evaluateTimeoutMs?: number;
66
+ }): FrameTarget;
46
67
  /**
47
68
  * Resolves the `FrameTarget` for `frameSelector` against `page`, polling for
48
- * up to `FRAME_READY_TIMEOUT_MS` (at `FRAME_READY_POLL_MS` intervals) before
49
- * falling back to the main-frame target rather than throwing:
69
+ * up to `timeoutMs` (at `pollMs` intervals) before falling back to the
70
+ * main-frame target rather than throwing:
50
71
  *
51
72
  * 1. `frameSelector` is `null`/`undefined` → main-frame target (today's
52
73
  * behavior, unchanged) — zero polling, zero delay.
@@ -54,22 +75,36 @@ export declare function mainFrameTarget(page: Page): FrameTarget;
54
75
  * it isn't an `<iframe>`, or its `src` can't be read and more than one
55
76
  * `page.frames()` candidate exists (identity match is ambiguous), or no
56
77
  * `page.frames()` entry has a matching origin yet → try again after
57
- * `FRAME_READY_POLL_MS`.
78
+ * `pollMs`.
58
79
  * 3. A poll finds a matching frame → a child-frame target bound to it,
59
80
  * however many polls it took (an iframe created mid-flow by an earlier
60
81
  * step, e.g. after a click reveals it, resolves as soon as Stagehand's
61
82
  * CDP layer attaches to it instead of only when present at the first
62
83
  * poll).
63
- * 4. Still unresolved once the deadline passes → main-frame target, with a
64
- * `warn` naming the selector so a silent revert-to-main-frame is
65
- * diagnosable from the log instead of invisible.
84
+ * 4. Still unresolved once the deadline passes → main-frame target carrying
85
+ * `declaredFrameSelector` (so a caller can notice the failure and retry
86
+ * resolution later), with a `warn` naming the selector so a silent
87
+ * revert-to-main-frame is diagnosable from the log instead of invisible.
66
88
  *
67
- * `opts` overrides the poll timing for tests; production call sites rely on
68
- * the `FRAME_READY_TIMEOUT_MS`/`FRAME_READY_POLL_MS` defaults.
89
+ * Every `page`/`Frame` `evaluate` call this function (transitively) makes is
90
+ * bounded by `evaluateTimeoutMs`, further clamped to whatever remains of the
91
+ * total attach `deadline` at the moment each probe starts — including the
92
+ * very first resolution attempt made *before* the poll loop starts. Without
93
+ * that clamp, a single wedged CDP call there hangs this function for up to
94
+ * `evaluateTimeoutMs`, and a page with several `page.frames()` candidates
95
+ * multiplies that by each candidate probed in the same pass, which is
96
+ * exactly what made the declared attach deadline (`timeoutMs`) unenforceable
97
+ * whenever `evaluateTimeoutMs` exceeded it.
98
+ *
99
+ * `opts` overrides the timing for tests; production call sites default from
100
+ * `config.scraper.frameReadyTimeoutMs` / `frameEvaluateTimeoutMs` (poll
101
+ * cadence stays the fixed `FRAME_READY_POLL_MS`, cheap enough not to need
102
+ * tuning).
69
103
  */
70
104
  export declare function resolveFrameTarget(page: Page, frameSelector?: string | null, opts?: {
71
105
  timeoutMs?: number;
72
106
  pollMs?: number;
107
+ evaluateTimeoutMs?: number;
73
108
  }): Promise<FrameTarget>;
74
109
  /**
75
110
  * Composes a Stagehand hop-notation scope string from a frame selector and an
@@ -89,10 +124,21 @@ export declare function sleep(ms: number): Promise<void>;
89
124
  * navigation lands. Best-effort like `waitForSpaReady`: never throws, just resolves
90
125
  * once ready or once `timeoutMs` elapses, so a frame that never becomes ready
91
126
  * degrades to "proceed anyway" rather than hanging the flow.
127
+ *
128
+ * Each `document.readyState` probe is itself bounded by `evaluateTimeoutMs` and
129
+ * treated as not-ready on timeout (same as a rejected `evaluate`) — otherwise a
130
+ * single wedged CDP call inside one poll would block past `timeoutMs`, defeating
131
+ * the outer deadline this function exists to enforce.
132
+ *
133
+ * `opts` overrides the timing for tests; production call sites default from
134
+ * `config.scraper.frameDocumentReadyTimeoutMs` / `frameEvaluateTimeoutMs` — kept
135
+ * separate from `resolveFrameTarget`'s (longer) attach budget since this wait
136
+ * settles in well under a second once the frame has attached.
92
137
  */
93
138
  export declare function waitForChildFrameReady(target: FrameTarget, opts?: {
94
139
  timeoutMs?: number;
95
140
  pollMs?: number;
141
+ evaluateTimeoutMs?: number;
96
142
  }): Promise<void>;
97
143
  export {};
98
144
  //# sourceMappingURL=frame-target.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"frame-target.d.ts","sourceRoot":"","sources":["../../src/scraper/frame-target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAMrD,kHAAkH;AAClH,KAAK,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,MA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MAAM,CAAC,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,IAAI,EACV,IAAI,GAAE;IAAE,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/E,WAAW,CAmBb;AAwJD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,EACV,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,EAC7B,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAO,GAC7E,OAAO,CAAC,WAAW,CAAC,CAqBtB;AAID;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACxC,aAAa,EAAE,MAAM,GACpB,MAAM,CAOR;AAKD,+FAA+F;AAC/F,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,WAAW,EACnB,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAO,GAC7E,OAAO,CAAC,IAAI,CAAC,CAyBf"}
@@ -17,23 +17,37 @@ exports.resolveFrameTarget = resolveFrameTarget;
17
17
  exports.buildHopSelector = buildHopSelector;
18
18
  exports.sleep = sleep;
19
19
  exports.waitForChildFrameReady = waitForChildFrameReady;
20
+ const config_1 = require("../config");
20
21
  const logging_1 = require("../lib/logging");
22
+ const watchdog_1 = require("../scraper/watchdog");
21
23
  const logger = (0, logging_1.getLogger)({ name: "scraper/frame-target" });
22
24
  /**
23
- * Builds the main-frame `FrameTarget`: every method delegates straight to
24
- * `Page`, matching today's behavior for every site whose ATS form never
25
- * leaves the top window. Exported so call sites that have not yet resolved
26
- * a `FrameTarget` from `deps.frameSelector` can still pass a target-shaped
27
- * value to helpers that now require one.
25
+ * Builds the main-frame `FrameTarget`: every method delegates to `Page`,
26
+ * matching today's behavior for every site whose ATS form never leaves the
27
+ * top window. `evaluate`/`title` are bounded by a watchdog a wedged CDP
28
+ * call (e.g. a racy Browserbase session) must fail the caller's await
29
+ * instead of hanging it, since `evaluate`/`url` are the first awaits inside
30
+ * `flow-runner.ts`'s per-attempt snapshot, ahead of any attempt log.
31
+ * Exported so call sites that have not yet resolved a `FrameTarget` from
32
+ * `deps.frameSelector` can still pass a target-shaped value to helpers that
33
+ * now require one.
28
34
  */
29
- function mainFrameTarget(page) {
35
+ function mainFrameTarget(page, opts = {}) {
36
+ const evaluateTimeoutMs = opts.evaluateTimeoutMs ?? config_1.config.scraper.frameEvaluateTimeoutMs;
30
37
  return {
31
38
  frame: null,
32
39
  frameSelector: null,
33
- evaluate: (pageFunctionOrExpression, arg) => page.evaluate(pageFunctionOrExpression, arg),
40
+ declaredFrameSelector: opts.declaredFrameSelector ?? null,
41
+ evaluate: (pageFunctionOrExpression, arg) => (0, watchdog_1.withWatchdog)(() => page.evaluate(pageFunctionOrExpression, arg), {
42
+ timeoutMs: evaluateTimeoutMs,
43
+ label: "frame-target: main frame evaluate",
44
+ }),
34
45
  locator: (selector) => page.locator(selector),
35
46
  url: () => Promise.resolve(page.url()),
36
- title: () => page.title(),
47
+ title: () => (0, watchdog_1.withWatchdog)(() => page.title(), {
48
+ timeoutMs: evaluateTimeoutMs,
49
+ label: "frame-target: main frame title",
50
+ }),
37
51
  };
38
52
  }
39
53
  /**
@@ -41,16 +55,27 @@ function mainFrameTarget(page) {
41
55
  * resolved `Frame` (reaching across the cross-origin boundary via its own
42
56
  * CDP session), while `url`/`title` fall back to the frame's own
43
57
  * `location.href` and the top document's title respectively — `Frame` has
44
- * no `title()` of its own.
58
+ * no `title()` of its own. `evaluate`/`url`/`title` are bounded by the same
59
+ * watchdog as `mainFrameTarget` (`locator` stays unwrapped — it's
60
+ * synchronous, building a `Locator` handle rather than making a CDP call).
45
61
  */
46
- function childFrameTarget(page, frame, frameSelector) {
62
+ function childFrameTarget(page, frame, frameSelector, opts = {}) {
63
+ const evaluateTimeoutMs = opts.evaluateTimeoutMs ?? config_1.config.scraper.frameEvaluateTimeoutMs;
64
+ const evaluateOnFrame = (pageFunctionOrExpression, arg) => (0, watchdog_1.withWatchdog)(() => frame.evaluate(pageFunctionOrExpression, arg), {
65
+ timeoutMs: evaluateTimeoutMs,
66
+ label: "frame-target: child frame evaluate",
67
+ });
47
68
  return {
48
69
  frame,
49
70
  frameSelector,
50
- evaluate: (pageFunctionOrExpression, arg) => frame.evaluate(pageFunctionOrExpression, arg),
71
+ declaredFrameSelector: frameSelector,
72
+ evaluate: evaluateOnFrame,
51
73
  locator: (selector) => frame.locator(selector),
52
- url: () => frame.evaluate("location.href"),
53
- title: () => page.title(),
74
+ url: () => evaluateOnFrame("location.href"),
75
+ title: () => (0, watchdog_1.withWatchdog)(() => page.title(), {
76
+ timeoutMs: evaluateTimeoutMs,
77
+ label: "frame-target: child frame title",
78
+ }),
54
79
  };
55
80
  }
56
81
  /**
@@ -89,14 +114,45 @@ function originOf(url) {
89
114
  * beyond the main frame, that frame must be the one CDP attached to for
90
115
  * this iframe, so bind to it directly rather than degrading to the main
91
116
  * frame.
117
+ *
118
+ * Both `evaluate` calls (the top-level `<iframe>`-src probe and the
119
+ * per-candidate `location.href` read) are bounded by `evaluateTimeoutMs`,
120
+ * further clamped to whatever remains of `deadline` — `resolveFrameTarget`'s
121
+ * total attach budget — at the moment each probe starts: a wedged CDP call
122
+ * against a racy OOPIF must fail this one pass rather than hanging it, and
123
+ * the clamp keeps that true even for the *sum* of every probe a single pass
124
+ * makes, since the top-level probe runs once *before* `resolveFrameTarget`'s
125
+ * poll loop even starts (making an unclamped deadline unreachable) and a
126
+ * page with several candidate frames would otherwise pay
127
+ * `(1 + frames) * evaluateTimeoutMs` in one pass regardless of `deadline`.
128
+ * The candidate loop always probes its first candidate — mirroring the
129
+ * top-level probe's "runs once regardless of budget" guarantee, since a
130
+ * `timeoutMs: 0` re-resolution (`flow-runner.ts`'s `reresolveFrameTargetIfLost`)
131
+ * must still be able to pick up a frame that has already attached — but
132
+ * breaks before any further candidate once no budget remains, rather than
133
+ * still issuing a zero-budget probe per remaining candidate. A timed-out
134
+ * probe is treated as "no match, try again" (same as a `false` `matched`
135
+ * result) so a poll that merely wedges degrades to a retry rather than
136
+ * aborting resolution outright — a genuine evaluate error (e.g. a caller
137
+ * passing an invalid selector) still propagates unchanged, preserving the
138
+ * existing "rejects rather than silently falling back" contract for real
139
+ * errors.
92
140
  */
93
- async function tryResolveChildFrame(page, frameSelector) {
141
+ async function tryResolveChildFrame(page, frameSelector, evaluateTimeoutMs, deadline) {
142
+ const remainingBudgetMs = () => Math.max(0, deadline - Date.now());
94
143
  const iframeSrcExpr = `(() => {
95
144
  const el = document.querySelector(${JSON.stringify(frameSelector)});
96
145
  if (!el || el.tagName !== "IFRAME") return { matched: false, src: null };
97
146
  return { matched: true, src: el.getAttribute("src") };
98
147
  })()`;
99
- const { matched, src: iframeSrc } = await page.evaluate(iframeSrcExpr);
148
+ const { matched, src: iframeSrc } = await (0, watchdog_1.withWatchdog)(() => page.evaluate(iframeSrcExpr), {
149
+ timeoutMs: Math.min(evaluateTimeoutMs, remainingBudgetMs()),
150
+ label: "frame-target: iframe src probe",
151
+ }).catch((err) => {
152
+ if (err instanceof watchdog_1.WatchdogTimeoutError)
153
+ return { matched: false, src: null };
154
+ throw err;
155
+ });
100
156
  if (!matched)
101
157
  return null;
102
158
  const candidates = page.frames();
@@ -104,21 +160,26 @@ async function tryResolveChildFrame(page, frameSelector) {
104
160
  if (!targetOrigin) {
105
161
  const [onlyCandidate] = candidates;
106
162
  return candidates.length === 1 && onlyCandidate
107
- ? childFrameTarget(page, onlyCandidate, frameSelector)
163
+ ? childFrameTarget(page, onlyCandidate, frameSelector, { evaluateTimeoutMs })
108
164
  : null;
109
165
  }
110
- for (const candidate of candidates) {
111
- const candidateUrl = await candidate.evaluate("location.href").catch(() => null);
166
+ for (const [index, candidate] of candidates.entries()) {
167
+ if (index > 0 && remainingBudgetMs() <= 0)
168
+ break;
169
+ const candidateUrl = await (0, watchdog_1.withWatchdog)(() => candidate.evaluate("location.href"), {
170
+ timeoutMs: Math.min(evaluateTimeoutMs, remainingBudgetMs()),
171
+ label: "frame-target: candidate frame location probe",
172
+ }).catch(() => null);
112
173
  if (candidateUrl && originOf(candidateUrl) === targetOrigin) {
113
- return childFrameTarget(page, candidate, frameSelector);
174
+ return childFrameTarget(page, candidate, frameSelector, { evaluateTimeoutMs });
114
175
  }
115
176
  }
116
177
  return null;
117
178
  }
118
179
  /**
119
180
  * Resolves the `FrameTarget` for `frameSelector` against `page`, polling for
120
- * up to `FRAME_READY_TIMEOUT_MS` (at `FRAME_READY_POLL_MS` intervals) before
121
- * falling back to the main-frame target rather than throwing:
181
+ * up to `timeoutMs` (at `pollMs` intervals) before falling back to the
182
+ * main-frame target rather than throwing:
122
183
  *
123
184
  * 1. `frameSelector` is `null`/`undefined` → main-frame target (today's
124
185
  * behavior, unchanged) — zero polling, zero delay.
@@ -126,36 +187,50 @@ async function tryResolveChildFrame(page, frameSelector) {
126
187
  * it isn't an `<iframe>`, or its `src` can't be read and more than one
127
188
  * `page.frames()` candidate exists (identity match is ambiguous), or no
128
189
  * `page.frames()` entry has a matching origin yet → try again after
129
- * `FRAME_READY_POLL_MS`.
190
+ * `pollMs`.
130
191
  * 3. A poll finds a matching frame → a child-frame target bound to it,
131
192
  * however many polls it took (an iframe created mid-flow by an earlier
132
193
  * step, e.g. after a click reveals it, resolves as soon as Stagehand's
133
194
  * CDP layer attaches to it instead of only when present at the first
134
195
  * poll).
135
- * 4. Still unresolved once the deadline passes → main-frame target, with a
136
- * `warn` naming the selector so a silent revert-to-main-frame is
137
- * diagnosable from the log instead of invisible.
196
+ * 4. Still unresolved once the deadline passes → main-frame target carrying
197
+ * `declaredFrameSelector` (so a caller can notice the failure and retry
198
+ * resolution later), with a `warn` naming the selector so a silent
199
+ * revert-to-main-frame is diagnosable from the log instead of invisible.
200
+ *
201
+ * Every `page`/`Frame` `evaluate` call this function (transitively) makes is
202
+ * bounded by `evaluateTimeoutMs`, further clamped to whatever remains of the
203
+ * total attach `deadline` at the moment each probe starts — including the
204
+ * very first resolution attempt made *before* the poll loop starts. Without
205
+ * that clamp, a single wedged CDP call there hangs this function for up to
206
+ * `evaluateTimeoutMs`, and a page with several `page.frames()` candidates
207
+ * multiplies that by each candidate probed in the same pass, which is
208
+ * exactly what made the declared attach deadline (`timeoutMs`) unenforceable
209
+ * whenever `evaluateTimeoutMs` exceeded it.
138
210
  *
139
- * `opts` overrides the poll timing for tests; production call sites rely on
140
- * the `FRAME_READY_TIMEOUT_MS`/`FRAME_READY_POLL_MS` defaults.
211
+ * `opts` overrides the timing for tests; production call sites default from
212
+ * `config.scraper.frameReadyTimeoutMs` / `frameEvaluateTimeoutMs` (poll
213
+ * cadence stays the fixed `FRAME_READY_POLL_MS`, cheap enough not to need
214
+ * tuning).
141
215
  */
142
216
  async function resolveFrameTarget(page, frameSelector, opts = {}) {
217
+ const evaluateTimeoutMs = opts.evaluateTimeoutMs ?? config_1.config.scraper.frameEvaluateTimeoutMs;
143
218
  if (!frameSelector)
144
- return mainFrameTarget(page);
145
- const resolved = await tryResolveChildFrame(page, frameSelector);
146
- if (resolved)
147
- return resolved;
148
- const timeoutMs = opts.timeoutMs ?? FRAME_READY_TIMEOUT_MS;
219
+ return mainFrameTarget(page, { evaluateTimeoutMs });
220
+ const timeoutMs = opts.timeoutMs ?? config_1.config.scraper.frameReadyTimeoutMs;
149
221
  const pollMs = opts.pollMs ?? FRAME_READY_POLL_MS;
150
222
  const deadline = Date.now() + timeoutMs;
223
+ const resolved = await tryResolveChildFrame(page, frameSelector, evaluateTimeoutMs, deadline);
224
+ if (resolved)
225
+ return resolved;
151
226
  while (Date.now() < deadline) {
152
227
  await sleep(pollMs);
153
- const polled = await tryResolveChildFrame(page, frameSelector);
228
+ const polled = await tryResolveChildFrame(page, frameSelector, evaluateTimeoutMs, deadline);
154
229
  if (polled)
155
230
  return polled;
156
231
  }
157
232
  logger.warn(`frame ${frameSelector} did not attach within ${timeoutMs}ms — falling back to main frame`);
158
- return mainFrameTarget(page);
233
+ return mainFrameTarget(page, { declaredFrameSelector: frameSelector, evaluateTimeoutMs });
159
234
  }
160
235
  const HOP_SEPARATOR = " >> ";
161
236
  /**
@@ -174,8 +249,7 @@ function buildHopSelector(frameSelector, innerSelector) {
174
249
  }
175
250
  return `${trimmedFrameSelector}${HOP_SEPARATOR}${innerSelector.trimStart()}`;
176
251
  }
177
- /** Readiness-wait defaults cheap poll, short timeout: an attached-but-not-yet-navigated child frame should settle in well under a second. */
178
- const FRAME_READY_TIMEOUT_MS = 5_000;
252
+ /** Poll cadence shared by `resolveFrameTarget` and `waitForChildFrameReady` cheap enough not to need per-call tuning. */
179
253
  const FRAME_READY_POLL_MS = 100;
180
254
  /** Shared delay helper — `FrameTarget` has no `waitForTimeout` since it isn't frame-scoped. */
181
255
  function sleep(ms) {
@@ -189,14 +263,28 @@ function sleep(ms) {
189
263
  * navigation lands. Best-effort like `waitForSpaReady`: never throws, just resolves
190
264
  * once ready or once `timeoutMs` elapses, so a frame that never becomes ready
191
265
  * degrades to "proceed anyway" rather than hanging the flow.
266
+ *
267
+ * Each `document.readyState` probe is itself bounded by `evaluateTimeoutMs` and
268
+ * treated as not-ready on timeout (same as a rejected `evaluate`) — otherwise a
269
+ * single wedged CDP call inside one poll would block past `timeoutMs`, defeating
270
+ * the outer deadline this function exists to enforce.
271
+ *
272
+ * `opts` overrides the timing for tests; production call sites default from
273
+ * `config.scraper.frameDocumentReadyTimeoutMs` / `frameEvaluateTimeoutMs` — kept
274
+ * separate from `resolveFrameTarget`'s (longer) attach budget since this wait
275
+ * settles in well under a second once the frame has attached.
192
276
  */
193
277
  async function waitForChildFrameReady(target, opts = {}) {
194
278
  if (!target.frame)
195
279
  return;
196
- const timeoutMs = opts.timeoutMs ?? FRAME_READY_TIMEOUT_MS;
280
+ const timeoutMs = opts.timeoutMs ?? config_1.config.scraper.frameDocumentReadyTimeoutMs;
197
281
  const pollMs = opts.pollMs ?? FRAME_READY_POLL_MS;
282
+ const evaluateTimeoutMs = opts.evaluateTimeoutMs ?? config_1.config.scraper.frameEvaluateTimeoutMs;
198
283
  const isReady = async () => {
199
- const readyState = await target.evaluate("document.readyState").catch(() => null);
284
+ const readyState = await (0, watchdog_1.withWatchdog)(() => target.evaluate("document.readyState"), {
285
+ timeoutMs: evaluateTimeoutMs,
286
+ label: "frame-target: document.readyState probe",
287
+ }).catch(() => null);
200
288
  return readyState === "interactive" || readyState === "complete";
201
289
  };
202
290
  if (await isReady())
@@ -1 +1 @@
1
- {"version":3,"file":"frame-target.js","sourceRoot":"","sources":["../../src/scraper/frame-target.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;AAIH,2CAA0C;AAE1C,MAAM,MAAM,GAAG,IAAA,mBAAS,EAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC,CAAC;AA+B3D;;;;;;GAMG;AACH,yBAAgC,IAAU;IACxC,OAAO;QACL,KAAK,EAAE,IAAI;QACX,aAAa,EAAE,IAAI;QACnB,QAAQ,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,wBAAwB,EAAE,GAAG,CAAC;QACzF,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC7C,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC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MAAM,KAAK,CAAC,MAAM,CAAC,CAAC;QACpB,IAAI,MAAM,OAAO,EAAE;YAAE,OAAO;IAC9B,CAAC;IACD,MAAM,CAAC,IAAI,CACT,eAAe,MAAM,CAAC,aAAa,IAAI,cAAc,0BAA0B,SAAS,wBAAwB,CACjH,CAAC;AACJ,CAAC"}
@@ -111,6 +111,11 @@ export declare class StagehandSchemaError extends Error {
111
111
  * `ActResult` verbatim. On envelope drift, throws `StagehandSchemaError`
112
112
  * and logs `failureKind: "schema-validation-failed"`.
113
113
  *
114
+ * The underlying `stagehand.act` call is raced against `options.timeout`
115
+ * (falling back to `DEFAULT_GUARD_TIMEOUT_MS`) via `withWatchdog` — Stagehand
116
+ * receives the same `timeout` as before, but a call that ignores it and hangs
117
+ * now fails the attempt instead of blocking the step forever.
118
+ *
114
119
  * Accepts the same trailing `frameTarget` param as `guardedObserve`/
115
120
  * `guardedExtract` for signature symmetry, but does not forward it into
116
121
  * `ActOptions` — `ActOptions` has no `selector` field, and its `page`
@@ -138,6 +143,11 @@ export declare function guardedAct(stagehand: Stagehand, input: string | Action,
138
143
  * main-frame target (`frameTarget` omitted, or its `frameSelector` is
139
144
  * `null`) leaves `options` untouched, so every existing call site is
140
145
  * byte-identical to today.
146
+ *
147
+ * The underlying `stagehand.observe` call is raced against `options.timeout`
148
+ * (falling back to `DEFAULT_GUARD_TIMEOUT_MS`) via `withWatchdog`, so a
149
+ * candidate search that never settles fails the attempt instead of hanging
150
+ * the step.
141
151
  */
142
152
  export declare function guardedObserve(stagehand: Stagehand, instruction?: string, options?: ObserveOptions, captureFn?: StagehandCaptureFn, frameTarget?: FrameTarget): Promise<Action[]>;
143
153
  /**
@@ -151,6 +161,10 @@ export declare function guardedObserve(stagehand: Stagehand, instruction?: strin
151
161
  * extracts from that frame's DOM instead of only the top frame. A
152
162
  * caller-supplied `options.selector` wins over `frameTarget.frameSelector`.
153
163
  * The main-frame target leaves `options` untouched.
164
+ *
165
+ * The underlying `stagehand.extract` call is raced against `options.timeout`
166
+ * (falling back to `DEFAULT_GUARD_TIMEOUT_MS`) via `withWatchdog`, so an
167
+ * extract that never settles fails the attempt instead of hanging the step.
154
168
  */
155
169
  export declare function guardedExtract<T extends z.ZodTypeAny>(stagehand: Stagehand, instruction: string, schema: T, options?: ExtractOptions, captureFn?: StagehandCaptureFn, frameTarget?: FrameTarget): Promise<z.infer<T>>;
156
170
  //# sourceMappingURL=stagehand-guard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stagehand-guard.d.ts","sourceRoot":"","sources":["../../src/scraper/stagehand-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAIH,OAAO,KAAK,EACV,MAAM,EACN,UAAU,EACV,SAAS,EACT,cAAc,EACd,cAAc,EACd,SAAS,EACV,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,8BAA8B,CAAC;AAMtC,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAExE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa;;;;;iBAKxB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;iBAM5B,CAAC;AAEH;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAG,0BAA0B,CAAU;IACpD,QAAQ,CAAC,SAAS,EAAE,KAAK,GAAG,SAAS,GAAG,SAAS,CAAC;IAClD,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAE9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AAM,EAAE,CAAC,CAsEnB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EACzD,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,cAAc,EACxB,SAAS,CAAC,EAAE,kBAAkB,EAC9B,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CA0ErB"}
@@ -47,6 +47,14 @@ const v4_1 = require("zod/v4");
47
47
  const call_capture_1 = require("../lib/telemetry/call-capture");
48
48
  const call_types_1 = require("../lib/telemetry/call-types");
49
49
  const frame_target_1 = require("../scraper/frame-target");
50
+ const watchdog_1 = require("../scraper/watchdog");
51
+ /**
52
+ * Fallback watchdog bound for a guarded call whose caller passes no
53
+ * `options.timeout`. Mirrors `STEP_WATCHDOG_MS` (`@/scraper/flow-runner`) by
54
+ * convention rather than by import — `flow-runner.ts` imports `guardedAct`/
55
+ * `guardedObserve` from this module, so importing back would cycle.
56
+ */
57
+ const DEFAULT_GUARD_TIMEOUT_MS = 120_000;
50
58
  /**
51
59
  * Zod mirror of Stagehand's public `Action` shape (from
52
60
  * `@browserbasehq/stagehand/.../public/methods.d.ts`):
@@ -143,6 +151,11 @@ function frameScopedOptions(options, frameTarget) {
143
151
  * `ActResult` verbatim. On envelope drift, throws `StagehandSchemaError`
144
152
  * and logs `failureKind: "schema-validation-failed"`.
145
153
  *
154
+ * The underlying `stagehand.act` call is raced against `options.timeout`
155
+ * (falling back to `DEFAULT_GUARD_TIMEOUT_MS`) via `withWatchdog` — Stagehand
156
+ * receives the same `timeout` as before, but a call that ignores it and hangs
157
+ * now fails the attempt instead of blocking the step forever.
158
+ *
146
159
  * Accepts the same trailing `frameTarget` param as `guardedObserve`/
147
160
  * `guardedExtract` for signature symmetry, but does not forward it into
148
161
  * `ActOptions` — `ActOptions` has no `selector` field, and its `page`
@@ -167,9 +180,7 @@ async function guardedAct(stagehand, input, options, captureFn, _frameTarget) {
167
180
  // `stagehand.act` to a variable then calling it as a standalone function
168
181
  // loses `this` in strict mode, which crashes inside Stagehand's
169
182
  // `withInstanceLogContext(this.instanceId, ...)` wrapper on entry.
170
- const raw = typeof input === "string"
171
- ? await stagehand.act(input, options)
172
- : await stagehand.act(input, options);
183
+ const raw = await (0, watchdog_1.withWatchdog)(() => typeof input === "string" ? stagehand.act(input, options) : stagehand.act(input, options), { timeoutMs: options?.timeout ?? DEFAULT_GUARD_TIMEOUT_MS, label: "stagehand-act" });
173
184
  const latencyMs = performance.now() - t0;
174
185
  const parsed = exports.ACT_RESULT_SCHEMA.safeParse(raw);
175
186
  if (!parsed.success) {
@@ -231,6 +242,11 @@ async function guardedAct(stagehand, input, options, captureFn, _frameTarget) {
231
242
  * main-frame target (`frameTarget` omitted, or its `frameSelector` is
232
243
  * `null`) leaves `options` untouched, so every existing call site is
233
244
  * byte-identical to today.
245
+ *
246
+ * The underlying `stagehand.observe` call is raced against `options.timeout`
247
+ * (falling back to `DEFAULT_GUARD_TIMEOUT_MS`) via `withWatchdog`, so a
248
+ * candidate search that never settles fails the attempt instead of hanging
249
+ * the step.
234
250
  */
235
251
  async function guardedObserve(stagehand, instruction, options, captureFn, frameTarget) {
236
252
  const callId = (0, node_crypto_1.randomUUID)();
@@ -240,11 +256,11 @@ async function guardedObserve(stagehand, instruction, options, captureFn, frameT
240
256
  try {
241
257
  // Match Stagehand's overloads: pass instruction only when defined, so
242
258
  // the SDK falls through to its no-arg/options-only path otherwise.
243
- const raw = instruction === undefined
259
+ const raw = await (0, watchdog_1.withWatchdog)(() => instruction === undefined
244
260
  ? scopedOptions === undefined
245
- ? await stagehand.observe()
246
- : await stagehand.observe(scopedOptions)
247
- : await stagehand.observe(instruction, scopedOptions);
261
+ ? stagehand.observe()
262
+ : stagehand.observe(scopedOptions)
263
+ : stagehand.observe(instruction, scopedOptions), { timeoutMs: scopedOptions?.timeout ?? DEFAULT_GUARD_TIMEOUT_MS, label: "stagehand-observe" });
248
264
  const latencyMs = performance.now() - t0;
249
265
  const parsed = v4_1.z.array(exports.ACTION_SCHEMA).safeParse(raw);
250
266
  if (!parsed.success) {
@@ -303,6 +319,10 @@ async function guardedObserve(stagehand, instruction, options, captureFn, frameT
303
319
  * extracts from that frame's DOM instead of only the top frame. A
304
320
  * caller-supplied `options.selector` wins over `frameTarget.frameSelector`.
305
321
  * The main-frame target leaves `options` untouched.
322
+ *
323
+ * The underlying `stagehand.extract` call is raced against `options.timeout`
324
+ * (falling back to `DEFAULT_GUARD_TIMEOUT_MS`) via `withWatchdog`, so an
325
+ * extract that never settles fails the attempt instead of hanging the step.
306
326
  */
307
327
  async function guardedExtract(stagehand, instruction, schema, options, captureFn, frameTarget) {
308
328
  const callId = (0, node_crypto_1.randomUUID)();
@@ -316,7 +336,7 @@ async function guardedExtract(stagehand, instruction, schema, options, captureFn
316
336
  // the cleanest public-API way to express "whatever overload-2 expects."
317
337
  // The `as unknown` step is needed because TS won't accept a single
318
338
  // direct cast across the entire overload set.
319
- const raw = await stagehand.extract(instruction, schema, frameScopedOptions(options, frameTarget));
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" });
320
340
  const latencyMs = performance.now() - t0;
321
341
  const parsed = schema.safeParse(raw);
322
342
  if (!parsed.success) {
@@ -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;AAW5E;;;;;;;;;;;;;;GAcG;AACU,QAAA,aAAa,GA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