@browserbasehq/orca 3.0.0-preview.1 → 3.0.0-preview.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.
Files changed (159) hide show
  1. package/dist/index.d.ts +759 -593
  2. package/dist/index.js +25560 -24375
  3. package/package.json +35 -74
  4. package/README.md +0 -165
  5. package/dist/lib/StagehandContext.d.ts +0 -25
  6. package/dist/lib/StagehandPage.d.ts +0 -103
  7. package/dist/lib/a11y/utils.d.ts +0 -144
  8. package/dist/lib/agent/AgentClient.d.ts +0 -20
  9. package/dist/lib/agent/AgentProvider.d.ts +0 -19
  10. package/dist/lib/agent/AnthropicCUAClient.d.ts +0 -56
  11. package/dist/lib/agent/GoogleCUAClient.d.ts +0 -63
  12. package/dist/lib/agent/OpenAICUAClient.d.ts +0 -65
  13. package/dist/lib/agent/StagehandAgent.d.ts +0 -15
  14. package/dist/lib/agent/tools/act.d.ts +0 -59
  15. package/dist/lib/agent/tools/ariaTree.d.ts +0 -11
  16. package/dist/lib/agent/tools/close.d.ts +0 -22
  17. package/dist/lib/agent/tools/extract.d.ts +0 -38
  18. package/dist/lib/agent/tools/fillform.d.ts +0 -37
  19. package/dist/lib/agent/tools/goto.d.ts +0 -29
  20. package/dist/lib/agent/tools/index.d.ts +0 -257
  21. package/dist/lib/agent/tools/navback.d.ts +0 -17
  22. package/dist/lib/agent/tools/screenshot.d.ts +0 -13
  23. package/dist/lib/agent/tools/scroll.d.ts +0 -23
  24. package/dist/lib/agent/tools/wait.d.ts +0 -18
  25. package/dist/lib/agent/utils/cuaKeyMapping.d.ts +0 -10
  26. package/dist/lib/agent/utils/imageCompression.d.ts +0 -53
  27. package/dist/lib/agent/utils/messageProcessing.d.ts +0 -13
  28. package/dist/lib/api.d.ts +0 -23
  29. package/dist/lib/browserbaseDefaults.d.ts +0 -9
  30. package/dist/lib/cache/ActionCache.d.ts +0 -62
  31. package/dist/lib/cache/BaseCache.d.ts +0 -66
  32. package/dist/lib/cache/LLMCache.d.ts +0 -22
  33. package/dist/lib/cache.d.ts +0 -29
  34. package/dist/lib/dom/build/scriptContent.d.ts +0 -1
  35. package/dist/lib/dom/elementCheckUtils.d.ts +0 -2
  36. package/dist/lib/dom/genDomScripts.d.ts +0 -1
  37. package/dist/lib/dom/index.d.ts +0 -2
  38. package/dist/lib/dom/process.d.ts +0 -17
  39. package/dist/lib/dom/utils.d.ts +0 -7
  40. package/dist/lib/dom/xpathUtils.d.ts +0 -14
  41. package/dist/lib/handlers/actHandler.d.ts +0 -33
  42. package/dist/lib/handlers/cuaAgentHandler.d.ts +0 -58
  43. package/dist/lib/handlers/extractHandler.d.ts +0 -54
  44. package/dist/lib/handlers/handlerUtils/actHandlerUtils.d.ts +0 -21
  45. package/dist/lib/handlers/observeHandler.d.ts +0 -40
  46. package/dist/lib/handlers/stagehandAgentHandler.d.ts +0 -27
  47. package/dist/lib/index.d.ts +0 -94
  48. package/dist/lib/inference.d.ts +0 -71
  49. package/dist/lib/inferenceLogUtils.d.ts +0 -12
  50. package/dist/lib/llm/AnthropicClient.d.ts +0 -21
  51. package/dist/lib/llm/CerebrasClient.d.ts +0 -22
  52. package/dist/lib/llm/GoogleClient.d.ts +0 -24
  53. package/dist/lib/llm/GroqClient.d.ts +0 -22
  54. package/dist/lib/llm/LLMClient.d.ts +0 -99
  55. package/dist/lib/llm/LLMProvider.d.ts +0 -13
  56. package/dist/lib/llm/OpenAIClient.d.ts +0 -20
  57. package/dist/lib/llm/aisdk.d.ts +0 -20
  58. package/dist/lib/logger.d.ts +0 -54
  59. package/dist/lib/mcp/connection.d.ts +0 -11
  60. package/dist/lib/mcp/utils.d.ts +0 -3
  61. package/dist/lib/prompt.d.ts +0 -12
  62. package/dist/lib/utils.d.ts +0 -65
  63. package/dist/lib/v3/agent/AgentClient.d.ts +0 -18
  64. package/dist/lib/v3/agent/AgentProvider.d.ts +0 -18
  65. package/dist/lib/v3/agent/AnthropicCUAClient.d.ts +0 -55
  66. package/dist/lib/v3/agent/OpenAICUAClient.d.ts +0 -64
  67. package/dist/lib/v3/agent/StagehandAgent.d.ts +0 -15
  68. package/dist/lib/v3/agent/tools/index.d.ts +0 -229
  69. package/dist/lib/v3/agent/tools/v3-act.d.ts +0 -29
  70. package/dist/lib/v3/agent/tools/v3-ariaTree.d.ts +0 -11
  71. package/dist/lib/v3/agent/tools/v3-close.d.ts +0 -24
  72. package/dist/lib/v3/agent/tools/v3-extract.d.ts +0 -38
  73. package/dist/lib/v3/agent/tools/v3-fillform.d.ts +0 -37
  74. package/dist/lib/v3/agent/tools/v3-goto.d.ts +0 -29
  75. package/dist/lib/v3/agent/tools/v3-navback.d.ts +0 -17
  76. package/dist/lib/v3/agent/tools/v3-screenshot.d.ts +0 -13
  77. package/dist/lib/v3/agent/tools/v3-scroll.d.ts +0 -23
  78. package/dist/lib/v3/agent/tools/v3-wait.d.ts +0 -19
  79. package/dist/lib/v3/agent/utils/cuaKeyMapping.d.ts +0 -10
  80. package/dist/lib/v3/agent/utils/imageCompression.d.ts +0 -18
  81. package/dist/lib/v3/agent/utils/messageProcessing.d.ts +0 -13
  82. package/dist/lib/v3/dom/build/scriptV3Content.d.ts +0 -1
  83. package/dist/lib/v3/dom/genDomScripts.d.ts +0 -1
  84. package/dist/lib/v3/dom/index.d.ts +0 -1
  85. package/dist/lib/v3/dom/piercer.entry.d.ts +0 -1
  86. package/dist/lib/v3/dom/piercer.runtime.d.ts +0 -25
  87. package/dist/lib/v3/handlers/actHandler.d.ts +0 -18
  88. package/dist/lib/v3/handlers/extractHandler.d.ts +0 -29
  89. package/dist/lib/v3/handlers/handlerUtils/actHandlerUtils.d.ts +0 -18
  90. package/dist/lib/v3/handlers/observeHandler.d.ts +0 -15
  91. package/dist/lib/v3/handlers/v3AgentHandler.d.ts +0 -17
  92. package/dist/lib/v3/handlers/v3CuaAgentHandler.d.ts +0 -26
  93. package/dist/lib/v3/index.d.ts +0 -10
  94. package/dist/lib/v3/launch/browserbase.d.ts +0 -8
  95. package/dist/lib/v3/launch/local.d.ts +0 -13
  96. package/dist/lib/v3/llm/AnthropicClient.d.ts +0 -16
  97. package/dist/lib/v3/llm/CerebrasClient.d.ts +0 -17
  98. package/dist/lib/v3/llm/GoogleClient.d.ts +0 -19
  99. package/dist/lib/v3/llm/GroqClient.d.ts +0 -17
  100. package/dist/lib/v3/llm/LLMClient.d.ts +0 -99
  101. package/dist/lib/v3/llm/LLMProvider.d.ts +0 -10
  102. package/dist/lib/v3/llm/OpenAIClient.d.ts +0 -15
  103. package/dist/lib/v3/llm/aisdk.d.ts +0 -15
  104. package/dist/lib/v3/logger.d.ts +0 -48
  105. package/dist/lib/v3/mcp/connection.d.ts +0 -11
  106. package/dist/lib/v3/mcp/utils.d.ts +0 -3
  107. package/dist/lib/v3/tests/default-page-tracking.spec.d.ts +0 -1
  108. package/dist/lib/v3/tests/downloads.spec.d.ts +0 -1
  109. package/dist/lib/v3/tests/perform-understudy-method.spec.d.ts +0 -1
  110. package/dist/lib/v3/tests/shadow-iframe.spec.d.ts +0 -1
  111. package/dist/lib/v3/tests/timeouts.spec.d.ts +0 -1
  112. package/dist/lib/v3/tests/v3.bb.config.d.ts +0 -4
  113. package/dist/lib/v3/tests/v3.config.d.ts +0 -4
  114. package/dist/lib/v3/tests/v3.playwright.config.d.ts +0 -2
  115. package/dist/lib/v3/tests/xpath-for-location-deep.spec.d.ts +0 -1
  116. package/dist/lib/v3/types/act.d.ts +0 -10
  117. package/dist/lib/v3/types/agent.d.ts +0 -132
  118. package/dist/lib/v3/types/api.d.ts +0 -40
  119. package/dist/lib/v3/types/cache.d.ts +0 -71
  120. package/dist/lib/v3/types/context.d.ts +0 -2
  121. package/dist/lib/v3/types/evals.d.ts +0 -71
  122. package/dist/lib/v3/types/evaluator.d.ts +0 -40
  123. package/dist/lib/v3/types/llm.d.ts +0 -11
  124. package/dist/lib/v3/types/log.d.ts +0 -23
  125. package/dist/lib/v3/types/model.d.ts +0 -20
  126. package/dist/lib/v3/types/playwright.d.ts +0 -6
  127. package/dist/lib/v3/types/stagehand.d.ts +0 -113
  128. package/dist/lib/v3/types/stagehandApiErrors.d.ts +0 -18
  129. package/dist/lib/v3/types/stagehandErrors.d.ts +0 -104
  130. package/dist/lib/v3/types.d.ts +0 -176
  131. package/dist/lib/v3/understudy/a11y/snapshot.d.ts +0 -71
  132. package/dist/lib/v3/understudy/cdp.d.ts +0 -58
  133. package/dist/lib/v3/understudy/context.d.ts +0 -120
  134. package/dist/lib/v3/understudy/deepLocator.d.ts +0 -69
  135. package/dist/lib/v3/understudy/executionContextRegistry.d.ts +0 -15
  136. package/dist/lib/v3/understudy/frame.d.ts +0 -63
  137. package/dist/lib/v3/understudy/frameLocator.d.ts +0 -46
  138. package/dist/lib/v3/understudy/frameRegistry.d.ts +0 -100
  139. package/dist/lib/v3/understudy/locator.d.ts +0 -196
  140. package/dist/lib/v3/understudy/page.d.ts +0 -241
  141. package/dist/lib/v3/understudy/piercer.d.ts +0 -4
  142. package/dist/lib/v3/v3.d.ts +0 -158
  143. package/dist/lib/version.d.ts +0 -5
  144. package/dist/stagehand.config.d.ts +0 -3
  145. package/dist/types/act.d.ts +0 -50
  146. package/dist/types/agent.d.ts +0 -143
  147. package/dist/types/api.d.ts +0 -40
  148. package/dist/types/browser.d.ts +0 -10
  149. package/dist/types/context.d.ts +0 -117
  150. package/dist/types/evals.d.ts +0 -94
  151. package/dist/types/evaluator.d.ts +0 -40
  152. package/dist/types/llm.d.ts +0 -11
  153. package/dist/types/log.d.ts +0 -23
  154. package/dist/types/model.d.ts +0 -17
  155. package/dist/types/page.d.ts +0 -38
  156. package/dist/types/playwright.d.ts +0 -12
  157. package/dist/types/stagehand.d.ts +0 -330
  158. package/dist/types/stagehandApiErrors.d.ts +0 -18
  159. package/dist/types/stagehandErrors.d.ts +0 -104
