@browserbasehq/orca 3.0.0-preview.0 → 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.
- package/dist/index.d.ts +761 -593
- package/dist/index.js +25775 -24553
- package/package.json +35 -74
- package/README.md +0 -165
- package/dist/lib/api.d.ts +0 -23
- package/dist/lib/dom/build/scriptContent.d.ts +0 -1
- package/dist/lib/inference.d.ts +0 -71
- package/dist/lib/inferenceLogUtils.d.ts +0 -12
- package/dist/lib/logger.d.ts +0 -54
- package/dist/lib/prompt.d.ts +0 -12
- package/dist/lib/utils.d.ts +0 -65
- package/dist/lib/v3/agent/AgentClient.d.ts +0 -18
- package/dist/lib/v3/agent/AgentProvider.d.ts +0 -18
- package/dist/lib/v3/agent/AnthropicCUAClient.d.ts +0 -55
- package/dist/lib/v3/agent/OpenAICUAClient.d.ts +0 -64
- package/dist/lib/v3/agent/StagehandAgent.d.ts +0 -15
- package/dist/lib/v3/agent/tools/index.d.ts +0 -229
- package/dist/lib/v3/agent/tools/v3-act.d.ts +0 -29
- package/dist/lib/v3/agent/tools/v3-ariaTree.d.ts +0 -11
- package/dist/lib/v3/agent/tools/v3-close.d.ts +0 -24
- package/dist/lib/v3/agent/tools/v3-extract.d.ts +0 -38
- package/dist/lib/v3/agent/tools/v3-fillform.d.ts +0 -37
- package/dist/lib/v3/agent/tools/v3-goto.d.ts +0 -29
- package/dist/lib/v3/agent/tools/v3-navback.d.ts +0 -17
- package/dist/lib/v3/agent/tools/v3-screenshot.d.ts +0 -13
- package/dist/lib/v3/agent/tools/v3-scroll.d.ts +0 -23
- package/dist/lib/v3/agent/tools/v3-wait.d.ts +0 -19
- package/dist/lib/v3/agent/utils/cuaKeyMapping.d.ts +0 -10
- package/dist/lib/v3/agent/utils/imageCompression.d.ts +0 -18
- package/dist/lib/v3/agent/utils/messageProcessing.d.ts +0 -13
- package/dist/lib/v3/dom/build/scriptV3Content.d.ts +0 -1
- package/dist/lib/v3/dom/genDomScripts.d.ts +0 -1
- package/dist/lib/v3/dom/index.d.ts +0 -1
- package/dist/lib/v3/dom/piercer.entry.d.ts +0 -1
- package/dist/lib/v3/dom/piercer.runtime.d.ts +0 -25
- package/dist/lib/v3/handlers/actHandler.d.ts +0 -18
- package/dist/lib/v3/handlers/extractHandler.d.ts +0 -29
- package/dist/lib/v3/handlers/handlerUtils/actHandlerUtils.d.ts +0 -18
- package/dist/lib/v3/handlers/observeHandler.d.ts +0 -15
- package/dist/lib/v3/handlers/v3AgentHandler.d.ts +0 -17
- package/dist/lib/v3/handlers/v3CuaAgentHandler.d.ts +0 -26
- package/dist/lib/v3/index.d.ts +0 -10
- package/dist/lib/v3/launch/browserbase.d.ts +0 -8
- package/dist/lib/v3/launch/local.d.ts +0 -13
- package/dist/lib/v3/llm/AnthropicClient.d.ts +0 -16
- package/dist/lib/v3/llm/CerebrasClient.d.ts +0 -17
- package/dist/lib/v3/llm/GoogleClient.d.ts +0 -19
- package/dist/lib/v3/llm/GroqClient.d.ts +0 -17
- package/dist/lib/v3/llm/LLMClient.d.ts +0 -99
- package/dist/lib/v3/llm/LLMProvider.d.ts +0 -10
- package/dist/lib/v3/llm/OpenAIClient.d.ts +0 -15
- package/dist/lib/v3/llm/aisdk.d.ts +0 -15
- package/dist/lib/v3/logger.d.ts +0 -48
- package/dist/lib/v3/mcp/connection.d.ts +0 -11
- package/dist/lib/v3/mcp/utils.d.ts +0 -3
- package/dist/lib/v3/tests/default-page-tracking.spec.d.ts +0 -1
- package/dist/lib/v3/tests/perform-understudy-method.spec.d.ts +0 -1
- package/dist/lib/v3/tests/shadow-iframe.spec.d.ts +0 -1
- package/dist/lib/v3/tests/timeouts.spec.d.ts +0 -1
- package/dist/lib/v3/tests/v3.config.d.ts +0 -4
- package/dist/lib/v3/tests/v3.playwright.config.d.ts +0 -2
- package/dist/lib/v3/tests/xpath-for-location-deep.spec.d.ts +0 -1
- package/dist/lib/v3/types/act.d.ts +0 -10
- package/dist/lib/v3/types/agent.d.ts +0 -132
- package/dist/lib/v3/types/api.d.ts +0 -40
- package/dist/lib/v3/types/cache.d.ts +0 -71
- package/dist/lib/v3/types/context.d.ts +0 -2
- package/dist/lib/v3/types/evals.d.ts +0 -71
- package/dist/lib/v3/types/evaluator.d.ts +0 -40
- package/dist/lib/v3/types/llm.d.ts +0 -11
- package/dist/lib/v3/types/log.d.ts +0 -23
- package/dist/lib/v3/types/model.d.ts +0 -20
- package/dist/lib/v3/types/playwright.d.ts +0 -6
- package/dist/lib/v3/types/stagehand.d.ts +0 -113
- package/dist/lib/v3/types/stagehandApiErrors.d.ts +0 -18
- package/dist/lib/v3/types/stagehandErrors.d.ts +0 -104
- package/dist/lib/v3/types.d.ts +0 -176
- package/dist/lib/v3/understudy/a11y/snapshot.d.ts +0 -71
- package/dist/lib/v3/understudy/cdp.d.ts +0 -58
- package/dist/lib/v3/understudy/context.d.ts +0 -120
- package/dist/lib/v3/understudy/deepLocator.d.ts +0 -69
- package/dist/lib/v3/understudy/executionContextRegistry.d.ts +0 -15
- package/dist/lib/v3/understudy/frame.d.ts +0 -63
- package/dist/lib/v3/understudy/frameLocator.d.ts +0 -46
- package/dist/lib/v3/understudy/frameRegistry.d.ts +0 -100
- package/dist/lib/v3/understudy/locator.d.ts +0 -196
- package/dist/lib/v3/understudy/page.d.ts +0 -241
- package/dist/lib/v3/understudy/piercer.d.ts +0 -4
- package/dist/lib/v3/v3.d.ts +0 -156
- package/dist/lib/version.d.ts +0 -5
package/dist/lib/v3/types.d.ts
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { LaunchedChrome } from "chrome-launcher";
|
|
2
|
-
import Browserbase from "@browserbasehq/sdk";
|
|
3
|
-
import { Page } from "./understudy/page";
|
|
4
|
-
import { ModelConfiguration } from "../v3/types/model";
|
|
5
|
-
import { LLMClient } from "./llm/LLMClient";
|
|
6
|
-
import { z } from "zod/v3";
|
|
7
|
-
import type { ZodTypeAny } from "zod/v3";
|
|
8
|
-
import type { LogLine } from "../v3/types/log";
|
|
9
|
-
export type V3Env = "LOCAL" | "BROWSERBASE";
|
|
10
|
-
/** Local launch options for V3 (chrome-launcher + CDP).
|
|
11
|
-
* Matches v2 shape where feasible; unsupported fields are accepted but ignored.
|
|
12
|
-
*/
|
|
13
|
-
export interface LocalBrowserLaunchOptions {
|
|
14
|
-
args?: string[];
|
|
15
|
-
executablePath?: string;
|
|
16
|
-
userDataDir?: string;
|
|
17
|
-
preserveUserDataDir?: boolean;
|
|
18
|
-
headless?: boolean;
|
|
19
|
-
devtools?: boolean;
|
|
20
|
-
chromiumSandbox?: boolean;
|
|
21
|
-
ignoreDefaultArgs?: boolean | string[];
|
|
22
|
-
proxy?: {
|
|
23
|
-
server: string;
|
|
24
|
-
bypass?: string;
|
|
25
|
-
username?: string;
|
|
26
|
-
password?: string;
|
|
27
|
-
};
|
|
28
|
-
locale?: string;
|
|
29
|
-
viewport?: {
|
|
30
|
-
width: number;
|
|
31
|
-
height: number;
|
|
32
|
-
};
|
|
33
|
-
deviceScaleFactor?: number;
|
|
34
|
-
hasTouch?: boolean;
|
|
35
|
-
ignoreHTTPSErrors?: boolean;
|
|
36
|
-
cdpUrl?: string;
|
|
37
|
-
connectTimeoutMs?: number;
|
|
38
|
-
downloadsPath?: string;
|
|
39
|
-
acceptDownloads?: boolean;
|
|
40
|
-
}
|
|
41
|
-
/** Constructor options for V3 */
|
|
42
|
-
export interface V3Options {
|
|
43
|
-
env: V3Env;
|
|
44
|
-
apiKey?: string;
|
|
45
|
-
projectId?: string;
|
|
46
|
-
/**
|
|
47
|
-
* Optional: fine-tune Browserbase session creation or resume an existing session.
|
|
48
|
-
*/
|
|
49
|
-
browserbaseSessionCreateParams?: Omit<Browserbase.Sessions.SessionCreateParams, "projectId"> & {
|
|
50
|
-
projectId?: string;
|
|
51
|
-
};
|
|
52
|
-
browserbaseSessionID?: string;
|
|
53
|
-
localBrowserLaunchOptions?: LocalBrowserLaunchOptions;
|
|
54
|
-
model?: ModelConfiguration;
|
|
55
|
-
llmClient?: LLMClient;
|
|
56
|
-
systemPrompt?: string;
|
|
57
|
-
logInferenceToFile?: boolean;
|
|
58
|
-
experimental?: boolean;
|
|
59
|
-
verbose?: 0 | 1 | 2;
|
|
60
|
-
selfHeal?: boolean;
|
|
61
|
-
/** Disable pino logging backend (useful for tests or minimal environments). */
|
|
62
|
-
disablePino?: boolean;
|
|
63
|
-
/** Optional external logger hook for integrating with host apps. */
|
|
64
|
-
logger?: (line: LogLine) => void;
|
|
65
|
-
/** Show a visual cursor overlay that follows our mouse events. */
|
|
66
|
-
includeCursor?: boolean;
|
|
67
|
-
/** Directory used to persist cached actions for act(). */
|
|
68
|
-
cacheDir?: string;
|
|
69
|
-
domSettleTimeout?: number;
|
|
70
|
-
}
|
|
71
|
-
/** Narrow shape we rely on from Browserbase session creation */
|
|
72
|
-
export interface BrowserbaseSession {
|
|
73
|
-
id: string;
|
|
74
|
-
connectUrl: string;
|
|
75
|
-
}
|
|
76
|
-
/** Narrow shape we rely on from /json/version */
|
|
77
|
-
export interface JsonVersionResponse {
|
|
78
|
-
webSocketDebuggerUrl: string;
|
|
79
|
-
}
|
|
80
|
-
export type InitState = {
|
|
81
|
-
kind: "UNINITIALIZED";
|
|
82
|
-
} | {
|
|
83
|
-
kind: "LOCAL";
|
|
84
|
-
chrome: LaunchedChrome;
|
|
85
|
-
ws: string;
|
|
86
|
-
userDataDir?: string;
|
|
87
|
-
createdTempProfile?: boolean;
|
|
88
|
-
preserveUserDataDir?: boolean;
|
|
89
|
-
} | {
|
|
90
|
-
kind: "BROWSERBASE";
|
|
91
|
-
bb: Browserbase;
|
|
92
|
-
sessionId: string;
|
|
93
|
-
ws: string;
|
|
94
|
-
};
|
|
95
|
-
export type PlaywrightPage = import("playwright-core").Page;
|
|
96
|
-
export type PatchrightPage = import("patchright-core").Page;
|
|
97
|
-
export type PuppeteerPage = import("puppeteer-core").Page;
|
|
98
|
-
export type AnyPage = PlaywrightPage | PuppeteerPage | PatchrightPage | Page;
|
|
99
|
-
export interface ActOptions {
|
|
100
|
-
model?: ModelConfiguration;
|
|
101
|
-
variables?: Record<string, string>;
|
|
102
|
-
timeout?: number;
|
|
103
|
-
page?: PlaywrightPage | PuppeteerPage | PatchrightPage | Page;
|
|
104
|
-
}
|
|
105
|
-
export interface ActHandlerParams {
|
|
106
|
-
instruction: string;
|
|
107
|
-
model?: ModelConfiguration;
|
|
108
|
-
variables?: Record<string, string>;
|
|
109
|
-
timeout?: number;
|
|
110
|
-
page: Page;
|
|
111
|
-
}
|
|
112
|
-
export interface ExtractOptions {
|
|
113
|
-
model?: ModelConfiguration;
|
|
114
|
-
timeout?: number;
|
|
115
|
-
selector?: string;
|
|
116
|
-
page?: PlaywrightPage | PuppeteerPage | PatchrightPage | Page;
|
|
117
|
-
}
|
|
118
|
-
export interface ExtractHandlerParams<T extends ZodTypeAny> {
|
|
119
|
-
instruction?: string;
|
|
120
|
-
schema?: T;
|
|
121
|
-
model?: ModelConfiguration;
|
|
122
|
-
timeout?: number;
|
|
123
|
-
selector?: string;
|
|
124
|
-
page: Page;
|
|
125
|
-
}
|
|
126
|
-
export declare const defaultExtractSchema: z.ZodObject<{
|
|
127
|
-
extraction: z.ZodString;
|
|
128
|
-
}, "strip", z.ZodTypeAny, {
|
|
129
|
-
extraction?: string;
|
|
130
|
-
}, {
|
|
131
|
-
extraction?: string;
|
|
132
|
-
}>;
|
|
133
|
-
export declare const pageTextSchema: z.ZodObject<{
|
|
134
|
-
pageText: z.ZodString;
|
|
135
|
-
}, "strip", z.ZodTypeAny, {
|
|
136
|
-
pageText?: string;
|
|
137
|
-
}, {
|
|
138
|
-
pageText?: string;
|
|
139
|
-
}>;
|
|
140
|
-
export interface ObserveOptions {
|
|
141
|
-
model?: ModelConfiguration;
|
|
142
|
-
timeout?: number;
|
|
143
|
-
selector?: string;
|
|
144
|
-
page?: PlaywrightPage | PuppeteerPage | PatchrightPage | Page;
|
|
145
|
-
}
|
|
146
|
-
export interface ObserveHandlerParams {
|
|
147
|
-
instruction?: string;
|
|
148
|
-
model?: ModelConfiguration;
|
|
149
|
-
timeout?: number;
|
|
150
|
-
selector?: string;
|
|
151
|
-
page: Page;
|
|
152
|
-
}
|
|
153
|
-
export type LoadState = "load" | "domcontentloaded" | "networkidle";
|
|
154
|
-
export interface V3Metrics {
|
|
155
|
-
actPromptTokens: number;
|
|
156
|
-
actCompletionTokens: number;
|
|
157
|
-
actInferenceTimeMs: number;
|
|
158
|
-
extractPromptTokens: number;
|
|
159
|
-
extractCompletionTokens: number;
|
|
160
|
-
extractInferenceTimeMs: number;
|
|
161
|
-
observePromptTokens: number;
|
|
162
|
-
observeCompletionTokens: number;
|
|
163
|
-
observeInferenceTimeMs: number;
|
|
164
|
-
agentPromptTokens: number;
|
|
165
|
-
agentCompletionTokens: number;
|
|
166
|
-
agentInferenceTimeMs: number;
|
|
167
|
-
totalPromptTokens: number;
|
|
168
|
-
totalCompletionTokens: number;
|
|
169
|
-
totalInferenceTimeMs: number;
|
|
170
|
-
}
|
|
171
|
-
export declare enum V3FunctionName {
|
|
172
|
-
ACT = "ACT",
|
|
173
|
-
EXTRACT = "EXTRACT",
|
|
174
|
-
OBSERVE = "OBSERVE",
|
|
175
|
-
AGENT = "AGENT"
|
|
176
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Page } from "../page";
|
|
2
|
-
/**
|
|
3
|
-
* a11y/snapshot
|
|
4
|
-
*
|
|
5
|
-
* Purpose:
|
|
6
|
-
* Build a **hybrid DOM + Accessibility** snapshot for a V3 `Page`, suitable for
|
|
7
|
-
* act/extract/observe handlers. The snapshot includes:
|
|
8
|
-
* - A merged, human-readable outline (Accessibility tree) for the page
|
|
9
|
-
* - EncodedId → XPath map (DOM)
|
|
10
|
-
* - EncodedId → URL map (from AX properties)
|
|
11
|
-
*
|
|
12
|
-
* Design highlights:
|
|
13
|
-
* - EncodedId is frame-aware and compact: `${frameOrdinal}-${backendNodeId}` where
|
|
14
|
-
* the frame ordinal is provided by `Page.getOrdinal(frameId)`.
|
|
15
|
-
* - Each frame (main, same-process iframe, OOPIF) is processed against **its owning session**,
|
|
16
|
-
* so DOM and A11y ownership are correct for that document.
|
|
17
|
-
* - We compute an **absolute iframe XPath prefix** for each child frame by asking
|
|
18
|
-
* the **parent session** for the `<iframe>` owner node (via `DOM.getFrameOwner`).
|
|
19
|
-
* - No global inventory imports; we rely solely on Page’s registry-backed APIs.
|
|
20
|
-
*/
|
|
21
|
-
export type SnapshotOptions = {
|
|
22
|
-
/**
|
|
23
|
-
* Filter the snapshot to a specific element/subtree using a selector that can cross iframes.
|
|
24
|
-
* Supports:
|
|
25
|
-
* - XPath: strings starting with 'xpath=' or '/'
|
|
26
|
-
* - CSS with iframe hops via '>>': e.g., 'section iframe >> #email'
|
|
27
|
-
*/
|
|
28
|
-
focusSelector?: string;
|
|
29
|
-
/** Pierce shadow DOM in DOM.getDocument (default: true). */
|
|
30
|
-
pierceShadow?: boolean;
|
|
31
|
-
/** Experimental behaviours flag. */
|
|
32
|
-
experimental?: boolean;
|
|
33
|
-
};
|
|
34
|
-
export type HybridSnapshot = {
|
|
35
|
-
/** Merged/stitched outline across frames. */
|
|
36
|
-
combinedTree: string;
|
|
37
|
-
/** EncodedId (ordinal-backendId) → absolute XPath (across iframes). */
|
|
38
|
-
combinedXpathMap: Record<string, string>;
|
|
39
|
-
/** EncodedId → URL (from AX properties). */
|
|
40
|
-
combinedUrlMap: Record<string, string>;
|
|
41
|
-
/** Per-frame details for debugging/consumers. */
|
|
42
|
-
perFrame?: Array<{
|
|
43
|
-
frameId: string;
|
|
44
|
-
outline: string;
|
|
45
|
-
xpathMap: Record<string, string>;
|
|
46
|
-
urlMap: Record<string, string>;
|
|
47
|
-
}>;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Resolve deepest node for a page coordinate and compute its absolute XPath across frames.
|
|
51
|
-
* More efficient than building a full hybrid snapshot when only a single node’s XPath is needed.
|
|
52
|
-
*/
|
|
53
|
-
export declare function resolveXpathForLocation(page: Page, x: number, y: number): Promise<{
|
|
54
|
-
frameId: string;
|
|
55
|
-
backendNodeId: number;
|
|
56
|
-
absoluteXPath: string;
|
|
57
|
-
} | null>;
|
|
58
|
-
/**
|
|
59
|
-
* Compute the absolute XPath for the currently focused element.
|
|
60
|
-
* - Detects which frame has focus via document.hasFocus().
|
|
61
|
-
* - Finds the deepest activeElement (dives into shadow DOM).
|
|
62
|
-
* - Builds an absolute, cross-frame XPath by prefixing iframe hosts.
|
|
63
|
-
*/
|
|
64
|
-
export declare function computeActiveElementXpath(page: Page): Promise<string | null>;
|
|
65
|
-
export declare function captureHybridSnapshot(page: Page, options?: SnapshotOptions): Promise<HybridSnapshot>;
|
|
66
|
-
/**
|
|
67
|
-
* Return the lines that appear in `nextTree` but not in `prevTree`.
|
|
68
|
-
* Comparison is done line-by-line, ignoring leading whitespace in both trees.
|
|
69
|
-
* The returned block is re-indented so the minimal indent becomes column 0.
|
|
70
|
-
*/
|
|
71
|
-
export declare function diffCombinedTrees(prevTree: string, nextTree: string): string;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CDP transport & session multiplexer
|
|
3
|
-
*
|
|
4
|
-
* Owns the browser WebSocket and multiplexes flattened Target sessions.
|
|
5
|
-
* Tracks inflight CDP calls, routes responses to the right session, and forwards events.
|
|
6
|
-
*
|
|
7
|
-
* This does not interpret Page/DOM/Runtime semantics — callers own that logic.
|
|
8
|
-
*/
|
|
9
|
-
export interface CDPSessionLike {
|
|
10
|
-
send<R = unknown>(method: string, params?: object): Promise<R>;
|
|
11
|
-
on<P = unknown>(event: string, handler: (params: P) => void): void;
|
|
12
|
-
off<P = unknown>(event: string, handler: (params: P) => void): void;
|
|
13
|
-
close(): Promise<void>;
|
|
14
|
-
readonly id: string | null;
|
|
15
|
-
}
|
|
16
|
-
type EventHandler = (params: unknown) => void;
|
|
17
|
-
export declare class CdpConnection implements CDPSessionLike {
|
|
18
|
-
private ws;
|
|
19
|
-
private nextId;
|
|
20
|
-
private inflight;
|
|
21
|
-
private eventHandlers;
|
|
22
|
-
private sessions;
|
|
23
|
-
readonly id: string | null;
|
|
24
|
-
private transportCloseHandlers;
|
|
25
|
-
onTransportClosed(handler: (why: string) => void): void;
|
|
26
|
-
offTransportClosed(handler: (why: string) => void): void;
|
|
27
|
-
private emitTransportClosed;
|
|
28
|
-
private constructor();
|
|
29
|
-
static connect(wsUrl: string): Promise<CdpConnection>;
|
|
30
|
-
enableAutoAttach(): Promise<void>;
|
|
31
|
-
send<R = unknown>(method: string, params?: object): Promise<R>;
|
|
32
|
-
on<P = unknown>(event: string, handler: (params: P) => void): void;
|
|
33
|
-
off<P = unknown>(event: string, handler: (params: P) => void): void;
|
|
34
|
-
close(): Promise<void>;
|
|
35
|
-
getSession(sessionId: string): CdpSession | undefined;
|
|
36
|
-
attachToTarget(targetId: string): Promise<CdpSession>;
|
|
37
|
-
getTargets(): Promise<Array<{
|
|
38
|
-
targetId: string;
|
|
39
|
-
type: string;
|
|
40
|
-
url: string;
|
|
41
|
-
}>>;
|
|
42
|
-
private onMessage;
|
|
43
|
-
_sendViaSession<R = unknown>(sessionId: string, method: string, params?: object): Promise<R>;
|
|
44
|
-
_onSessionEvent(sessionId: string, event: string, handler: EventHandler): void;
|
|
45
|
-
_offSessionEvent(sessionId: string, event: string, handler: EventHandler): void;
|
|
46
|
-
_dispatchToSession(sessionId: string, event: string, params: unknown): void;
|
|
47
|
-
}
|
|
48
|
-
export declare class CdpSession implements CDPSessionLike {
|
|
49
|
-
private readonly root;
|
|
50
|
-
readonly id: string;
|
|
51
|
-
constructor(root: CdpConnection, id: string);
|
|
52
|
-
send<R = unknown>(method: string, params?: object): Promise<R>;
|
|
53
|
-
on<P = unknown>(event: string, handler: (params: P) => void): void;
|
|
54
|
-
off<P = unknown>(event: string, handler: (params: P) => void): void;
|
|
55
|
-
close(): Promise<void>;
|
|
56
|
-
dispatch(event: string, params: unknown): void;
|
|
57
|
-
}
|
|
58
|
-
export {};
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import type { Protocol } from "devtools-protocol";
|
|
2
|
-
import { CdpConnection } from "./cdp";
|
|
3
|
-
import { Page } from "./page";
|
|
4
|
-
/**
|
|
5
|
-
* V3Context
|
|
6
|
-
*
|
|
7
|
-
* Owns the root CDP connection and wires Target/Page events into Page.
|
|
8
|
-
* Maintains one Page per top-level target, adopts OOPIF child sessions into the owner Page,
|
|
9
|
-
* and tracks target→page and (root) frame→target mappings for lookups.
|
|
10
|
-
*
|
|
11
|
-
* IMPORTANT: FrameId → session ownership is managed inside Page (via its FrameRegistry).
|
|
12
|
-
* Context never “guesses” owners; it simply forwards events (with the emitting session)
|
|
13
|
-
* so Page can record the correct owner at event time.
|
|
14
|
-
*/
|
|
15
|
-
export declare class V3Context {
|
|
16
|
-
readonly conn: CdpConnection;
|
|
17
|
-
private readonly includeCursor;
|
|
18
|
-
private readonly env;
|
|
19
|
-
private constructor();
|
|
20
|
-
private readonly _piercerInstalled;
|
|
21
|
-
private _lastPopupSignalAt;
|
|
22
|
-
private sessionKey;
|
|
23
|
-
private readonly _sessionInit;
|
|
24
|
-
private pagesByTarget;
|
|
25
|
-
private mainFrameToTarget;
|
|
26
|
-
private sessionOwnerPage;
|
|
27
|
-
private frameOwnerPage;
|
|
28
|
-
private pendingOopifByMainFrame;
|
|
29
|
-
private createdAtByTarget;
|
|
30
|
-
private typeByTarget;
|
|
31
|
-
private _pageOrder;
|
|
32
|
-
/**
|
|
33
|
-
* Create a Context for a given CDP websocket URL and bootstrap target wiring.
|
|
34
|
-
*/
|
|
35
|
-
static create(wsUrl: string, opts?: {
|
|
36
|
-
includeCursor?: boolean;
|
|
37
|
-
env?: "LOCAL" | "BROWSERBASE";
|
|
38
|
-
}): Promise<V3Context>;
|
|
39
|
-
/**
|
|
40
|
-
* Wait until at least one top-level Page has been created and registered.
|
|
41
|
-
* We poll internal maps that bootstrap/onAttachedToTarget populate.
|
|
42
|
-
*/
|
|
43
|
-
private waitForFirstTopLevelPage;
|
|
44
|
-
private ensurePiercer;
|
|
45
|
-
/** Mark a page target as the most-recent one (active). */
|
|
46
|
-
private _pushActive;
|
|
47
|
-
/** Remove a page target from the recency list (used on close). */
|
|
48
|
-
private _removeFromOrder;
|
|
49
|
-
/** Return the current active Page (most-recent page that still exists). */
|
|
50
|
-
activePage(): Page | undefined;
|
|
51
|
-
/**
|
|
52
|
-
* Return top-level `Page`s (oldest → newest). OOPIF targets are not included.
|
|
53
|
-
*/
|
|
54
|
-
pages(): Page[];
|
|
55
|
-
/**
|
|
56
|
-
* Resolve an owning `Page` by the **top-level main frame id**.
|
|
57
|
-
* Note: child (OOPIF) roots are intentionally not present in this mapping.
|
|
58
|
-
*/
|
|
59
|
-
resolvePageByMainFrameId(frameId: string): Page | undefined;
|
|
60
|
-
/**
|
|
61
|
-
* Serialize the full frame tree for a given top-level main frame id.
|
|
62
|
-
*/
|
|
63
|
-
getFullFrameTreeByMainFrameId(rootMainFrameId: string): Promise<Protocol.Page.FrameTree>;
|
|
64
|
-
/**
|
|
65
|
-
* Create a new top-level page (tab) with the given URL and return its Page object.
|
|
66
|
-
* Waits until the target is attached and registered.
|
|
67
|
-
*/
|
|
68
|
-
newPage(url?: string): Promise<Page>;
|
|
69
|
-
/**
|
|
70
|
-
* Close CDP and clear all mappings. Best-effort cleanup.
|
|
71
|
-
*/
|
|
72
|
-
close(): Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* Bootstrap target lifecycle:
|
|
75
|
-
* - Attach to existing targets.
|
|
76
|
-
* - Attach on `Target.targetCreated` (fallback for OOPIFs).
|
|
77
|
-
* - Handle auto-attach events.
|
|
78
|
-
* - Clean up on detach/destroy.
|
|
79
|
-
*/
|
|
80
|
-
private bootstrap;
|
|
81
|
-
/**
|
|
82
|
-
* Handle a newly attached target (top-level or potential OOPIF):
|
|
83
|
-
* - Enable Page domain and lifecycle events.
|
|
84
|
-
* - If top-level → create Page, wire listeners, resume.
|
|
85
|
-
* - Else → probe child root frame id via `Page.getFrameTree` and adopt immediately
|
|
86
|
-
* if the parent is known; otherwise stage until parent `frameAttached`.
|
|
87
|
-
* - Resume the target only after listeners are wired.
|
|
88
|
-
*/
|
|
89
|
-
private onAttachedToTarget;
|
|
90
|
-
/**
|
|
91
|
-
* Detach handler:
|
|
92
|
-
* - Remove child session ownership and prune its subtree.
|
|
93
|
-
* - If a top-level target, cleanup its `Page` and mappings.
|
|
94
|
-
* - Drop any staged child for this session.
|
|
95
|
-
*/
|
|
96
|
-
private onDetachedFromTarget;
|
|
97
|
-
/**
|
|
98
|
-
* Cleanup a top-level Page by target id, removing its root and staged children.
|
|
99
|
-
*/
|
|
100
|
-
private cleanupByTarget;
|
|
101
|
-
/**
|
|
102
|
-
* Wire Page-domain frame events for a session into the owning Page & mappings.
|
|
103
|
-
* We forward the *emitting session* with every event so Page can stamp ownership precisely.
|
|
104
|
-
*/
|
|
105
|
-
private installFrameEventBridges;
|
|
106
|
-
/**
|
|
107
|
-
* Register that a session belongs to a Page (used by event routing).
|
|
108
|
-
*/
|
|
109
|
-
private wireSessionToOwnerPage;
|
|
110
|
-
/**
|
|
111
|
-
* Utility: reverse-lookup the top-level target id that owns a given Page.
|
|
112
|
-
*/
|
|
113
|
-
private findTargetIdByPage;
|
|
114
|
-
private _notePopupSignal;
|
|
115
|
-
/**
|
|
116
|
-
* Await the current active page, waiting briefly if a popup/open was just triggered.
|
|
117
|
-
* Normal path returns immediately; popup path waits up to timeoutMs for the new page.
|
|
118
|
-
*/
|
|
119
|
-
awaitActivePage(timeoutMs?: number): Promise<Page>;
|
|
120
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Locator } from "./locator";
|
|
2
|
-
import type { Frame } from "./frame";
|
|
3
|
-
import type { Page } from "./page";
|
|
4
|
-
/** Build a Locator scoped to the correct frame for a deep XPath crossing iframes. */
|
|
5
|
-
export declare function deepLocatorThroughIframes(page: Page, root: Frame, xpathOrSelector: string): Promise<Locator>;
|
|
6
|
-
/**
|
|
7
|
-
* Unified resolver that supports '>>' hop notation, deep XPath across iframes,
|
|
8
|
-
* and plain single-frame selectors. Keeps hop logic in one shared place.
|
|
9
|
-
*/
|
|
10
|
-
export declare function resolveLocatorWithHops(page: Page, root: Frame, selectorRaw: string): Promise<Locator>;
|
|
11
|
-
/**
|
|
12
|
-
* DeepLocatorDelegate: a lightweight wrapper that looks like a Locator and
|
|
13
|
-
* resolves to the correct frame/element on each call using hop/deep-XPath logic.
|
|
14
|
-
*
|
|
15
|
-
* Returned by `page.deepLocator()` for ergonomic, await-free chaining:
|
|
16
|
-
* page.deepLocator('iframe#ifrA >> #btn').click()
|
|
17
|
-
*/
|
|
18
|
-
export declare class DeepLocatorDelegate {
|
|
19
|
-
private readonly page;
|
|
20
|
-
private readonly root;
|
|
21
|
-
private readonly selector;
|
|
22
|
-
constructor(page: Page, root: Frame, selector: string);
|
|
23
|
-
private real;
|
|
24
|
-
click(options?: {
|
|
25
|
-
button?: "left" | "right" | "middle";
|
|
26
|
-
clickCount?: number;
|
|
27
|
-
}): Promise<void>;
|
|
28
|
-
fill(value: string): Promise<void>;
|
|
29
|
-
type(text: string, options?: {
|
|
30
|
-
delay?: number;
|
|
31
|
-
}): Promise<void>;
|
|
32
|
-
selectOption(values: string | string[]): Promise<string[]>;
|
|
33
|
-
scrollTo(percent: number | string): Promise<void>;
|
|
34
|
-
isVisible(): Promise<boolean>;
|
|
35
|
-
isChecked(): Promise<boolean>;
|
|
36
|
-
inputValue(): Promise<string>;
|
|
37
|
-
textContent(): Promise<string>;
|
|
38
|
-
innerHtml(): Promise<string>;
|
|
39
|
-
innerText(): Promise<string>;
|
|
40
|
-
centroid(): Promise<{
|
|
41
|
-
x: number;
|
|
42
|
-
y: number;
|
|
43
|
-
}>;
|
|
44
|
-
backendNodeId(): Promise<number>;
|
|
45
|
-
highlight(options?: {
|
|
46
|
-
durationMs?: number;
|
|
47
|
-
borderColor?: {
|
|
48
|
-
r: number;
|
|
49
|
-
g: number;
|
|
50
|
-
b: number;
|
|
51
|
-
a?: number;
|
|
52
|
-
};
|
|
53
|
-
contentColor?: {
|
|
54
|
-
r: number;
|
|
55
|
-
g: number;
|
|
56
|
-
b: number;
|
|
57
|
-
a?: number;
|
|
58
|
-
};
|
|
59
|
-
}): Promise<void>;
|
|
60
|
-
sendClickEvent(options?: {
|
|
61
|
-
bubbles?: boolean;
|
|
62
|
-
cancelable?: boolean;
|
|
63
|
-
composed?: boolean;
|
|
64
|
-
detail?: number;
|
|
65
|
-
}): Promise<void>;
|
|
66
|
-
first(): this;
|
|
67
|
-
}
|
|
68
|
-
/** Factory to create a deep locator delegate from a Page + root frame. */
|
|
69
|
-
export declare function deepLocatorFromPage(page: Page, root: Frame, selector: string): DeepLocatorDelegate;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Protocol } from "devtools-protocol";
|
|
2
|
-
import type { CDPSessionLike } from "./cdp";
|
|
3
|
-
type FrameId = Protocol.Page.FrameId;
|
|
4
|
-
type ExecId = Protocol.Runtime.ExecutionContextId;
|
|
5
|
-
export declare class ExecutionContextRegistry {
|
|
6
|
-
private readonly byFrame;
|
|
7
|
-
private readonly byExec;
|
|
8
|
-
/** Wire listeners for this session. Call BEFORE Runtime.enable. */
|
|
9
|
-
attachSession(session: CDPSessionLike): void;
|
|
10
|
-
getMainWorld(session: CDPSessionLike, frameId: FrameId): ExecId | null;
|
|
11
|
-
waitForMainWorld(session: CDPSessionLike, frameId: FrameId, timeoutMs?: number): Promise<ExecId>;
|
|
12
|
-
private register;
|
|
13
|
-
}
|
|
14
|
-
export declare const executionContexts: ExecutionContextRegistry;
|
|
15
|
-
export {};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Protocol } from "devtools-protocol";
|
|
2
|
-
import type { CDPSessionLike } from "./cdp";
|
|
3
|
-
import { Locator } from "./locator";
|
|
4
|
-
interface FrameManager {
|
|
5
|
-
session: CDPSessionLike;
|
|
6
|
-
frameId: string;
|
|
7
|
-
pageId: string;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Frame
|
|
11
|
-
*
|
|
12
|
-
* A thin, session-bound handle to a specific DOM frame (by frameId).
|
|
13
|
-
* All CDP calls in this class go through `this.session`, which MUST be the
|
|
14
|
-
* owning session for `this.frameId`. Page is responsible for constructing
|
|
15
|
-
* Frames with the correct session.
|
|
16
|
-
*/
|
|
17
|
-
export declare class Frame implements FrameManager {
|
|
18
|
-
session: CDPSessionLike;
|
|
19
|
-
frameId: string;
|
|
20
|
-
pageId: string;
|
|
21
|
-
/** Owning CDP session id (useful for logs); null for root connection (should not happen for targets) */
|
|
22
|
-
readonly sessionId: string | null;
|
|
23
|
-
constructor(session: CDPSessionLike, frameId: string, pageId: string);
|
|
24
|
-
/** DOM.getNodeForLocation → DOM.describeNode */
|
|
25
|
-
getNodeAtLocation(x: number, y: number): Promise<Protocol.DOM.Node>;
|
|
26
|
-
/** CSS selector → DOM.querySelector → DOM.getBoxModel */
|
|
27
|
-
getLocationForSelector(selector: string): Promise<{
|
|
28
|
-
x: number;
|
|
29
|
-
y: number;
|
|
30
|
-
width: number;
|
|
31
|
-
height: number;
|
|
32
|
-
}>;
|
|
33
|
-
/** Accessibility.getFullAXTree (+ recurse into child frames if requested) */
|
|
34
|
-
getAccessibilityTree(withFrames?: boolean): Promise<Protocol.Accessibility.AXNode[]>;
|
|
35
|
-
/**
|
|
36
|
-
* Evaluate a function or expression in this frame's isolated world.
|
|
37
|
-
* - If a string is provided, treated as a JS expression.
|
|
38
|
-
* - If a function is provided, it is stringified and invoked with the optional argument.
|
|
39
|
-
*/
|
|
40
|
-
evaluate<R = unknown, Arg = unknown>(pageFunctionOrExpression: string | ((arg: Arg) => R | Promise<R>), arg?: Arg): Promise<R>;
|
|
41
|
-
/** Page.captureScreenshot (frame-scoped session) */
|
|
42
|
-
screenshot(options?: {
|
|
43
|
-
fullPage?: boolean;
|
|
44
|
-
clip?: {
|
|
45
|
-
x: number;
|
|
46
|
-
y: number;
|
|
47
|
-
width: number;
|
|
48
|
-
height: number;
|
|
49
|
-
};
|
|
50
|
-
}): Promise<string>;
|
|
51
|
-
/** Child frames via Page.getFrameTree */
|
|
52
|
-
childFrames(): Promise<Frame[]>;
|
|
53
|
-
/** Wait for a lifecycle state (load/domcontentloaded/networkidle) */
|
|
54
|
-
waitForLoadState(state?: "load" | "domcontentloaded" | "networkidle"): Promise<void>;
|
|
55
|
-
/** Simple placeholder for your own locator abstraction */
|
|
56
|
-
locator(selector: string, options?: {
|
|
57
|
-
deep?: boolean;
|
|
58
|
-
depth?: number;
|
|
59
|
-
}): Locator;
|
|
60
|
-
/** Create/get an isolated world for this frame and return its executionContextId */
|
|
61
|
-
private getExecutionContextId;
|
|
62
|
-
}
|
|
63
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { Page } from "./page";
|
|
2
|
-
import { Frame } from "./frame";
|
|
3
|
-
/**
|
|
4
|
-
* FrameLocator: resolves iframe elements to their child Frames and allows
|
|
5
|
-
* creating locators scoped to that frame. Supports chaining.
|
|
6
|
-
*/
|
|
7
|
-
export declare class FrameLocator {
|
|
8
|
-
private readonly parent?;
|
|
9
|
-
private readonly selector;
|
|
10
|
-
private readonly page;
|
|
11
|
-
private readonly root?;
|
|
12
|
-
constructor(page: Page, selector: string, parent?: FrameLocator, root?: Frame);
|
|
13
|
-
/** Create a nested FrameLocator under this one. */
|
|
14
|
-
frameLocator(selector: string): FrameLocator;
|
|
15
|
-
/** Resolve to the concrete Frame for this FrameLocator chain. */
|
|
16
|
-
resolveFrame(): Promise<Frame>;
|
|
17
|
-
/** Return a Locator scoped to this frame. Methods delegate to the frame lazily. */
|
|
18
|
-
locator(selector: string): LocatorDelegate;
|
|
19
|
-
}
|
|
20
|
-
/** A small delegating wrapper that resolves the frame lazily per call. */
|
|
21
|
-
declare class LocatorDelegate {
|
|
22
|
-
private readonly fl;
|
|
23
|
-
private readonly sel;
|
|
24
|
-
constructor(fl: FrameLocator, sel: string);
|
|
25
|
-
private real;
|
|
26
|
-
click(options?: {
|
|
27
|
-
button?: "left" | "right" | "middle";
|
|
28
|
-
clickCount?: number;
|
|
29
|
-
}): Promise<void>;
|
|
30
|
-
fill(value: string): Promise<void>;
|
|
31
|
-
type(text: string, options?: {
|
|
32
|
-
delay?: number;
|
|
33
|
-
}): Promise<void>;
|
|
34
|
-
selectOption(values: string | string[]): Promise<string[]>;
|
|
35
|
-
scrollTo(percent: number | string): Promise<void>;
|
|
36
|
-
isVisible(): Promise<boolean>;
|
|
37
|
-
isChecked(): Promise<boolean>;
|
|
38
|
-
inputValue(): Promise<string>;
|
|
39
|
-
textContent(): Promise<string>;
|
|
40
|
-
innerHtml(): Promise<string>;
|
|
41
|
-
innerText(): Promise<string>;
|
|
42
|
-
first(): LocatorDelegate;
|
|
43
|
-
}
|
|
44
|
-
/** Factory to start a FrameLocator chain from an arbitrary root Frame. */
|
|
45
|
-
export declare function frameLocatorFromFrame(page: Page, root: Frame, selector: string): FrameLocator;
|
|
46
|
-
export {};
|