@@ -1,100 +0,0 @@
1
- import type { Protocol } from "devtools-protocol";
2
- /**
3
- * FrameRegistry
4
- *
5
- * Purpose:
6
- * A single, authoritative source of truth for **both**:
7
- * 1) Frame topology (parent/children, current main/root id, last-seen CDP `Frame`)
8
- * 2) Frame → Session ownership (which CDP session owns a given frameId)
9
- * 3) Optional iframe-owner metadata (backendNodeId of the <iframe> element in the parent doc)
10
- *
11
- *
12
- * Model:
13
- * - This class is **CDP-agnostic**; it stores **sessionId strings** (not session objects).
14
- * - Context bridges (wiring Target/Page events) must call the mutators below (onAttached,
15
- * onNavigated, onDetached, adoptChildSession, seedFromFrameTree, setOwnerBackendNodeId).
16
- * - Consumers ask read APIs (getOwnerSessionId, getParent, asProtocolFrameTree, listAll, …)
17
- * and never probe ownership at run time.
18
- */
19
- type FrameId = string;
20
- type SessionId = string;
21
- export declare class FrameRegistry {
22
- /** Owner target id (top-level target); informational only */
23
- private readonly ownerTargetId;
24
- /** Current main/root frame id (changes on root swaps) */
25
- private rootFrameId;
26
- /** frameId → FrameInfo */
27
- private frames;
28
- /** sessionId → Set<frameId> (inverse map for diagnostics/fast membership checks) */
29
- private framesBySession;
30
- constructor(ownerTargetId: string, mainFrameId: FrameId);
31
- /**
32
- * Record that a frame attached. If `parentId` is null and `frameId` differs from the current
33
- * root, this is a root swap and we rename the root id.
34
- *
35
- * IMPORTANT: The emitter's `sessionId` is the **owner** for the new/attached frame.
36
- */
37
- onFrameAttached(frameId: FrameId, parentId: FrameId | null, sessionId: SessionId): void;
38
- /**
39
- * Record a navigation with the full CDP `Frame`. Also updates ownership based on the emitting
40
- * session id. Handles root swap if the navigated frame is the new main (no parentId).
41
- */
42
- onFrameNavigated(frame: Protocol.Page.Frame, sessionId: SessionId): void;
43
- /**
44
- * Record that a frame detached. If `reason !== "swap"`, remove the subtree from the graph,
45
- * and clean the inverse maps. For “swap” we keep the node to preserve continuity.
46
- */
47
- onFrameDetached(frameId: FrameId, reason?: "remove" | "swap" | string): void;
48
- /**
49
- * An adopted OOPIF child session was created whose **main** frame id equals the parent iframe’s frameId.
50
- * We mark the entire child subtree as owned by `childSessionId`.
51
- * (Topology edges remain aligned by the parent session’s `frameAttached` events.)
52
- */
53
- adoptChildSession(childSessionId: SessionId, childMainFrameId: FrameId): void;
54
- /**
55
- * Seed topology and ownership from an existing `Page.getFrameTree` snapshot, typically right after
56
- * a session is attached. This is a best-effort: we record frames and set the provided `sessionId`
57
- * as owner for the subtree **if** an owner isn't already set.
58
- */
59
- seedFromFrameTree(sessionId: SessionId, frameTree: Protocol.Page.FrameTree): void;
60
- /**
61
- * Set the backendNodeId of the `<iframe>` element for a child frame **as seen from its parent**.
62
- * This is useful for building absolute XPath prefixes later (from the parent document).
63
- */
64
- setOwnerBackendNodeId(childFrameId: FrameId, backendNodeId: number): void;
65
- mainFrameId(): FrameId;
66
- /**
67
- * Return the owner session id for this frame. If unknown, returns `undefined`.
68
- */
69
- getOwnerSessionId(frameId: FrameId): SessionId | undefined;
70
- /**
71
- * Return the owner backendNodeId (iframe element) if recorded.
72
- * This is in the **parent** document; pair it with `getParent`.
73
- */
74
- getOwnerBackendNodeId(frameId: FrameId): number | undefined;
75
- /**
76
- * Return the parent frame id, or null for root/unknown.
77
- */
78
- getParent(frameId: FrameId): FrameId | null;
79
- /**
80
- * List frame ids in root-first DFS order (same shape as CDP’s FrameTree traversal).
81
- */
82
- listAllFrames(): FrameId[];
83
- /**
84
- * Serialize to `Protocol.Page.FrameTree` starting at the given root id (typically mainFrameId()).
85
- */
86
- asProtocolFrameTree(rootId: FrameId): Protocol.Page.FrameTree;
87
- /**
88
- * For diagnostics: return the current owner sessions for a frame id (0..n),
89
- * usually 0 or 1, but helpful to see potential inconsistencies during wiring.
90
- */
91
- sessionsForFrame(frameId: FrameId): SessionId[];
92
- /**
93
- * For diagnostics: return current frame set per session.
94
- */
95
- framesForSession(sessionId: SessionId): FrameId[];
96
- private ensureNode;
97
- private renameNodeId;
98
- private setOwnerSessionIdInternal;
99
- }
100
- export {};
@@ -1,196 +0,0 @@
1
- import { Protocol } from "devtools-protocol";
2
- import { Buffer } from "buffer";
3
- import type { Frame } from "./frame";
4
- type MouseButton = "left" | "right" | "middle";
5
- /**
6
- * Locator
7
- *
8
- * Purpose:
9
- * A small, CDP-based element interaction helper scoped to a specific `Frame`.
10
- * It resolves a CSS/XPath selector inside the frame’s **isolated world**, and then
11
- * performs low-level actions (click, type, select) using DOM/Runtime/Input
12
- * protocol domains with minimal abstraction.
13
- *
14
- * Key change:
15
- * - Prefer **objectId**-based CDP calls (scroll, geometry) to avoid brittle
16
- * frontend nodeId mappings. nodeId is resolved on a best-effort basis and
17
- * returned for compatibility, but actions do not depend on it.
18
- *
19
- * Notes:
20
- * - Resolution is lazy: every action resolves the selector again.
21
- * - Uses `Page.createIsolatedWorld` so evaluation is isolated from page scripts.
22
- * - Releases remote objects (`Runtime.releaseObject`) where appropriate.
23
- */
24
- export declare class Locator {
25
- private readonly frame;
26
- private readonly selector;
27
- private readonly options?;
28
- constructor(frame: Frame, selector: string, options?: {
29
- deep?: boolean;
30
- depth?: number;
31
- });
32
- /** Return the owning Frame for this locator (typed accessor, no private access). */
33
- getFrame(): Frame;
34
- /**
35
- * Set files on an <input type="file"> element.
36
- *
37
- * Mirrors Playwright's Locator.setInputFiles basics:
38
- * - Accepts file path(s) or payload object(s) { name, mimeType, buffer }.
39
- * - Uses CDP DOM.setFileInputFiles under the hood.
40
- * - Best‑effort dispatches change/input via CDP (Chrome does by default).
41
- * - Passing an empty array clears the selection.
42
- */
43
- setInputFiles(files: string | string[] | {
44
- name: string;
45
- mimeType: string;
46
- buffer: ArrayBuffer | Uint8Array | Buffer | string;
47
- } | Array<{
48
- name: string;
49
- mimeType: string;
50
- buffer: ArrayBuffer | Uint8Array | Buffer | string;
51
- }>): Promise<void>;
52
- /**
53
- * Return the DOM backendNodeId for this locator's target element.
54
- * Useful for identity comparisons without needing element handles.
55
- */
56
- backendNodeId(): Promise<Protocol.DOM.BackendNodeId>;
57
- /**
58
- * Return the center of the element's bounding box in the owning frame's viewport
59
- * (CSS pixels), rounded to integers. Scrolls into view best-effort.
60
- */
61
- centroid(): Promise<{
62
- x: number;
63
- y: number;
64
- }>;
65
- /**
66
- * Highlight the element's bounding box using the CDP Overlay domain.
67
- * - Scrolls element into view best-effort.
68
- * - Shows a semi-transparent overlay briefly, then hides it.
69
- */
70
- highlight(options?: {
71
- durationMs?: number;
72
- borderColor?: {
73
- r: number;
74
- g: number;
75
- b: number;
76
- a?: number;
77
- };
78
- contentColor?: {
79
- r: number;
80
- g: number;
81
- b: number;
82
- a?: number;
83
- };
84
- }): Promise<void>;
85
- /**
86
- * Click the element at its visual center.
87
- * Steps:
88
- * 1) Resolve selector to { objectId } in the frame world.
89
- * 2) Scroll into view via `DOM.scrollIntoViewIfNeeded({ objectId })`.
90
- * 3) Read geometry via `DOM.getBoxModel({ objectId })` → compute a center point.
91
- * 4) Synthesize mouse press + release via `Input.dispatchMouseEvent`.
92
- */
93
- click(options?: {
94
- button?: MouseButton;
95
- clickCount?: number;
96
- }): Promise<void>;
97
- /**
98
- * Dispatch a DOM 'click' MouseEvent on the element itself.
99
- * - Does not synthesize real pointer input; directly dispatches an event.
100
- * - Useful for elements that rely on click handlers without needing hit-testing.
101
- */
102
- sendClickEvent(options?: {
103
- bubbles?: boolean;
104
- cancelable?: boolean;
105
- composed?: boolean;
106
- detail?: number;
107
- }): Promise<void>;
108
- /**
109
- * Scroll the element vertically to a given percentage (0–100).
110
- * - If the element is <html> or <body>, scrolls the window/document.
111
- * - Otherwise, scrolls the element itself via element.scrollTo.
112
- */
113
- scrollTo(percent: number | string): Promise<void>;
114
- /**
115
- * Fill an input/textarea/contenteditable element.
116
- * - Sets the value/text directly in DOM.
117
- * - Dispatches `input` and `change` events to mimic user input.
118
- * - Releases the underlying `objectId` afterwards to avoid leaks.
119
- */
120
- fill(value: string): Promise<void>;
121
- /**
122
- * Type text into the element (focuses first).
123
- * - Focus via element.focus() in page JS (no DOM.focus(nodeId)).
124
- * - If no delay, uses `Input.insertText` for efficiency.
125
- * - With delay, synthesizes `keyDown`/`keyUp` per character.
126
- */
127
- type(text: string, options?: {
128
- delay?: number;
129
- }): Promise<void>;
130
- /**
131
- * Select one or more options on a `<select>` element.
132
- * Returns the values actually selected after the operation.
133
- */
134
- selectOption(values: string | string[]): Promise<string[]>;
135
- /**
136
- * Return true if the element is attached and visible (rough heuristic).
137
- */
138
- isVisible(): Promise<boolean>;
139
- /**
140
- * Return true if the element is an input[type=checkbox|radio] and is checked.
141
- * Also considers aria-checked for ARIA widgets.
142
- */
143
- isChecked(): Promise<boolean>;
144
- /**
145
- * Return the element's input value (for input/textarea/select/contenteditable).
146
- */
147
- inputValue(): Promise<string>;
148
- /**
149
- * Return the element's textContent (raw, not innerText).
150
- */
151
- textContent(): Promise<string>;
152
- /**
153
- * Return the element's innerHTML string.
154
- */
155
- innerHtml(): Promise<string>;
156
- /**
157
- * Return the element's innerText (layout-aware, visible text).
158
- */
159
- innerText(): Promise<string>;
160
- /**
161
- * For API parity, returns the same locator (querySelector already returns the first match).
162
- */
163
- first(): Locator;
164
- /**
165
- * Resolve `this.selector` within the frame to `{ objectId, nodeId? }`:
166
- * - Ensures Runtime/DOM are enabled.
167
- * - Creates (or reuses) an isolated world for this frame.
168
- * - Evaluates a CSS or XPath query in that isolated world.
169
- * - Best-effort: attempts to convert `objectId` to `nodeId`; failure is non-fatal.
170
- *
171
- * - For XPath: first try page-side resolver (__stagehandV3__.resolveSimpleXPath).
172
- * If it returns null (e.g. closed DSD not captured), fall back to CDP DOM with
173
- * `pierce: true` to traverse closed shadow roots and resolve by backendNodeId.
174
- */
175
- resolveNode(): Promise<{
176
- nodeId: Protocol.DOM.NodeId | null;
177
- objectId: Protocol.Runtime.RemoteObjectId;
178
- }>;
179
- /**
180
- * CDP fallback for XPath resolution that needs to cross *closed* shadow roots
181
- * created via Declarative Shadow DOM (no attachShadow call to intercept).
182
- *
183
- * Strategy:
184
- * - Fetch full DOM with `pierce: true` so closed shadow roots are included.
185
- * - Run a small, tolerant XPath stepper over the CDP node tree:
186
- * • supports absolute paths like `/html/body/...`
187
- * • supports `//` descendant jumps
188
- * • supports `tag[n]` numeric predicates per sibling group
189
- * • supports `*`
190
- * - Resolve the winning backendNodeId to an objectId for downstream actions.
191
- */
192
- private resolveViaDomPierceXPath;
193
- /** Compute a center point from a BoxModel content quad */
194
- private centerFromBoxContent;
195
- }
196
- export {};
@@ -1,241 +0,0 @@
1
- import { Protocol } from "devtools-protocol";
2
- import type { CDPSessionLike } from "./cdp";
3
- import { CdpConnection } from "./cdp";
4
- import { Frame } from "./frame";
5
- import { FrameLocator } from "./frameLocator";
6
- import { LoadState } from "../types";
7
- export declare class Page {
8
- private readonly conn;
9
- private readonly mainSession;
10
- private readonly _targetId;
11
- /** Every CDP child session this page owns (top-level + adopted OOPIF sessions). */
12
- private readonly sessions;
13
- /** Unified truth for frame topology + ownership. */
14
- private readonly registry;
15
- /** A convenience wrapper bound to the current main frame id (top-level session). */
16
- private mainFrameWrapper;
17
- /** Compact ordinal per frameId (used by snapshot encoding). */
18
- private frameOrdinals;
19
- private nextOrdinal;
20
- /** cache Frames per frameId so everyone uses the same one */
21
- private readonly frameCache;
22
- /** Stable id for Frames created by this Page (use top-level TargetId). */
23
- private readonly pageId;
24
- private constructor();
25
- private cursorEnabled;
26
- private ensureCursorScript;
27
- enableCursorOverlay(): Promise<void>;
28
- private updateCursor;
29
- /**
30
- * Factory: create Page and seed registry with the shallow tree from Page.getFrameTree.
31
- * Assumes Page domain is already enabled on the session passed in.
32
- */
33
- static create(conn: CdpConnection, session: CDPSessionLike, targetId: string): Promise<Page>;
34
- /**
35
- * Parent/child session emitted a `frameAttached`.
36
- * Topology update + ownership stamped to **emitting session**.
37
- */
38
- onFrameAttached(frameId: string, parentId: string | null, session: CDPSessionLike): void;
39
- /**
40
- * Parent/child session emitted a `frameDetached`.
41
- */
42
- onFrameDetached(frameId: string, reason?: "remove" | "swap" | string): void;
43
- /**
44
- * Parent/child session emitted a `frameNavigated`.
45
- * Topology + ownership update. Handles root swaps.
46
- */
47
- onFrameNavigated(frame: Protocol.Page.Frame, session: CDPSessionLike): void;
48
- /**
49
- * An OOPIF child session whose **main** frame id equals the parent iframe’s frameId
50
- * has been attached; adopt the session into this Page and seed ownership for its subtree.
51
- */
52
- adoptOopifSession(childSession: CDPSessionLike, childMainFrameId: string): void;
53
- /** Detach an adopted child session and prune its subtree */
54
- detachOopifSession(sessionId: string): void;
55
- /** Return the owning CDP session for a frameId (falls back to main session) */
56
- getSessionForFrame(frameId: string): CDPSessionLike;
57
- /** Always returns a Frame bound to the owning session */
58
- frameForId(frameId: string): Frame;
59
- /** Expose a session by id (used by snapshot to resolve session id -> session) */
60
- getSessionById(id: string): CDPSessionLike | undefined;
61
- targetId(): string;
62
- mainFrameId(): string;
63
- mainFrame(): Frame;
64
- /**
65
- * Close this top-level page (tab). Best-effort via Target.closeTarget.
66
- */
67
- close(): Promise<void>;
68
- getFullFrameTree(): Protocol.Page.FrameTree;
69
- asProtocolFrameTree(rootMainFrameId: string): Protocol.Page.FrameTree;
70
- private ensureOrdinal;
71
- /** Public getter for snapshot code / handlers. */
72
- getOrdinal(frameId: string): number;
73
- listAllFrameIds(): string[];
74
- /**
75
- * Navigate the page; optionally wait for a lifecycle state.
76
- * Waits on the **current** main frame and follows root swaps during navigation.
77
- */
78
- goto(url: string, options?: {
79
- waitUntil?: LoadState;
80
- timeoutMs?: number;
81
- }): Promise<void>;
82
- /**
83
- * Reload the page; optionally wait for a lifecycle state.
84
- */
85
- reload(options?: {
86
- waitUntil?: LoadState;
87
- timeoutMs?: number;
88
- ignoreCache?: boolean;
89
- }): Promise<void>;
90
- /**
91
- * Navigate back in history if possible; optionally wait for a lifecycle state.
92
- */
93
- goBack(options?: {
94
- waitUntil?: LoadState;
95
- timeoutMs?: number;
96
- }): Promise<void>;
97
- /**
98
- * Navigate forward in history if possible; optionally wait for a lifecycle state.
99
- */
100
- goForward(options?: {
101
- waitUntil?: LoadState;
102
- timeoutMs?: number;
103
- }): Promise<void>;
104
- /**
105
- * Return the current page URL (from navigation history).
106
- */
107
- url(): Promise<string>;
108
- /**
109
- * Return the current page title.
110
- * Prefers reading from the active document via Runtime.evaluate to reflect dynamic changes.
111
- * Falls back to navigation history title if evaluation is unavailable.
112
- */
113
- title(): Promise<string>;
114
- /**
115
- * Capture a screenshot (delegated to the current main frame).
116
- */
117
- screenshot(options?: {
118
- fullPage?: boolean;
119
- }): Promise<string>;
120
- /**
121
- * Create a locator bound to the current main frame.
122
- */
123
- locator(selector: string): ReturnType<Frame["locator"]>;
124
- /**
125
- * Deep locator that supports cross-iframe traversal.
126
- * - Recognizes '>>' hop notation to enter iframe contexts.
127
- * - Supports deep XPath that includes iframe steps (e.g., '/html/body/iframe[2]//div').
128
- * Returns a Locator scoped to the appropriate frame.
129
- */
130
- deepLocator(selector: string): import("./deepLocator").DeepLocatorDelegate;
131
- /**
132
- * Frame locator similar to Playwright: targets iframe elements and scopes
133
- * subsequent locators to that frame. Supports chaining.
134
- */
135
- frameLocator(selector: string): FrameLocator;
136
- /**
137
- * List all frames belonging to this page as Frame objects bound to their owning sessions.
138
- * The list is ordered by a stable ordinal assigned during the page lifetime.
139
- */
140
- frames(): Frame[];
141
- /**
142
- * Wait until the page reaches a lifecycle state on the current main frame.
143
- * Mirrors Playwright's API signatures.
144
- */
145
- waitForLoadState(state: LoadState, timeoutMs?: number): Promise<void>;
146
- /**
147
- * Evaluate a function or expression in the current main frame's isolated world.
148
- * - If a string is provided, it is treated as a JS expression.
149
- * - If a function is provided, it is stringified and invoked with the optional argument.
150
- * - The return value should be JSON-serializable. Non-serializable objects will
151
- * best-effort serialize via JSON.stringify inside the page context.
152
- */
153
- evaluate<R = unknown, Arg = unknown>(pageFunctionOrExpression: string | ((arg: Arg) => R | Promise<R>), arg?: Arg): Promise<R>;
154
- /**
155
- * Force the page viewport to an exact CSS size and device scale factor.
156
- * Ensures screenshots match width x height pixels when deviceScaleFactor = 1.
157
- */
158
- setViewportSize(width: number, height: number, options?: {
159
- deviceScaleFactor?: number;
160
- }): Promise<void>;
161
- /**
162
- * Click at absolute page coordinates (CSS pixels).
163
- * Dispatches mouseMoved → mousePressed → mouseReleased via CDP Input domain
164
- * on the top-level page target's session. Coordinates are relative to the
165
- * viewport origin (top-left). Does not scroll.
166
- */
167
- click(x: number, y: number, options: {
168
- button?: "left" | "right" | "middle";
169
- clickCount?: number;
170
- returnXpath: true;
171
- }): Promise<string>;
172
- click(x: number, y: number, options?: {
173
- button?: "left" | "right" | "middle";
174
- clickCount?: number;
175
- returnXpath?: false;
176
- }): Promise<void>;
177
- click(x: number, y: number, options: {
178
- button?: "left" | "right" | "middle";
179
- clickCount?: number;
180
- returnXpath: boolean;
181
- }): Promise<void | string>;
182
- scroll(x: number, y: number, deltaX: number, deltaY: number, options: {
183
- returnXpath: true;
184
- }): Promise<string>;
185
- scroll(x: number, y: number, deltaX: number, deltaY: number, options?: {
186
- returnXpath?: false;
187
- }): Promise<void>;
188
- scroll(x: number, y: number, deltaX: number, deltaY: number, options: {
189
- returnXpath: boolean;
190
- }): Promise<void | string>;
191
- /**
192
- * Drag from (fromX, fromY) to (toX, toY) using mouse events.
193
- * Sends mouseMoved → mousePressed → mouseMoved (steps) → mouseReleased.
194
- */
195
- dragAndDrop(fromX: number, fromY: number, toX: number, toY: number, options: {
196
- button?: "left" | "right" | "middle";
197
- steps?: number;
198
- delay?: number;
199
- returnXpath: true;
200
- }): Promise<[string, string]>;
201
- dragAndDrop(fromX: number, fromY: number, toX: number, toY: number, options?: {
202
- button?: "left" | "right" | "middle";
203
- steps?: number;
204
- delay?: number;
205
- returnXpath?: false;
206
- }): Promise<void>;
207
- dragAndDrop(fromX: number, fromY: number, toX: number, toY: number, options: {
208
- button?: "left" | "right" | "middle";
209
- steps?: number;
210
- delay?: number;
211
- returnXpath: boolean;
212
- }): Promise<void | [string, string]>;
213
- /**
214
- * Type a string by dispatching keyDown/keyUp events per character.
215
- * Focus must already be on the desired element. Uses CDP Input.dispatchKeyEvent
216
- * and never falls back to Input.insertText. Optional delay applies between
217
- * successive characters.
218
- */
219
- type(text: string, options?: {
220
- delay?: number;
221
- withMistakes?: boolean;
222
- }): Promise<void>;
223
- /**
224
- * Press a single key (keyDown then keyUp). For printable characters,
225
- * uses the text path on keyDown; for named keys, sets key/code/VK.
226
- */
227
- keyPress(key: string, options?: {
228
- delay?: number;
229
- }): Promise<void>;
230
- /**
231
- * Create an isolated world for the **current** main frame and return its context id.
232
- */
233
- private createIsolatedWorldForCurrentMain;
234
- /**
235
- * Wait until the **current** main frame reaches a lifecycle state.
236
- * - Fast path via `document.readyState`.
237
- * - Event path listens at the session level and compares incoming `frameId`
238
- * to `mainFrameId()` **at event time** to follow root swaps.
239
- */
240
- private waitForMainLoadState;
241
- }
@@ -1,4 +0,0 @@
1
- import type { CDPSessionLike } from "./cdp";
2
- export declare function installV3PiercerIntoSession(session: CDPSessionLike): Promise<void>;
3
- /** (Optional) stream patch logs in your node console during bring-up */
4
- export declare function tapPiercerConsole(session: CDPSessionLike, label: string): void;