@natewong1313/stagehand 3.0.8
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/LICENSE +21 -0
- package/README.md +164 -0
- package/dist/index.d.ts +4203 -0
- package/dist/index.js +68829 -0
- package/package.json +110 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4203 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import { ZodTypeAny, z, ZodObject, ZodRawShape, ZodError } from 'zod';
|
|
3
|
+
import * as z3 from 'zod/v3';
|
|
4
|
+
import { ClientOptions as ClientOptions$2 } from '@anthropic-ai/sdk';
|
|
5
|
+
import { GoogleVertexProviderSettings as GoogleVertexProviderSettings$1 } from '@ai-sdk/google-vertex';
|
|
6
|
+
import { LanguageModelV2 } from '@ai-sdk/provider';
|
|
7
|
+
import { ClientOptions as ClientOptions$1 } from 'openai';
|
|
8
|
+
import { Client, ClientOptions as ClientOptions$3 } from '@modelcontextprotocol/sdk/client/index.js';
|
|
9
|
+
import * as ai from 'ai';
|
|
10
|
+
import { ToolSet, ModelMessage, PrepareStepFunction, GenerateTextOnStepFinishCallback, StreamTextOnStepFinishCallback, StreamTextOnErrorCallback, StreamTextOnChunkCallback, StreamTextOnFinishCallback, StepResult, StreamTextResult, wrapLanguageModel, generateObject, generateText, streamText, streamObject, experimental_generateImage, embed, embedMany, experimental_transcribe, experimental_generateSpeech, InferUITools } from 'ai';
|
|
11
|
+
export { ModelMessage, Tool, tool } from 'ai';
|
|
12
|
+
import { Page as Page$1 } from 'playwright-core';
|
|
13
|
+
export { Page as PlaywrightPage } from 'playwright-core';
|
|
14
|
+
import { Page as Page$2 } from 'puppeteer-core';
|
|
15
|
+
export { Page as PuppeteerPage } from 'puppeteer-core';
|
|
16
|
+
import { Page as Page$3 } from 'patchright-core';
|
|
17
|
+
export { Page as PatchrightPage } from 'patchright-core';
|
|
18
|
+
import { Protocol } from 'devtools-protocol';
|
|
19
|
+
import { Buffer as Buffer$1 } from 'buffer';
|
|
20
|
+
import { z as z$1 } from 'zod/v4';
|
|
21
|
+
import { ChatCompletion } from 'openai/resources';
|
|
22
|
+
import { ToolSet as ToolSet$1 } from 'ai/dist';
|
|
23
|
+
import { Schema } from '@google/genai';
|
|
24
|
+
|
|
25
|
+
type StagehandZodSchema = ZodTypeAny | z3.ZodTypeAny;
|
|
26
|
+
type StagehandZodObject = ZodObject<ZodRawShape> | z3.ZodObject<z3.ZodRawShape>;
|
|
27
|
+
type InferStagehandSchema<T extends StagehandZodSchema> = T extends z3.ZodTypeAny ? z3.infer<T> : T extends ZodTypeAny ? z.infer<T> : never;
|
|
28
|
+
declare const isZod4Schema: (schema: StagehandZodSchema) => schema is ZodTypeAny & {
|
|
29
|
+
_zod: unknown;
|
|
30
|
+
};
|
|
31
|
+
declare const isZod3Schema: (schema: StagehandZodSchema) => schema is z3.ZodTypeAny;
|
|
32
|
+
type JsonSchemaDocument = Record<string, unknown>;
|
|
33
|
+
declare function toJsonSchema(schema: StagehandZodSchema): JsonSchemaDocument;
|
|
34
|
+
|
|
35
|
+
type LogLevel = 0 | 1 | 2;
|
|
36
|
+
/**
|
|
37
|
+
* Mapping between numeric log levels and their names
|
|
38
|
+
*
|
|
39
|
+
* 0 - error/warn - Critical issues or important warnings
|
|
40
|
+
* 1 - info - Standard information messages
|
|
41
|
+
* 2 - debug - Detailed information for debugging
|
|
42
|
+
*/
|
|
43
|
+
declare const LOG_LEVEL_NAMES: Record<LogLevel, string>;
|
|
44
|
+
type LogLine = {
|
|
45
|
+
id?: string;
|
|
46
|
+
category?: string;
|
|
47
|
+
message: string;
|
|
48
|
+
level?: LogLevel;
|
|
49
|
+
timestamp?: string;
|
|
50
|
+
auxiliary?: {
|
|
51
|
+
[key: string]: {
|
|
52
|
+
value: string;
|
|
53
|
+
type: "object" | "string" | "html" | "integer" | "float" | "boolean";
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
type Logger = (logLine: LogLine) => void;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* CDP transport & session multiplexer
|
|
61
|
+
*
|
|
62
|
+
* Owns the browser WebSocket and multiplexes flattened Target sessions.
|
|
63
|
+
* Tracks inflight CDP calls, routes responses to the right session, and forwards events.
|
|
64
|
+
*
|
|
65
|
+
* This does not interpret Page/DOM/Runtime semantics — callers own that logic.
|
|
66
|
+
*/
|
|
67
|
+
interface CDPSessionLike {
|
|
68
|
+
send<R = unknown>(method: string, params?: object): Promise<R>;
|
|
69
|
+
on<P = unknown>(event: string, handler: (params: P) => void): void;
|
|
70
|
+
off<P = unknown>(event: string, handler: (params: P) => void): void;
|
|
71
|
+
close(): Promise<void>;
|
|
72
|
+
readonly id: string | null;
|
|
73
|
+
}
|
|
74
|
+
type EventHandler = (params: unknown) => void;
|
|
75
|
+
declare class CdpConnection implements CDPSessionLike {
|
|
76
|
+
private ws;
|
|
77
|
+
private nextId;
|
|
78
|
+
private inflight;
|
|
79
|
+
private eventHandlers;
|
|
80
|
+
private sessions;
|
|
81
|
+
/** Maps sessionId -> targetId (1:1 mapping) */
|
|
82
|
+
private sessionToTarget;
|
|
83
|
+
readonly id: string | null;
|
|
84
|
+
private transportCloseHandlers;
|
|
85
|
+
/** Optional CDP logger - set this to receive all outgoing CDP method calls */
|
|
86
|
+
cdpLogger?: (info: {
|
|
87
|
+
method: string;
|
|
88
|
+
params?: object;
|
|
89
|
+
targetId?: string | null;
|
|
90
|
+
}) => void;
|
|
91
|
+
/** Optional CDP event logger - set this to receive all incoming CDP events */
|
|
92
|
+
cdpEventLogger?: (info: {
|
|
93
|
+
method: string;
|
|
94
|
+
params?: unknown;
|
|
95
|
+
targetId?: string | null;
|
|
96
|
+
}) => void;
|
|
97
|
+
onTransportClosed(handler: (why: string) => void): void;
|
|
98
|
+
offTransportClosed(handler: (why: string) => void): void;
|
|
99
|
+
private emitTransportClosed;
|
|
100
|
+
private constructor();
|
|
101
|
+
static connect(wsUrl: string): Promise<CdpConnection>;
|
|
102
|
+
enableAutoAttach(): Promise<void>;
|
|
103
|
+
send<R = unknown>(method: string, params?: object): Promise<R>;
|
|
104
|
+
on<P = unknown>(event: string, handler: (params: P) => void): void;
|
|
105
|
+
off<P = unknown>(event: string, handler: (params: P) => void): void;
|
|
106
|
+
close(): Promise<void>;
|
|
107
|
+
getSession(sessionId: string): CdpSession | undefined;
|
|
108
|
+
attachToTarget(targetId: string): Promise<CdpSession>;
|
|
109
|
+
getTargets(): Promise<Protocol.Target.TargetInfo[]>;
|
|
110
|
+
private onMessage;
|
|
111
|
+
_sendViaSession<R = unknown>(sessionId: string, method: string, params?: object): Promise<R>;
|
|
112
|
+
_onSessionEvent(sessionId: string, event: string, handler: EventHandler): void;
|
|
113
|
+
_offSessionEvent(sessionId: string, event: string, handler: EventHandler): void;
|
|
114
|
+
_dispatchToSession(sessionId: string, event: string, params: unknown): void;
|
|
115
|
+
}
|
|
116
|
+
declare class CdpSession implements CDPSessionLike {
|
|
117
|
+
private readonly root;
|
|
118
|
+
readonly id: string;
|
|
119
|
+
constructor(root: CdpConnection, id: string);
|
|
120
|
+
send<R = unknown>(method: string, params?: object): Promise<R>;
|
|
121
|
+
on<P = unknown>(event: string, handler: (params: P) => void): void;
|
|
122
|
+
off<P = unknown>(event: string, handler: (params: P) => void): void;
|
|
123
|
+
close(): Promise<void>;
|
|
124
|
+
dispatch(event: string, params: unknown): void;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface FrameManager {
|
|
128
|
+
session: CDPSessionLike;
|
|
129
|
+
frameId: string;
|
|
130
|
+
pageId: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Frame
|
|
134
|
+
*
|
|
135
|
+
* A thin, session-bound handle to a specific DOM frame (by frameId).
|
|
136
|
+
* All CDP calls in this class go through `this.session`, which MUST be the
|
|
137
|
+
* owning session for `this.frameId`. Page is responsible for constructing
|
|
138
|
+
* Frames with the correct session.
|
|
139
|
+
*/
|
|
140
|
+
declare class Frame implements FrameManager {
|
|
141
|
+
session: CDPSessionLike;
|
|
142
|
+
frameId: string;
|
|
143
|
+
pageId: string;
|
|
144
|
+
private readonly remoteBrowser;
|
|
145
|
+
/** Owning CDP session id (useful for logs); null for root connection (should not happen for targets) */
|
|
146
|
+
readonly sessionId: string | null;
|
|
147
|
+
constructor(session: CDPSessionLike, frameId: string, pageId: string, remoteBrowser: boolean);
|
|
148
|
+
/** True when the controlled browser runs on a different machine. */
|
|
149
|
+
isBrowserRemote(): boolean;
|
|
150
|
+
/** DOM.getNodeForLocation → DOM.describeNode */
|
|
151
|
+
getNodeAtLocation(x: number, y: number): Promise<Protocol.DOM.Node>;
|
|
152
|
+
/** CSS selector → DOM.querySelector → DOM.getBoxModel */
|
|
153
|
+
getLocationForSelector(selector: string): Promise<{
|
|
154
|
+
x: number;
|
|
155
|
+
y: number;
|
|
156
|
+
width: number;
|
|
157
|
+
height: number;
|
|
158
|
+
}>;
|
|
159
|
+
/** Accessibility.getFullAXTree (+ recurse into child frames if requested) */
|
|
160
|
+
getAccessibilityTree(withFrames?: boolean): Promise<Protocol.Accessibility.AXNode[]>;
|
|
161
|
+
/**
|
|
162
|
+
* Evaluate a function or expression in this frame's main world.
|
|
163
|
+
* - If a string is provided, treated as a JS expression.
|
|
164
|
+
* - If a function is provided, it is stringified and invoked with the optional argument.
|
|
165
|
+
*/
|
|
166
|
+
evaluate<R = unknown, Arg = unknown>(pageFunctionOrExpression: string | ((arg: Arg) => R | Promise<R>), arg?: Arg): Promise<R>;
|
|
167
|
+
/** Page.captureScreenshot (frame-scoped session) */
|
|
168
|
+
screenshot(options?: {
|
|
169
|
+
fullPage?: boolean;
|
|
170
|
+
clip?: {
|
|
171
|
+
x: number;
|
|
172
|
+
y: number;
|
|
173
|
+
width: number;
|
|
174
|
+
height: number;
|
|
175
|
+
};
|
|
176
|
+
type?: "png" | "jpeg";
|
|
177
|
+
quality?: number;
|
|
178
|
+
scale?: number;
|
|
179
|
+
}): Promise<Buffer>;
|
|
180
|
+
/** Child frames via Page.getFrameTree */
|
|
181
|
+
childFrames(): Promise<Frame[]>;
|
|
182
|
+
/** Wait for a lifecycle state (load/domcontentloaded/networkidle) */
|
|
183
|
+
waitForLoadState(state?: "load" | "domcontentloaded" | "networkidle", timeoutMs?: number): Promise<void>;
|
|
184
|
+
/** Simple placeholder for your own locator abstraction */
|
|
185
|
+
locator(selector: string, options?: {
|
|
186
|
+
deep?: boolean;
|
|
187
|
+
depth?: number;
|
|
188
|
+
}): Locator;
|
|
189
|
+
/** Resolve the main-world execution context id for this frame. */
|
|
190
|
+
private getMainWorldExecutionContextId;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
interface SetInputFilePayload {
|
|
194
|
+
name: string;
|
|
195
|
+
mimeType?: string;
|
|
196
|
+
buffer: ArrayBuffer | Uint8Array | Buffer$1 | string;
|
|
197
|
+
lastModified?: number;
|
|
198
|
+
}
|
|
199
|
+
type SetInputFilesArgument = string | string[] | SetInputFilePayload | SetInputFilePayload[];
|
|
200
|
+
|
|
201
|
+
type MouseButton = "left" | "right" | "middle";
|
|
202
|
+
/**
|
|
203
|
+
* Locator
|
|
204
|
+
*
|
|
205
|
+
* Purpose:
|
|
206
|
+
* A small, CDP-based element interaction helper scoped to a specific `Frame`.
|
|
207
|
+
* It resolves a CSS/XPath selector inside the frame’s **isolated world**, and then
|
|
208
|
+
* performs low-level actions (click, type, select) using DOM/Runtime/Input
|
|
209
|
+
* protocol domains with minimal abstraction.
|
|
210
|
+
*
|
|
211
|
+
* Key change:
|
|
212
|
+
* - Prefer **objectId**-based CDP calls (scroll, geometry) to avoid brittle
|
|
213
|
+
* frontend nodeId mappings. nodeId is resolved on a best-effort basis and
|
|
214
|
+
* returned for compatibility, but actions do not depend on it.
|
|
215
|
+
*
|
|
216
|
+
* Notes:
|
|
217
|
+
* - Resolution is lazy: every action resolves the selector again.
|
|
218
|
+
* - Uses `Page.createIsolatedWorld` so evaluation is isolated from page scripts.
|
|
219
|
+
* - Releases remote objects (`Runtime.releaseObject`) where appropriate.
|
|
220
|
+
*/
|
|
221
|
+
declare class Locator {
|
|
222
|
+
private readonly frame;
|
|
223
|
+
private readonly selector;
|
|
224
|
+
private readonly options?;
|
|
225
|
+
private readonly selectorResolver;
|
|
226
|
+
private readonly selectorQuery;
|
|
227
|
+
private readonly nthIndex;
|
|
228
|
+
constructor(frame: Frame, selector: string, options?: {
|
|
229
|
+
deep?: boolean;
|
|
230
|
+
depth?: number;
|
|
231
|
+
}, nthIndex?: number);
|
|
232
|
+
/** Return the owning Frame for this locator (typed accessor, no private access). */
|
|
233
|
+
getFrame(): Frame;
|
|
234
|
+
/**
|
|
235
|
+
* Set files on an <input type="file"> element.
|
|
236
|
+
*
|
|
237
|
+
* Mirrors Playwright's Locator.setInputFiles basics:
|
|
238
|
+
* - Accepts file path(s) or payload object(s) { name, mimeType, buffer }.
|
|
239
|
+
* - Uses CDP DOM.setFileInputFiles under the hood.
|
|
240
|
+
* - Best‑effort dispatches change/input via CDP (Chrome does by default).
|
|
241
|
+
* - Passing an empty array clears the selection.
|
|
242
|
+
*/
|
|
243
|
+
setInputFiles(files: SetInputFilesArgument): Promise<void>;
|
|
244
|
+
/**
|
|
245
|
+
* Remote browser fallback: build File objects inside the page and attach them via JS.
|
|
246
|
+
*
|
|
247
|
+
* When Stagehand is driving a browser that cannot see the local filesystem (Browserbase,
|
|
248
|
+
* remote CDP, etc.), CDP's DOM.setFileInputFiles would fail because Chrome can't reach
|
|
249
|
+
* our temp files. Instead we base64-encode the payloads, send them into the page, and
|
|
250
|
+
* let a DOM helper create File objects + dispatch change/input events.
|
|
251
|
+
*/
|
|
252
|
+
private assignFilesViaPayloadInjection;
|
|
253
|
+
/**
|
|
254
|
+
* Return the DOM backendNodeId for this locator's target element.
|
|
255
|
+
* Useful for identity comparisons without needing element handles.
|
|
256
|
+
*/
|
|
257
|
+
backendNodeId(): Promise<Protocol.DOM.BackendNodeId>;
|
|
258
|
+
/** Return how many nodes the current selector resolves to. */
|
|
259
|
+
count(): Promise<number>;
|
|
260
|
+
/**
|
|
261
|
+
* Return the center of the element's bounding box in the owning frame's viewport
|
|
262
|
+
* (CSS pixels), rounded to integers. Scrolls into view best-effort.
|
|
263
|
+
*/
|
|
264
|
+
centroid(): Promise<{
|
|
265
|
+
x: number;
|
|
266
|
+
y: number;
|
|
267
|
+
}>;
|
|
268
|
+
/**
|
|
269
|
+
* Highlight the element's bounding box using the CDP Overlay domain.
|
|
270
|
+
* - Scrolls element into view best-effort.
|
|
271
|
+
* - Shows a semi-transparent overlay briefly, then hides it.
|
|
272
|
+
*/
|
|
273
|
+
highlight(options?: {
|
|
274
|
+
durationMs?: number;
|
|
275
|
+
borderColor?: {
|
|
276
|
+
r: number;
|
|
277
|
+
g: number;
|
|
278
|
+
b: number;
|
|
279
|
+
a?: number;
|
|
280
|
+
};
|
|
281
|
+
contentColor?: {
|
|
282
|
+
r: number;
|
|
283
|
+
g: number;
|
|
284
|
+
b: number;
|
|
285
|
+
a?: number;
|
|
286
|
+
};
|
|
287
|
+
}): Promise<void>;
|
|
288
|
+
/**
|
|
289
|
+
* Move the mouse cursor to the element's visual center without clicking.
|
|
290
|
+
* - Scrolls into view best-effort, resolves geometry, then dispatches a mouse move.
|
|
291
|
+
*/
|
|
292
|
+
hover(): Promise<void>;
|
|
293
|
+
/**
|
|
294
|
+
* Click the element at its visual center.
|
|
295
|
+
* Steps:
|
|
296
|
+
* 1) Resolve selector to { objectId } in the frame world.
|
|
297
|
+
* 2) Scroll into view via `DOM.scrollIntoViewIfNeeded({ objectId })`.
|
|
298
|
+
* 3) Read geometry via `DOM.getBoxModel({ objectId })` → compute a center point.
|
|
299
|
+
* 4) Synthesize mouse press + release via `Input.dispatchMouseEvent`.
|
|
300
|
+
*/
|
|
301
|
+
click(options?: {
|
|
302
|
+
button?: MouseButton;
|
|
303
|
+
clickCount?: number;
|
|
304
|
+
}): Promise<void>;
|
|
305
|
+
/**
|
|
306
|
+
* Dispatch a DOM 'click' MouseEvent on the element itself.
|
|
307
|
+
* - Does not synthesize real pointer input; directly dispatches an event.
|
|
308
|
+
* - Useful for elements that rely on click handlers without needing hit-testing.
|
|
309
|
+
*/
|
|
310
|
+
sendClickEvent(options?: {
|
|
311
|
+
bubbles?: boolean;
|
|
312
|
+
cancelable?: boolean;
|
|
313
|
+
composed?: boolean;
|
|
314
|
+
detail?: number;
|
|
315
|
+
}): Promise<void>;
|
|
316
|
+
/**
|
|
317
|
+
* Scroll the element vertically to a given percentage (0–100).
|
|
318
|
+
* - If the element is <html> or <body>, scrolls the window/document.
|
|
319
|
+
* - Otherwise, scrolls the element itself via element.scrollTo.
|
|
320
|
+
*/
|
|
321
|
+
scrollTo(percent: number | string): Promise<void>;
|
|
322
|
+
/**
|
|
323
|
+
* Fill an input/textarea/contenteditable element.
|
|
324
|
+
* Mirrors Playwright semantics: the DOM helper either applies the native
|
|
325
|
+
* value setter (for special input types) or asks us to type text via the CDP
|
|
326
|
+
* Input domain after focusing/selecting.
|
|
327
|
+
*/
|
|
328
|
+
fill(value: string): Promise<void>;
|
|
329
|
+
/**
|
|
330
|
+
* Type text into the element (focuses first).
|
|
331
|
+
* - Focus via element.focus() in page JS (no DOM.focus(nodeId)).
|
|
332
|
+
* - If no delay, uses `Input.insertText` for efficiency.
|
|
333
|
+
* - With delay, synthesizes `keyDown`/`keyUp` per character.
|
|
334
|
+
*/
|
|
335
|
+
type(text: string, options?: {
|
|
336
|
+
delay?: number;
|
|
337
|
+
}): Promise<void>;
|
|
338
|
+
/**
|
|
339
|
+
* Select one or more options on a `<select>` element.
|
|
340
|
+
* Returns the values actually selected after the operation.
|
|
341
|
+
*/
|
|
342
|
+
selectOption(values: string | string[]): Promise<string[]>;
|
|
343
|
+
/**
|
|
344
|
+
* Return true if the element is attached and visible (rough heuristic).
|
|
345
|
+
*/
|
|
346
|
+
isVisible(): Promise<boolean>;
|
|
347
|
+
/**
|
|
348
|
+
* Return true if the element is an input[type=checkbox|radio] and is checked.
|
|
349
|
+
* Also considers aria-checked for ARIA widgets.
|
|
350
|
+
*/
|
|
351
|
+
isChecked(): Promise<boolean>;
|
|
352
|
+
/**
|
|
353
|
+
* Return the element's input value (for input/textarea/select/contenteditable).
|
|
354
|
+
*/
|
|
355
|
+
inputValue(): Promise<string>;
|
|
356
|
+
/**
|
|
357
|
+
* Return the element's textContent (raw, not innerText).
|
|
358
|
+
*/
|
|
359
|
+
textContent(): Promise<string>;
|
|
360
|
+
/**
|
|
361
|
+
* Return the element's innerHTML string.
|
|
362
|
+
*/
|
|
363
|
+
innerHtml(): Promise<string>;
|
|
364
|
+
/**
|
|
365
|
+
* Return the element's innerText (layout-aware, visible text).
|
|
366
|
+
*/
|
|
367
|
+
innerText(): Promise<string>;
|
|
368
|
+
/**
|
|
369
|
+
* For API parity, returns the same locator (querySelector already returns the first match).
|
|
370
|
+
*/
|
|
371
|
+
first(): Locator;
|
|
372
|
+
/** Return a locator narrowed to the element at the given zero-based index. */
|
|
373
|
+
nth(index: number): Locator;
|
|
374
|
+
/**
|
|
375
|
+
* Resolve `this.selector` within the frame to `{ objectId, nodeId? }`:
|
|
376
|
+
* Delegates to a shared selector resolver so all selector logic stays in sync.
|
|
377
|
+
*/
|
|
378
|
+
resolveNode(): Promise<{
|
|
379
|
+
nodeId: Protocol.DOM.NodeId | null;
|
|
380
|
+
objectId: Protocol.Runtime.RemoteObjectId;
|
|
381
|
+
}>;
|
|
382
|
+
/** Compute a center point from a BoxModel content quad */
|
|
383
|
+
private centerFromBoxContent;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* DeepLocatorDelegate: a lightweight wrapper that looks like a Locator and
|
|
388
|
+
* resolves to the correct frame/element on each call using hop/deep-XPath logic.
|
|
389
|
+
*
|
|
390
|
+
* Returned by `page.deepLocator()` for ergonomic, await-free chaining:
|
|
391
|
+
* page.deepLocator('iframe#ifrA >> #btn').click()
|
|
392
|
+
*/
|
|
393
|
+
declare class DeepLocatorDelegate {
|
|
394
|
+
private readonly page;
|
|
395
|
+
private readonly root;
|
|
396
|
+
private readonly selector;
|
|
397
|
+
private readonly nthIndex;
|
|
398
|
+
constructor(page: Page, root: Frame, selector: string, nthIndex?: number);
|
|
399
|
+
private real;
|
|
400
|
+
click(options?: {
|
|
401
|
+
button?: "left" | "right" | "middle";
|
|
402
|
+
clickCount?: number;
|
|
403
|
+
}): Promise<void>;
|
|
404
|
+
count(): Promise<number>;
|
|
405
|
+
hover(): Promise<void>;
|
|
406
|
+
fill(value: string): Promise<void>;
|
|
407
|
+
type(text: string, options?: {
|
|
408
|
+
delay?: number;
|
|
409
|
+
}): Promise<void>;
|
|
410
|
+
selectOption(values: string | string[]): Promise<string[]>;
|
|
411
|
+
scrollTo(percent: number | string): Promise<void>;
|
|
412
|
+
isVisible(): Promise<boolean>;
|
|
413
|
+
isChecked(): Promise<boolean>;
|
|
414
|
+
inputValue(): Promise<string>;
|
|
415
|
+
textContent(): Promise<string>;
|
|
416
|
+
innerHtml(): Promise<string>;
|
|
417
|
+
innerText(): Promise<string>;
|
|
418
|
+
centroid(): Promise<{
|
|
419
|
+
x: number;
|
|
420
|
+
y: number;
|
|
421
|
+
}>;
|
|
422
|
+
backendNodeId(): Promise<number>;
|
|
423
|
+
highlight(options?: {
|
|
424
|
+
durationMs?: number;
|
|
425
|
+
borderColor?: {
|
|
426
|
+
r: number;
|
|
427
|
+
g: number;
|
|
428
|
+
b: number;
|
|
429
|
+
a?: number;
|
|
430
|
+
};
|
|
431
|
+
contentColor?: {
|
|
432
|
+
r: number;
|
|
433
|
+
g: number;
|
|
434
|
+
b: number;
|
|
435
|
+
a?: number;
|
|
436
|
+
};
|
|
437
|
+
}): Promise<void>;
|
|
438
|
+
sendClickEvent(options?: {
|
|
439
|
+
bubbles?: boolean;
|
|
440
|
+
cancelable?: boolean;
|
|
441
|
+
composed?: boolean;
|
|
442
|
+
detail?: number;
|
|
443
|
+
}): Promise<void>;
|
|
444
|
+
setInputFiles(files: string | string[] | {
|
|
445
|
+
name: string;
|
|
446
|
+
mimeType: string;
|
|
447
|
+
buffer: ArrayBuffer | Uint8Array | Buffer | string;
|
|
448
|
+
} | Array<{
|
|
449
|
+
name: string;
|
|
450
|
+
mimeType: string;
|
|
451
|
+
buffer: ArrayBuffer | Uint8Array | Buffer | string;
|
|
452
|
+
}>): Promise<void>;
|
|
453
|
+
first(): DeepLocatorDelegate;
|
|
454
|
+
nth(index: number): DeepLocatorDelegate;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* FrameLocator: resolves iframe elements to their child Frames and allows
|
|
459
|
+
* creating locators scoped to that frame. Supports chaining.
|
|
460
|
+
*/
|
|
461
|
+
declare class FrameLocator {
|
|
462
|
+
private readonly parent?;
|
|
463
|
+
private readonly selector;
|
|
464
|
+
private readonly page;
|
|
465
|
+
private readonly root?;
|
|
466
|
+
constructor(page: Page, selector: string, parent?: FrameLocator, root?: Frame);
|
|
467
|
+
/** Create a nested FrameLocator under this one. */
|
|
468
|
+
frameLocator(selector: string): FrameLocator;
|
|
469
|
+
/** Resolve to the concrete Frame for this FrameLocator chain. */
|
|
470
|
+
resolveFrame(): Promise<Frame>;
|
|
471
|
+
/** Return a Locator scoped to this frame. Methods delegate to the frame lazily. */
|
|
472
|
+
locator(selector: string): LocatorDelegate;
|
|
473
|
+
}
|
|
474
|
+
/** A small delegating wrapper that resolves the frame lazily per call. */
|
|
475
|
+
declare class LocatorDelegate {
|
|
476
|
+
private readonly fl;
|
|
477
|
+
private readonly sel;
|
|
478
|
+
constructor(fl: FrameLocator, sel: string);
|
|
479
|
+
private real;
|
|
480
|
+
click(options?: {
|
|
481
|
+
button?: "left" | "right" | "middle";
|
|
482
|
+
clickCount?: number;
|
|
483
|
+
}): Promise<void>;
|
|
484
|
+
hover(): Promise<void>;
|
|
485
|
+
fill(value: string): Promise<void>;
|
|
486
|
+
type(text: string, options?: {
|
|
487
|
+
delay?: number;
|
|
488
|
+
}): Promise<void>;
|
|
489
|
+
selectOption(values: string | string[]): Promise<string[]>;
|
|
490
|
+
scrollTo(percent: number | string): Promise<void>;
|
|
491
|
+
isVisible(): Promise<boolean>;
|
|
492
|
+
isChecked(): Promise<boolean>;
|
|
493
|
+
inputValue(): Promise<string>;
|
|
494
|
+
textContent(): Promise<string>;
|
|
495
|
+
innerHtml(): Promise<string>;
|
|
496
|
+
innerText(): Promise<string>;
|
|
497
|
+
count(): Promise<number>;
|
|
498
|
+
first(): LocatorDelegate;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
type RemoteObject = Protocol.Runtime.RemoteObject;
|
|
502
|
+
type ConsoleListener = (message: ConsoleMessage) => void;
|
|
503
|
+
declare class ConsoleMessage {
|
|
504
|
+
private readonly event;
|
|
505
|
+
private readonly pageRef?;
|
|
506
|
+
constructor(event: Protocol.Runtime.ConsoleAPICalledEvent, pageRef?: Page);
|
|
507
|
+
type(): Protocol.Runtime.ConsoleAPICalledEvent["type"];
|
|
508
|
+
text(): string;
|
|
509
|
+
args(): RemoteObject[];
|
|
510
|
+
location(): {
|
|
511
|
+
url?: string;
|
|
512
|
+
lineNumber?: number;
|
|
513
|
+
columnNumber?: number;
|
|
514
|
+
};
|
|
515
|
+
page(): Page | undefined;
|
|
516
|
+
timestamp(): number | undefined;
|
|
517
|
+
raw(): Protocol.Runtime.ConsoleAPICalledEvent;
|
|
518
|
+
toString(): string;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
interface SerializableResponse {
|
|
522
|
+
requestId: string;
|
|
523
|
+
frameId?: string;
|
|
524
|
+
loaderId?: string;
|
|
525
|
+
response: Protocol.Network.Response;
|
|
526
|
+
fromServiceWorkerFlag?: boolean;
|
|
527
|
+
finishedSettled?: boolean;
|
|
528
|
+
extraInfoHeaders?: Protocol.Network.Headers | null;
|
|
529
|
+
extraInfoHeadersText?: string;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Represents a path through a Zod schema from the root object down to a
|
|
534
|
+
* particular field. The `segments` array describes the chain of keys/indices.
|
|
535
|
+
*
|
|
536
|
+
* - **String** segments indicate object property names.
|
|
537
|
+
* - **Number** segments indicate array indices.
|
|
538
|
+
*
|
|
539
|
+
* For example, `["users", 0, "homepage"]` might describe reaching
|
|
540
|
+
* the `homepage` field in `schema.users[0].homepage`.
|
|
541
|
+
*/
|
|
542
|
+
interface ZodPathSegments {
|
|
543
|
+
/**
|
|
544
|
+
* The ordered list of keys/indices leading from the schema root
|
|
545
|
+
* to the targeted field.
|
|
546
|
+
*/
|
|
547
|
+
segments: Array<string | number>;
|
|
548
|
+
}
|
|
549
|
+
type InitScriptSource<Arg> = string | {
|
|
550
|
+
path?: string;
|
|
551
|
+
content?: string;
|
|
552
|
+
} | ((arg: Arg) => unknown);
|
|
553
|
+
|
|
554
|
+
type EvaluateOptions = {
|
|
555
|
+
/** The question to ask about the task state */
|
|
556
|
+
question: string;
|
|
557
|
+
/** The answer to the question */
|
|
558
|
+
answer?: string;
|
|
559
|
+
/** Whether to take a screenshot of the task state, or array of screenshots to evaluate */
|
|
560
|
+
screenshot?: boolean | Buffer[];
|
|
561
|
+
/** Custom system prompt for the evaluator */
|
|
562
|
+
systemPrompt?: string;
|
|
563
|
+
/** Delay in milliseconds before taking the screenshot @default 250 */
|
|
564
|
+
screenshotDelayMs?: number;
|
|
565
|
+
/** The agent's reasoning/thought process for completing the task */
|
|
566
|
+
agentReasoning?: string;
|
|
567
|
+
};
|
|
568
|
+
type BatchAskOptions = {
|
|
569
|
+
/** Array of questions with optional answers */
|
|
570
|
+
questions: Array<{
|
|
571
|
+
question: string;
|
|
572
|
+
answer?: string;
|
|
573
|
+
}>;
|
|
574
|
+
/** Whether to take a screenshot of the task state */
|
|
575
|
+
screenshot?: boolean;
|
|
576
|
+
/** Custom system prompt for the evaluator */
|
|
577
|
+
systemPrompt?: string;
|
|
578
|
+
/** Delay in milliseconds before taking the screenshot @default 1000 */
|
|
579
|
+
screenshotDelayMs?: number;
|
|
580
|
+
};
|
|
581
|
+
/**
|
|
582
|
+
* Result of an evaluation
|
|
583
|
+
*/
|
|
584
|
+
interface EvaluationResult {
|
|
585
|
+
/**
|
|
586
|
+
* The evaluation result ('YES', 'NO', or 'INVALID' if parsing failed or value was unexpected)
|
|
587
|
+
*/
|
|
588
|
+
evaluation: "YES" | "NO" | "INVALID";
|
|
589
|
+
/**
|
|
590
|
+
* The reasoning behind the evaluation
|
|
591
|
+
*/
|
|
592
|
+
reasoning: string;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Centralized Zod schemas for Stagehand Server API
|
|
597
|
+
*
|
|
598
|
+
* Naming conventions:
|
|
599
|
+
* - `*RequestSchema` - Request body schemas (zod4), `*Request` is the inferred type
|
|
600
|
+
* - `*ResultSchema` - Inner response data (unwrapped), `*Result` is the inferred type
|
|
601
|
+
* - `*ResponseSchema` - Full response with success wrapper: { success: true, data: *Result }, `*Response` is the inferred type
|
|
602
|
+
*
|
|
603
|
+
* All TypeScript types are inferred from the Zod4 *Schemas using z.infer<>
|
|
604
|
+
*/
|
|
605
|
+
|
|
606
|
+
/** Browser launch options for local browsers */
|
|
607
|
+
declare const LocalBrowserLaunchOptionsSchema: z$1.ZodObject<{
|
|
608
|
+
args: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
609
|
+
executablePath: z$1.ZodOptional<z$1.ZodString>;
|
|
610
|
+
userDataDir: z$1.ZodOptional<z$1.ZodString>;
|
|
611
|
+
preserveUserDataDir: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
612
|
+
headless: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
613
|
+
devtools: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
614
|
+
chromiumSandbox: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
615
|
+
ignoreDefaultArgs: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodBoolean, z$1.ZodArray<z$1.ZodString>]>>;
|
|
616
|
+
proxy: z$1.ZodOptional<z$1.ZodObject<{
|
|
617
|
+
server: z$1.ZodString;
|
|
618
|
+
bypass: z$1.ZodOptional<z$1.ZodString>;
|
|
619
|
+
username: z$1.ZodOptional<z$1.ZodString>;
|
|
620
|
+
password: z$1.ZodOptional<z$1.ZodString>;
|
|
621
|
+
}, z$1.core.$strip>>;
|
|
622
|
+
locale: z$1.ZodOptional<z$1.ZodString>;
|
|
623
|
+
viewport: z$1.ZodOptional<z$1.ZodObject<{
|
|
624
|
+
width: z$1.ZodNumber;
|
|
625
|
+
height: z$1.ZodNumber;
|
|
626
|
+
}, z$1.core.$strip>>;
|
|
627
|
+
deviceScaleFactor: z$1.ZodOptional<z$1.ZodNumber>;
|
|
628
|
+
hasTouch: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
629
|
+
ignoreHTTPSErrors: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
630
|
+
cdpUrl: z$1.ZodOptional<z$1.ZodString>;
|
|
631
|
+
connectTimeoutMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
632
|
+
downloadsPath: z$1.ZodOptional<z$1.ZodString>;
|
|
633
|
+
acceptDownloads: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
634
|
+
}, z$1.core.$strict>;
|
|
635
|
+
/** Simple model name string */
|
|
636
|
+
declare const ModelNameSchema: z$1.ZodString;
|
|
637
|
+
/** Detailed model configuration object */
|
|
638
|
+
declare const ModelConfigObjectSchema: z$1.ZodObject<{
|
|
639
|
+
provider: z$1.ZodOptional<z$1.ZodEnum<{
|
|
640
|
+
openai: "openai";
|
|
641
|
+
anthropic: "anthropic";
|
|
642
|
+
google: "google";
|
|
643
|
+
microsoft: "microsoft";
|
|
644
|
+
}>>;
|
|
645
|
+
modelName: z$1.ZodString;
|
|
646
|
+
apiKey: z$1.ZodOptional<z$1.ZodString>;
|
|
647
|
+
baseURL: z$1.ZodOptional<z$1.ZodString>;
|
|
648
|
+
}, z$1.core.$strip>;
|
|
649
|
+
/** Model configuration - string model name or detailed config */
|
|
650
|
+
declare const ModelConfigSchema: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
|
|
651
|
+
provider: z$1.ZodOptional<z$1.ZodEnum<{
|
|
652
|
+
openai: "openai";
|
|
653
|
+
anthropic: "anthropic";
|
|
654
|
+
google: "google";
|
|
655
|
+
microsoft: "microsoft";
|
|
656
|
+
}>>;
|
|
657
|
+
modelName: z$1.ZodString;
|
|
658
|
+
apiKey: z$1.ZodOptional<z$1.ZodString>;
|
|
659
|
+
baseURL: z$1.ZodOptional<z$1.ZodString>;
|
|
660
|
+
}, z$1.core.$strip>]>;
|
|
661
|
+
/** Action object returned by observe and used by act */
|
|
662
|
+
declare const ActionSchema: z$1.ZodObject<{
|
|
663
|
+
selector: z$1.ZodString;
|
|
664
|
+
description: z$1.ZodString;
|
|
665
|
+
backendNodeId: z$1.ZodOptional<z$1.ZodNumber>;
|
|
666
|
+
method: z$1.ZodOptional<z$1.ZodString>;
|
|
667
|
+
arguments: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
668
|
+
}, z$1.core.$strip>;
|
|
669
|
+
/** Session ID path parameter */
|
|
670
|
+
declare const SessionIdParamsSchema: z$1.ZodObject<{
|
|
671
|
+
id: z$1.ZodString;
|
|
672
|
+
}, z$1.core.$strict>;
|
|
673
|
+
/** Browser configuration for session start */
|
|
674
|
+
declare const BrowserConfigSchema: z$1.ZodObject<{
|
|
675
|
+
type: z$1.ZodOptional<z$1.ZodEnum<{
|
|
676
|
+
local: "local";
|
|
677
|
+
browserbase: "browserbase";
|
|
678
|
+
}>>;
|
|
679
|
+
cdpUrl: z$1.ZodOptional<z$1.ZodString>;
|
|
680
|
+
launchOptions: z$1.ZodOptional<z$1.ZodObject<{
|
|
681
|
+
args: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
682
|
+
executablePath: z$1.ZodOptional<z$1.ZodString>;
|
|
683
|
+
userDataDir: z$1.ZodOptional<z$1.ZodString>;
|
|
684
|
+
preserveUserDataDir: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
685
|
+
headless: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
686
|
+
devtools: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
687
|
+
chromiumSandbox: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
688
|
+
ignoreDefaultArgs: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodBoolean, z$1.ZodArray<z$1.ZodString>]>>;
|
|
689
|
+
proxy: z$1.ZodOptional<z$1.ZodObject<{
|
|
690
|
+
server: z$1.ZodString;
|
|
691
|
+
bypass: z$1.ZodOptional<z$1.ZodString>;
|
|
692
|
+
username: z$1.ZodOptional<z$1.ZodString>;
|
|
693
|
+
password: z$1.ZodOptional<z$1.ZodString>;
|
|
694
|
+
}, z$1.core.$strip>>;
|
|
695
|
+
locale: z$1.ZodOptional<z$1.ZodString>;
|
|
696
|
+
viewport: z$1.ZodOptional<z$1.ZodObject<{
|
|
697
|
+
width: z$1.ZodNumber;
|
|
698
|
+
height: z$1.ZodNumber;
|
|
699
|
+
}, z$1.core.$strip>>;
|
|
700
|
+
deviceScaleFactor: z$1.ZodOptional<z$1.ZodNumber>;
|
|
701
|
+
hasTouch: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
702
|
+
ignoreHTTPSErrors: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
703
|
+
cdpUrl: z$1.ZodOptional<z$1.ZodString>;
|
|
704
|
+
connectTimeoutMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
705
|
+
downloadsPath: z$1.ZodOptional<z$1.ZodString>;
|
|
706
|
+
acceptDownloads: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
707
|
+
}, z$1.core.$strict>>;
|
|
708
|
+
}, z$1.core.$strip>;
|
|
709
|
+
/** Operational headers for all session requests (auth handled via security schemes) */
|
|
710
|
+
declare const SessionHeadersSchema: z$1.ZodObject<{
|
|
711
|
+
"x-stream-response": z$1.ZodOptional<z$1.ZodEnum<{
|
|
712
|
+
true: "true";
|
|
713
|
+
false: "false";
|
|
714
|
+
}>>;
|
|
715
|
+
"x-language": z$1.ZodOptional<z$1.ZodEnum<{
|
|
716
|
+
typescript: "typescript";
|
|
717
|
+
python: "python";
|
|
718
|
+
playground: "playground";
|
|
719
|
+
}>>;
|
|
720
|
+
"x-sdk-version": z$1.ZodOptional<z$1.ZodString>;
|
|
721
|
+
"x-sent-at": z$1.ZodOptional<z$1.ZodString>;
|
|
722
|
+
}, z$1.core.$strip>;
|
|
723
|
+
/** Standard error response */
|
|
724
|
+
declare const ErrorResponseSchema: z$1.ZodObject<{
|
|
725
|
+
success: z$1.ZodLiteral<false>;
|
|
726
|
+
error: z$1.ZodString;
|
|
727
|
+
code: z$1.ZodOptional<z$1.ZodString>;
|
|
728
|
+
}, z$1.core.$strict>;
|
|
729
|
+
/** Browserbase viewport configuration */
|
|
730
|
+
declare const BrowserbaseViewportSchema: z$1.ZodObject<{
|
|
731
|
+
width: z$1.ZodOptional<z$1.ZodNumber>;
|
|
732
|
+
height: z$1.ZodOptional<z$1.ZodNumber>;
|
|
733
|
+
}, z$1.core.$strip>;
|
|
734
|
+
/** Browserbase fingerprint screen configuration */
|
|
735
|
+
declare const BrowserbaseFingerprintScreenSchema: z$1.ZodObject<{
|
|
736
|
+
maxHeight: z$1.ZodOptional<z$1.ZodNumber>;
|
|
737
|
+
maxWidth: z$1.ZodOptional<z$1.ZodNumber>;
|
|
738
|
+
minHeight: z$1.ZodOptional<z$1.ZodNumber>;
|
|
739
|
+
minWidth: z$1.ZodOptional<z$1.ZodNumber>;
|
|
740
|
+
}, z$1.core.$strip>;
|
|
741
|
+
/** Browserbase fingerprint configuration for stealth mode */
|
|
742
|
+
declare const BrowserbaseFingerprintSchema: z$1.ZodObject<{
|
|
743
|
+
browsers: z$1.ZodOptional<z$1.ZodArray<z$1.ZodEnum<{
|
|
744
|
+
chrome: "chrome";
|
|
745
|
+
edge: "edge";
|
|
746
|
+
firefox: "firefox";
|
|
747
|
+
safari: "safari";
|
|
748
|
+
}>>>;
|
|
749
|
+
devices: z$1.ZodOptional<z$1.ZodArray<z$1.ZodEnum<{
|
|
750
|
+
desktop: "desktop";
|
|
751
|
+
mobile: "mobile";
|
|
752
|
+
}>>>;
|
|
753
|
+
httpVersion: z$1.ZodOptional<z$1.ZodEnum<{
|
|
754
|
+
1: "1";
|
|
755
|
+
2: "2";
|
|
756
|
+
}>>;
|
|
757
|
+
locales: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
758
|
+
operatingSystems: z$1.ZodOptional<z$1.ZodArray<z$1.ZodEnum<{
|
|
759
|
+
android: "android";
|
|
760
|
+
ios: "ios";
|
|
761
|
+
linux: "linux";
|
|
762
|
+
macos: "macos";
|
|
763
|
+
windows: "windows";
|
|
764
|
+
}>>>;
|
|
765
|
+
screen: z$1.ZodOptional<z$1.ZodObject<{
|
|
766
|
+
maxHeight: z$1.ZodOptional<z$1.ZodNumber>;
|
|
767
|
+
maxWidth: z$1.ZodOptional<z$1.ZodNumber>;
|
|
768
|
+
minHeight: z$1.ZodOptional<z$1.ZodNumber>;
|
|
769
|
+
minWidth: z$1.ZodOptional<z$1.ZodNumber>;
|
|
770
|
+
}, z$1.core.$strip>>;
|
|
771
|
+
}, z$1.core.$strip>;
|
|
772
|
+
/** Browserbase context configuration for session persistence */
|
|
773
|
+
declare const BrowserbaseContextSchema: z$1.ZodObject<{
|
|
774
|
+
id: z$1.ZodString;
|
|
775
|
+
persist: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
776
|
+
}, z$1.core.$strip>;
|
|
777
|
+
/** Browserbase browser settings for session creation */
|
|
778
|
+
declare const BrowserbaseBrowserSettingsSchema: z$1.ZodObject<{
|
|
779
|
+
advancedStealth: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
780
|
+
blockAds: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
781
|
+
context: z$1.ZodOptional<z$1.ZodObject<{
|
|
782
|
+
id: z$1.ZodString;
|
|
783
|
+
persist: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
784
|
+
}, z$1.core.$strip>>;
|
|
785
|
+
extensionId: z$1.ZodOptional<z$1.ZodString>;
|
|
786
|
+
fingerprint: z$1.ZodOptional<z$1.ZodObject<{
|
|
787
|
+
browsers: z$1.ZodOptional<z$1.ZodArray<z$1.ZodEnum<{
|
|
788
|
+
chrome: "chrome";
|
|
789
|
+
edge: "edge";
|
|
790
|
+
firefox: "firefox";
|
|
791
|
+
safari: "safari";
|
|
792
|
+
}>>>;
|
|
793
|
+
devices: z$1.ZodOptional<z$1.ZodArray<z$1.ZodEnum<{
|
|
794
|
+
desktop: "desktop";
|
|
795
|
+
mobile: "mobile";
|
|
796
|
+
}>>>;
|
|
797
|
+
httpVersion: z$1.ZodOptional<z$1.ZodEnum<{
|
|
798
|
+
1: "1";
|
|
799
|
+
2: "2";
|
|
800
|
+
}>>;
|
|
801
|
+
locales: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
802
|
+
operatingSystems: z$1.ZodOptional<z$1.ZodArray<z$1.ZodEnum<{
|
|
803
|
+
android: "android";
|
|
804
|
+
ios: "ios";
|
|
805
|
+
linux: "linux";
|
|
806
|
+
macos: "macos";
|
|
807
|
+
windows: "windows";
|
|
808
|
+
}>>>;
|
|
809
|
+
screen: z$1.ZodOptional<z$1.ZodObject<{
|
|
810
|
+
maxHeight: z$1.ZodOptional<z$1.ZodNumber>;
|
|
811
|
+
maxWidth: z$1.ZodOptional<z$1.ZodNumber>;
|
|
812
|
+
minHeight: z$1.ZodOptional<z$1.ZodNumber>;
|
|
813
|
+
minWidth: z$1.ZodOptional<z$1.ZodNumber>;
|
|
814
|
+
}, z$1.core.$strip>>;
|
|
815
|
+
}, z$1.core.$strip>>;
|
|
816
|
+
logSession: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
817
|
+
recordSession: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
818
|
+
solveCaptchas: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
819
|
+
viewport: z$1.ZodOptional<z$1.ZodObject<{
|
|
820
|
+
width: z$1.ZodOptional<z$1.ZodNumber>;
|
|
821
|
+
height: z$1.ZodOptional<z$1.ZodNumber>;
|
|
822
|
+
}, z$1.core.$strip>>;
|
|
823
|
+
}, z$1.core.$strip>;
|
|
824
|
+
/** Browserbase managed proxy geolocation configuration */
|
|
825
|
+
declare const BrowserbaseProxyGeolocationSchema: z$1.ZodObject<{
|
|
826
|
+
country: z$1.ZodString;
|
|
827
|
+
city: z$1.ZodOptional<z$1.ZodString>;
|
|
828
|
+
state: z$1.ZodOptional<z$1.ZodString>;
|
|
829
|
+
}, z$1.core.$strip>;
|
|
830
|
+
/** Browserbase managed proxy configuration */
|
|
831
|
+
declare const BrowserbaseProxyConfigSchema: z$1.ZodObject<{
|
|
832
|
+
type: z$1.ZodLiteral<"browserbase">;
|
|
833
|
+
domainPattern: z$1.ZodOptional<z$1.ZodString>;
|
|
834
|
+
geolocation: z$1.ZodOptional<z$1.ZodObject<{
|
|
835
|
+
country: z$1.ZodString;
|
|
836
|
+
city: z$1.ZodOptional<z$1.ZodString>;
|
|
837
|
+
state: z$1.ZodOptional<z$1.ZodString>;
|
|
838
|
+
}, z$1.core.$strip>>;
|
|
839
|
+
}, z$1.core.$strip>;
|
|
840
|
+
/** External proxy configuration */
|
|
841
|
+
declare const ExternalProxyConfigSchema: z$1.ZodObject<{
|
|
842
|
+
type: z$1.ZodLiteral<"external">;
|
|
843
|
+
server: z$1.ZodString;
|
|
844
|
+
domainPattern: z$1.ZodOptional<z$1.ZodString>;
|
|
845
|
+
username: z$1.ZodOptional<z$1.ZodString>;
|
|
846
|
+
password: z$1.ZodOptional<z$1.ZodString>;
|
|
847
|
+
}, z$1.core.$strip>;
|
|
848
|
+
/** Union of proxy configuration types */
|
|
849
|
+
declare const ProxyConfigSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
|
|
850
|
+
type: z$1.ZodLiteral<"browserbase">;
|
|
851
|
+
domainPattern: z$1.ZodOptional<z$1.ZodString>;
|
|
852
|
+
geolocation: z$1.ZodOptional<z$1.ZodObject<{
|
|
853
|
+
country: z$1.ZodString;
|
|
854
|
+
city: z$1.ZodOptional<z$1.ZodString>;
|
|
855
|
+
state: z$1.ZodOptional<z$1.ZodString>;
|
|
856
|
+
}, z$1.core.$strip>>;
|
|
857
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
858
|
+
type: z$1.ZodLiteral<"external">;
|
|
859
|
+
server: z$1.ZodString;
|
|
860
|
+
domainPattern: z$1.ZodOptional<z$1.ZodString>;
|
|
861
|
+
username: z$1.ZodOptional<z$1.ZodString>;
|
|
862
|
+
password: z$1.ZodOptional<z$1.ZodString>;
|
|
863
|
+
}, z$1.core.$strip>], "type">;
|
|
864
|
+
/** Browserbase session creation parameters */
|
|
865
|
+
declare const BrowserbaseSessionCreateParamsSchema: z$1.ZodObject<{
|
|
866
|
+
projectId: z$1.ZodOptional<z$1.ZodString>;
|
|
867
|
+
browserSettings: z$1.ZodOptional<z$1.ZodObject<{
|
|
868
|
+
advancedStealth: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
869
|
+
blockAds: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
870
|
+
context: z$1.ZodOptional<z$1.ZodObject<{
|
|
871
|
+
id: z$1.ZodString;
|
|
872
|
+
persist: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
873
|
+
}, z$1.core.$strip>>;
|
|
874
|
+
extensionId: z$1.ZodOptional<z$1.ZodString>;
|
|
875
|
+
fingerprint: z$1.ZodOptional<z$1.ZodObject<{
|
|
876
|
+
browsers: z$1.ZodOptional<z$1.ZodArray<z$1.ZodEnum<{
|
|
877
|
+
chrome: "chrome";
|
|
878
|
+
edge: "edge";
|
|
879
|
+
firefox: "firefox";
|
|
880
|
+
safari: "safari";
|
|
881
|
+
}>>>;
|
|
882
|
+
devices: z$1.ZodOptional<z$1.ZodArray<z$1.ZodEnum<{
|
|
883
|
+
desktop: "desktop";
|
|
884
|
+
mobile: "mobile";
|
|
885
|
+
}>>>;
|
|
886
|
+
httpVersion: z$1.ZodOptional<z$1.ZodEnum<{
|
|
887
|
+
1: "1";
|
|
888
|
+
2: "2";
|
|
889
|
+
}>>;
|
|
890
|
+
locales: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
891
|
+
operatingSystems: z$1.ZodOptional<z$1.ZodArray<z$1.ZodEnum<{
|
|
892
|
+
android: "android";
|
|
893
|
+
ios: "ios";
|
|
894
|
+
linux: "linux";
|
|
895
|
+
macos: "macos";
|
|
896
|
+
windows: "windows";
|
|
897
|
+
}>>>;
|
|
898
|
+
screen: z$1.ZodOptional<z$1.ZodObject<{
|
|
899
|
+
maxHeight: z$1.ZodOptional<z$1.ZodNumber>;
|
|
900
|
+
maxWidth: z$1.ZodOptional<z$1.ZodNumber>;
|
|
901
|
+
minHeight: z$1.ZodOptional<z$1.ZodNumber>;
|
|
902
|
+
minWidth: z$1.ZodOptional<z$1.ZodNumber>;
|
|
903
|
+
}, z$1.core.$strip>>;
|
|
904
|
+
}, z$1.core.$strip>>;
|
|
905
|
+
logSession: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
906
|
+
recordSession: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
907
|
+
solveCaptchas: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
908
|
+
viewport: z$1.ZodOptional<z$1.ZodObject<{
|
|
909
|
+
width: z$1.ZodOptional<z$1.ZodNumber>;
|
|
910
|
+
height: z$1.ZodOptional<z$1.ZodNumber>;
|
|
911
|
+
}, z$1.core.$strip>>;
|
|
912
|
+
}, z$1.core.$strip>>;
|
|
913
|
+
extensionId: z$1.ZodOptional<z$1.ZodString>;
|
|
914
|
+
keepAlive: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
915
|
+
proxies: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodBoolean, z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
|
|
916
|
+
type: z$1.ZodLiteral<"browserbase">;
|
|
917
|
+
domainPattern: z$1.ZodOptional<z$1.ZodString>;
|
|
918
|
+
geolocation: z$1.ZodOptional<z$1.ZodObject<{
|
|
919
|
+
country: z$1.ZodString;
|
|
920
|
+
city: z$1.ZodOptional<z$1.ZodString>;
|
|
921
|
+
state: z$1.ZodOptional<z$1.ZodString>;
|
|
922
|
+
}, z$1.core.$strip>>;
|
|
923
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
924
|
+
type: z$1.ZodLiteral<"external">;
|
|
925
|
+
server: z$1.ZodString;
|
|
926
|
+
domainPattern: z$1.ZodOptional<z$1.ZodString>;
|
|
927
|
+
username: z$1.ZodOptional<z$1.ZodString>;
|
|
928
|
+
password: z$1.ZodOptional<z$1.ZodString>;
|
|
929
|
+
}, z$1.core.$strip>], "type">>]>>;
|
|
930
|
+
region: z$1.ZodOptional<z$1.ZodEnum<{
|
|
931
|
+
"us-west-2": "us-west-2";
|
|
932
|
+
"us-east-1": "us-east-1";
|
|
933
|
+
"eu-central-1": "eu-central-1";
|
|
934
|
+
"ap-southeast-1": "ap-southeast-1";
|
|
935
|
+
}>>;
|
|
936
|
+
timeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
937
|
+
userMetadata: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
938
|
+
}, z$1.core.$strip>;
|
|
939
|
+
declare const SessionStartRequestSchema: z$1.ZodObject<{
|
|
940
|
+
modelName: z$1.ZodString;
|
|
941
|
+
domSettleTimeoutMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
942
|
+
verbose: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodLiteral<0>, z$1.ZodLiteral<1>, z$1.ZodLiteral<2>]>>;
|
|
943
|
+
systemPrompt: z$1.ZodOptional<z$1.ZodString>;
|
|
944
|
+
browserbaseSessionCreateParams: z$1.ZodOptional<z$1.ZodObject<{
|
|
945
|
+
projectId: z$1.ZodOptional<z$1.ZodString>;
|
|
946
|
+
browserSettings: z$1.ZodOptional<z$1.ZodObject<{
|
|
947
|
+
advancedStealth: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
948
|
+
blockAds: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
949
|
+
context: z$1.ZodOptional<z$1.ZodObject<{
|
|
950
|
+
id: z$1.ZodString;
|
|
951
|
+
persist: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
952
|
+
}, z$1.core.$strip>>;
|
|
953
|
+
extensionId: z$1.ZodOptional<z$1.ZodString>;
|
|
954
|
+
fingerprint: z$1.ZodOptional<z$1.ZodObject<{
|
|
955
|
+
browsers: z$1.ZodOptional<z$1.ZodArray<z$1.ZodEnum<{
|
|
956
|
+
chrome: "chrome";
|
|
957
|
+
edge: "edge";
|
|
958
|
+
firefox: "firefox";
|
|
959
|
+
safari: "safari";
|
|
960
|
+
}>>>;
|
|
961
|
+
devices: z$1.ZodOptional<z$1.ZodArray<z$1.ZodEnum<{
|
|
962
|
+
desktop: "desktop";
|
|
963
|
+
mobile: "mobile";
|
|
964
|
+
}>>>;
|
|
965
|
+
httpVersion: z$1.ZodOptional<z$1.ZodEnum<{
|
|
966
|
+
1: "1";
|
|
967
|
+
2: "2";
|
|
968
|
+
}>>;
|
|
969
|
+
locales: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
970
|
+
operatingSystems: z$1.ZodOptional<z$1.ZodArray<z$1.ZodEnum<{
|
|
971
|
+
android: "android";
|
|
972
|
+
ios: "ios";
|
|
973
|
+
linux: "linux";
|
|
974
|
+
macos: "macos";
|
|
975
|
+
windows: "windows";
|
|
976
|
+
}>>>;
|
|
977
|
+
screen: z$1.ZodOptional<z$1.ZodObject<{
|
|
978
|
+
maxHeight: z$1.ZodOptional<z$1.ZodNumber>;
|
|
979
|
+
maxWidth: z$1.ZodOptional<z$1.ZodNumber>;
|
|
980
|
+
minHeight: z$1.ZodOptional<z$1.ZodNumber>;
|
|
981
|
+
minWidth: z$1.ZodOptional<z$1.ZodNumber>;
|
|
982
|
+
}, z$1.core.$strip>>;
|
|
983
|
+
}, z$1.core.$strip>>;
|
|
984
|
+
logSession: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
985
|
+
recordSession: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
986
|
+
solveCaptchas: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
987
|
+
viewport: z$1.ZodOptional<z$1.ZodObject<{
|
|
988
|
+
width: z$1.ZodOptional<z$1.ZodNumber>;
|
|
989
|
+
height: z$1.ZodOptional<z$1.ZodNumber>;
|
|
990
|
+
}, z$1.core.$strip>>;
|
|
991
|
+
}, z$1.core.$strip>>;
|
|
992
|
+
extensionId: z$1.ZodOptional<z$1.ZodString>;
|
|
993
|
+
keepAlive: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
994
|
+
proxies: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodBoolean, z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
|
|
995
|
+
type: z$1.ZodLiteral<"browserbase">;
|
|
996
|
+
domainPattern: z$1.ZodOptional<z$1.ZodString>;
|
|
997
|
+
geolocation: z$1.ZodOptional<z$1.ZodObject<{
|
|
998
|
+
country: z$1.ZodString;
|
|
999
|
+
city: z$1.ZodOptional<z$1.ZodString>;
|
|
1000
|
+
state: z$1.ZodOptional<z$1.ZodString>;
|
|
1001
|
+
}, z$1.core.$strip>>;
|
|
1002
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
1003
|
+
type: z$1.ZodLiteral<"external">;
|
|
1004
|
+
server: z$1.ZodString;
|
|
1005
|
+
domainPattern: z$1.ZodOptional<z$1.ZodString>;
|
|
1006
|
+
username: z$1.ZodOptional<z$1.ZodString>;
|
|
1007
|
+
password: z$1.ZodOptional<z$1.ZodString>;
|
|
1008
|
+
}, z$1.core.$strip>], "type">>]>>;
|
|
1009
|
+
region: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1010
|
+
"us-west-2": "us-west-2";
|
|
1011
|
+
"us-east-1": "us-east-1";
|
|
1012
|
+
"eu-central-1": "eu-central-1";
|
|
1013
|
+
"ap-southeast-1": "ap-southeast-1";
|
|
1014
|
+
}>>;
|
|
1015
|
+
timeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1016
|
+
userMetadata: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
1017
|
+
}, z$1.core.$strip>>;
|
|
1018
|
+
browser: z$1.ZodOptional<z$1.ZodObject<{
|
|
1019
|
+
type: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1020
|
+
local: "local";
|
|
1021
|
+
browserbase: "browserbase";
|
|
1022
|
+
}>>;
|
|
1023
|
+
cdpUrl: z$1.ZodOptional<z$1.ZodString>;
|
|
1024
|
+
launchOptions: z$1.ZodOptional<z$1.ZodObject<{
|
|
1025
|
+
args: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
1026
|
+
executablePath: z$1.ZodOptional<z$1.ZodString>;
|
|
1027
|
+
userDataDir: z$1.ZodOptional<z$1.ZodString>;
|
|
1028
|
+
preserveUserDataDir: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1029
|
+
headless: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1030
|
+
devtools: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1031
|
+
chromiumSandbox: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1032
|
+
ignoreDefaultArgs: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodBoolean, z$1.ZodArray<z$1.ZodString>]>>;
|
|
1033
|
+
proxy: z$1.ZodOptional<z$1.ZodObject<{
|
|
1034
|
+
server: z$1.ZodString;
|
|
1035
|
+
bypass: z$1.ZodOptional<z$1.ZodString>;
|
|
1036
|
+
username: z$1.ZodOptional<z$1.ZodString>;
|
|
1037
|
+
password: z$1.ZodOptional<z$1.ZodString>;
|
|
1038
|
+
}, z$1.core.$strip>>;
|
|
1039
|
+
locale: z$1.ZodOptional<z$1.ZodString>;
|
|
1040
|
+
viewport: z$1.ZodOptional<z$1.ZodObject<{
|
|
1041
|
+
width: z$1.ZodNumber;
|
|
1042
|
+
height: z$1.ZodNumber;
|
|
1043
|
+
}, z$1.core.$strip>>;
|
|
1044
|
+
deviceScaleFactor: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1045
|
+
hasTouch: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1046
|
+
ignoreHTTPSErrors: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1047
|
+
cdpUrl: z$1.ZodOptional<z$1.ZodString>;
|
|
1048
|
+
connectTimeoutMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1049
|
+
downloadsPath: z$1.ZodOptional<z$1.ZodString>;
|
|
1050
|
+
acceptDownloads: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1051
|
+
}, z$1.core.$strict>>;
|
|
1052
|
+
}, z$1.core.$strip>>;
|
|
1053
|
+
selfHeal: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1054
|
+
browserbaseSessionID: z$1.ZodOptional<z$1.ZodString>;
|
|
1055
|
+
experimental: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1056
|
+
waitForCaptchaSolves: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1057
|
+
actTimeoutMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1058
|
+
}, z$1.core.$strip>;
|
|
1059
|
+
declare const SessionStartResultSchema: z$1.ZodObject<{
|
|
1060
|
+
sessionId: z$1.ZodString;
|
|
1061
|
+
cdpUrl: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1062
|
+
available: z$1.ZodBoolean;
|
|
1063
|
+
}, z$1.core.$strip>;
|
|
1064
|
+
declare const SessionStartResponseSchema: z$1.ZodObject<{
|
|
1065
|
+
success: z$1.ZodBoolean;
|
|
1066
|
+
data: z$1.ZodObject<{
|
|
1067
|
+
sessionId: z$1.ZodString;
|
|
1068
|
+
cdpUrl: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1069
|
+
available: z$1.ZodBoolean;
|
|
1070
|
+
}, z$1.core.$strip>;
|
|
1071
|
+
}, z$1.core.$strip>;
|
|
1072
|
+
/** Session end request - empty JSON object (required). */
|
|
1073
|
+
declare const SessionEndRequestSchema: z$1.ZodObject<{
|
|
1074
|
+
_forceBody: z$1.ZodOptional<z$1.ZodUndefined>;
|
|
1075
|
+
}, z$1.core.$strict>;
|
|
1076
|
+
declare const SessionEndResultSchema: z$1.ZodObject<{}, z$1.core.$strict>;
|
|
1077
|
+
/** Session end response - just success flag, no data wrapper */
|
|
1078
|
+
declare const SessionEndResponseSchema: z$1.ZodObject<{
|
|
1079
|
+
success: z$1.ZodBoolean;
|
|
1080
|
+
}, z$1.core.$strict>;
|
|
1081
|
+
declare const ActOptionsSchema: z$1.ZodOptional<z$1.ZodObject<{
|
|
1082
|
+
model: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
|
|
1083
|
+
provider: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1084
|
+
openai: "openai";
|
|
1085
|
+
anthropic: "anthropic";
|
|
1086
|
+
google: "google";
|
|
1087
|
+
microsoft: "microsoft";
|
|
1088
|
+
}>>;
|
|
1089
|
+
modelName: z$1.ZodString;
|
|
1090
|
+
apiKey: z$1.ZodOptional<z$1.ZodString>;
|
|
1091
|
+
baseURL: z$1.ZodOptional<z$1.ZodString>;
|
|
1092
|
+
}, z$1.core.$strip>]>>;
|
|
1093
|
+
variables: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
1094
|
+
timeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1095
|
+
}, z$1.core.$strip>>;
|
|
1096
|
+
declare const ActRequestSchema: z$1.ZodObject<{
|
|
1097
|
+
input: z$1.ZodUnion<[z$1.ZodString, z$1.ZodObject<{
|
|
1098
|
+
selector: z$1.ZodString;
|
|
1099
|
+
description: z$1.ZodString;
|
|
1100
|
+
backendNodeId: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1101
|
+
method: z$1.ZodOptional<z$1.ZodString>;
|
|
1102
|
+
arguments: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
1103
|
+
}, z$1.core.$strip>]>;
|
|
1104
|
+
options: z$1.ZodOptional<z$1.ZodObject<{
|
|
1105
|
+
model: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
|
|
1106
|
+
provider: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1107
|
+
openai: "openai";
|
|
1108
|
+
anthropic: "anthropic";
|
|
1109
|
+
google: "google";
|
|
1110
|
+
microsoft: "microsoft";
|
|
1111
|
+
}>>;
|
|
1112
|
+
modelName: z$1.ZodString;
|
|
1113
|
+
apiKey: z$1.ZodOptional<z$1.ZodString>;
|
|
1114
|
+
baseURL: z$1.ZodOptional<z$1.ZodString>;
|
|
1115
|
+
}, z$1.core.$strip>]>>;
|
|
1116
|
+
variables: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
1117
|
+
timeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1118
|
+
}, z$1.core.$strip>>;
|
|
1119
|
+
frameId: z$1.ZodOptional<z$1.ZodString>;
|
|
1120
|
+
streamResponse: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1121
|
+
}, z$1.core.$strip>;
|
|
1122
|
+
/** Inner act result data */
|
|
1123
|
+
declare const ActResultDataSchema: z$1.ZodObject<{
|
|
1124
|
+
success: z$1.ZodBoolean;
|
|
1125
|
+
message: z$1.ZodString;
|
|
1126
|
+
actionDescription: z$1.ZodString;
|
|
1127
|
+
actions: z$1.ZodArray<z$1.ZodObject<{
|
|
1128
|
+
selector: z$1.ZodString;
|
|
1129
|
+
description: z$1.ZodString;
|
|
1130
|
+
backendNodeId: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1131
|
+
method: z$1.ZodOptional<z$1.ZodString>;
|
|
1132
|
+
arguments: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
1133
|
+
}, z$1.core.$strip>>;
|
|
1134
|
+
}, z$1.core.$strip>;
|
|
1135
|
+
declare const ActResultSchema: z$1.ZodObject<{
|
|
1136
|
+
result: z$1.ZodObject<{
|
|
1137
|
+
success: z$1.ZodBoolean;
|
|
1138
|
+
message: z$1.ZodString;
|
|
1139
|
+
actionDescription: z$1.ZodString;
|
|
1140
|
+
actions: z$1.ZodArray<z$1.ZodObject<{
|
|
1141
|
+
selector: z$1.ZodString;
|
|
1142
|
+
description: z$1.ZodString;
|
|
1143
|
+
backendNodeId: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1144
|
+
method: z$1.ZodOptional<z$1.ZodString>;
|
|
1145
|
+
arguments: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
1146
|
+
}, z$1.core.$strip>>;
|
|
1147
|
+
}, z$1.core.$strip>;
|
|
1148
|
+
actionId: z$1.ZodOptional<z$1.ZodString>;
|
|
1149
|
+
}, z$1.core.$strip>;
|
|
1150
|
+
declare const ActResponseSchema: z$1.ZodObject<{
|
|
1151
|
+
success: z$1.ZodBoolean;
|
|
1152
|
+
data: z$1.ZodObject<{
|
|
1153
|
+
result: z$1.ZodObject<{
|
|
1154
|
+
success: z$1.ZodBoolean;
|
|
1155
|
+
message: z$1.ZodString;
|
|
1156
|
+
actionDescription: z$1.ZodString;
|
|
1157
|
+
actions: z$1.ZodArray<z$1.ZodObject<{
|
|
1158
|
+
selector: z$1.ZodString;
|
|
1159
|
+
description: z$1.ZodString;
|
|
1160
|
+
backendNodeId: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1161
|
+
method: z$1.ZodOptional<z$1.ZodString>;
|
|
1162
|
+
arguments: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
1163
|
+
}, z$1.core.$strip>>;
|
|
1164
|
+
}, z$1.core.$strip>;
|
|
1165
|
+
actionId: z$1.ZodOptional<z$1.ZodString>;
|
|
1166
|
+
}, z$1.core.$strip>;
|
|
1167
|
+
}, z$1.core.$strip>;
|
|
1168
|
+
declare const ExtractOptionsSchema: z$1.ZodOptional<z$1.ZodObject<{
|
|
1169
|
+
model: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
|
|
1170
|
+
provider: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1171
|
+
openai: "openai";
|
|
1172
|
+
anthropic: "anthropic";
|
|
1173
|
+
google: "google";
|
|
1174
|
+
microsoft: "microsoft";
|
|
1175
|
+
}>>;
|
|
1176
|
+
modelName: z$1.ZodString;
|
|
1177
|
+
apiKey: z$1.ZodOptional<z$1.ZodString>;
|
|
1178
|
+
baseURL: z$1.ZodOptional<z$1.ZodString>;
|
|
1179
|
+
}, z$1.core.$strip>]>>;
|
|
1180
|
+
timeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1181
|
+
selector: z$1.ZodOptional<z$1.ZodString>;
|
|
1182
|
+
}, z$1.core.$strip>>;
|
|
1183
|
+
declare const ExtractRequestSchema: z$1.ZodObject<{
|
|
1184
|
+
instruction: z$1.ZodOptional<z$1.ZodString>;
|
|
1185
|
+
schema: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
1186
|
+
options: z$1.ZodOptional<z$1.ZodObject<{
|
|
1187
|
+
model: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
|
|
1188
|
+
provider: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1189
|
+
openai: "openai";
|
|
1190
|
+
anthropic: "anthropic";
|
|
1191
|
+
google: "google";
|
|
1192
|
+
microsoft: "microsoft";
|
|
1193
|
+
}>>;
|
|
1194
|
+
modelName: z$1.ZodString;
|
|
1195
|
+
apiKey: z$1.ZodOptional<z$1.ZodString>;
|
|
1196
|
+
baseURL: z$1.ZodOptional<z$1.ZodString>;
|
|
1197
|
+
}, z$1.core.$strip>]>>;
|
|
1198
|
+
timeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1199
|
+
selector: z$1.ZodOptional<z$1.ZodString>;
|
|
1200
|
+
}, z$1.core.$strip>>;
|
|
1201
|
+
frameId: z$1.ZodOptional<z$1.ZodString>;
|
|
1202
|
+
streamResponse: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1203
|
+
}, z$1.core.$strip>;
|
|
1204
|
+
declare const ExtractResultSchema: z$1.ZodObject<{
|
|
1205
|
+
result: z$1.ZodUnknown;
|
|
1206
|
+
actionId: z$1.ZodOptional<z$1.ZodString>;
|
|
1207
|
+
}, z$1.core.$strip>;
|
|
1208
|
+
declare const ExtractResponseSchema: z$1.ZodObject<{
|
|
1209
|
+
success: z$1.ZodBoolean;
|
|
1210
|
+
data: z$1.ZodObject<{
|
|
1211
|
+
result: z$1.ZodUnknown;
|
|
1212
|
+
actionId: z$1.ZodOptional<z$1.ZodString>;
|
|
1213
|
+
}, z$1.core.$strip>;
|
|
1214
|
+
}, z$1.core.$strip>;
|
|
1215
|
+
declare const ObserveOptionsSchema: z$1.ZodOptional<z$1.ZodObject<{
|
|
1216
|
+
model: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
|
|
1217
|
+
provider: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1218
|
+
openai: "openai";
|
|
1219
|
+
anthropic: "anthropic";
|
|
1220
|
+
google: "google";
|
|
1221
|
+
microsoft: "microsoft";
|
|
1222
|
+
}>>;
|
|
1223
|
+
modelName: z$1.ZodString;
|
|
1224
|
+
apiKey: z$1.ZodOptional<z$1.ZodString>;
|
|
1225
|
+
baseURL: z$1.ZodOptional<z$1.ZodString>;
|
|
1226
|
+
}, z$1.core.$strip>]>>;
|
|
1227
|
+
timeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1228
|
+
selector: z$1.ZodOptional<z$1.ZodString>;
|
|
1229
|
+
}, z$1.core.$strip>>;
|
|
1230
|
+
declare const ObserveRequestSchema: z$1.ZodObject<{
|
|
1231
|
+
instruction: z$1.ZodOptional<z$1.ZodString>;
|
|
1232
|
+
options: z$1.ZodOptional<z$1.ZodObject<{
|
|
1233
|
+
model: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
|
|
1234
|
+
provider: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1235
|
+
openai: "openai";
|
|
1236
|
+
anthropic: "anthropic";
|
|
1237
|
+
google: "google";
|
|
1238
|
+
microsoft: "microsoft";
|
|
1239
|
+
}>>;
|
|
1240
|
+
modelName: z$1.ZodString;
|
|
1241
|
+
apiKey: z$1.ZodOptional<z$1.ZodString>;
|
|
1242
|
+
baseURL: z$1.ZodOptional<z$1.ZodString>;
|
|
1243
|
+
}, z$1.core.$strip>]>>;
|
|
1244
|
+
timeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1245
|
+
selector: z$1.ZodOptional<z$1.ZodString>;
|
|
1246
|
+
}, z$1.core.$strip>>;
|
|
1247
|
+
frameId: z$1.ZodOptional<z$1.ZodString>;
|
|
1248
|
+
streamResponse: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1249
|
+
}, z$1.core.$strip>;
|
|
1250
|
+
declare const ObserveResultSchema: z$1.ZodObject<{
|
|
1251
|
+
result: z$1.ZodArray<z$1.ZodObject<{
|
|
1252
|
+
selector: z$1.ZodString;
|
|
1253
|
+
description: z$1.ZodString;
|
|
1254
|
+
backendNodeId: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1255
|
+
method: z$1.ZodOptional<z$1.ZodString>;
|
|
1256
|
+
arguments: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
1257
|
+
}, z$1.core.$strip>>;
|
|
1258
|
+
actionId: z$1.ZodOptional<z$1.ZodString>;
|
|
1259
|
+
}, z$1.core.$strip>;
|
|
1260
|
+
declare const ObserveResponseSchema: z$1.ZodObject<{
|
|
1261
|
+
success: z$1.ZodBoolean;
|
|
1262
|
+
data: z$1.ZodObject<{
|
|
1263
|
+
result: z$1.ZodArray<z$1.ZodObject<{
|
|
1264
|
+
selector: z$1.ZodString;
|
|
1265
|
+
description: z$1.ZodString;
|
|
1266
|
+
backendNodeId: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1267
|
+
method: z$1.ZodOptional<z$1.ZodString>;
|
|
1268
|
+
arguments: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
1269
|
+
}, z$1.core.$strip>>;
|
|
1270
|
+
actionId: z$1.ZodOptional<z$1.ZodString>;
|
|
1271
|
+
}, z$1.core.$strip>;
|
|
1272
|
+
}, z$1.core.$strip>;
|
|
1273
|
+
declare const AgentConfigSchema: z$1.ZodObject<{
|
|
1274
|
+
provider: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1275
|
+
openai: "openai";
|
|
1276
|
+
anthropic: "anthropic";
|
|
1277
|
+
google: "google";
|
|
1278
|
+
microsoft: "microsoft";
|
|
1279
|
+
}>>;
|
|
1280
|
+
model: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
|
|
1281
|
+
provider: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1282
|
+
openai: "openai";
|
|
1283
|
+
anthropic: "anthropic";
|
|
1284
|
+
google: "google";
|
|
1285
|
+
microsoft: "microsoft";
|
|
1286
|
+
}>>;
|
|
1287
|
+
modelName: z$1.ZodString;
|
|
1288
|
+
apiKey: z$1.ZodOptional<z$1.ZodString>;
|
|
1289
|
+
baseURL: z$1.ZodOptional<z$1.ZodString>;
|
|
1290
|
+
}, z$1.core.$strip>]>>;
|
|
1291
|
+
systemPrompt: z$1.ZodOptional<z$1.ZodString>;
|
|
1292
|
+
cua: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1293
|
+
}, z$1.core.$strip>;
|
|
1294
|
+
/** Action taken by the agent during execution */
|
|
1295
|
+
declare const AgentActionSchema: z$1.ZodObject<{
|
|
1296
|
+
type: z$1.ZodString;
|
|
1297
|
+
reasoning: z$1.ZodOptional<z$1.ZodString>;
|
|
1298
|
+
taskCompleted: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1299
|
+
action: z$1.ZodOptional<z$1.ZodString>;
|
|
1300
|
+
timeMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1301
|
+
pageText: z$1.ZodOptional<z$1.ZodString>;
|
|
1302
|
+
pageUrl: z$1.ZodOptional<z$1.ZodString>;
|
|
1303
|
+
instruction: z$1.ZodOptional<z$1.ZodString>;
|
|
1304
|
+
}, z$1.core.$loose>;
|
|
1305
|
+
/** Token usage statistics for agent execution */
|
|
1306
|
+
declare const AgentUsageSchema: z$1.ZodObject<{
|
|
1307
|
+
input_tokens: z$1.ZodNumber;
|
|
1308
|
+
output_tokens: z$1.ZodNumber;
|
|
1309
|
+
reasoning_tokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1310
|
+
cached_input_tokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1311
|
+
inference_time_ms: z$1.ZodNumber;
|
|
1312
|
+
}, z$1.core.$strip>;
|
|
1313
|
+
/** Result data from agent execution */
|
|
1314
|
+
declare const AgentResultDataSchema: z$1.ZodObject<{
|
|
1315
|
+
success: z$1.ZodBoolean;
|
|
1316
|
+
message: z$1.ZodString;
|
|
1317
|
+
actions: z$1.ZodArray<z$1.ZodObject<{
|
|
1318
|
+
type: z$1.ZodString;
|
|
1319
|
+
reasoning: z$1.ZodOptional<z$1.ZodString>;
|
|
1320
|
+
taskCompleted: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1321
|
+
action: z$1.ZodOptional<z$1.ZodString>;
|
|
1322
|
+
timeMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1323
|
+
pageText: z$1.ZodOptional<z$1.ZodString>;
|
|
1324
|
+
pageUrl: z$1.ZodOptional<z$1.ZodString>;
|
|
1325
|
+
instruction: z$1.ZodOptional<z$1.ZodString>;
|
|
1326
|
+
}, z$1.core.$loose>>;
|
|
1327
|
+
completed: z$1.ZodBoolean;
|
|
1328
|
+
metadata: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
1329
|
+
usage: z$1.ZodOptional<z$1.ZodObject<{
|
|
1330
|
+
input_tokens: z$1.ZodNumber;
|
|
1331
|
+
output_tokens: z$1.ZodNumber;
|
|
1332
|
+
reasoning_tokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1333
|
+
cached_input_tokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1334
|
+
inference_time_ms: z$1.ZodNumber;
|
|
1335
|
+
}, z$1.core.$strip>>;
|
|
1336
|
+
}, z$1.core.$strip>;
|
|
1337
|
+
declare const AgentExecuteOptionsSchema: z$1.ZodObject<{
|
|
1338
|
+
instruction: z$1.ZodString;
|
|
1339
|
+
maxSteps: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1340
|
+
highlightCursor: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1341
|
+
}, z$1.core.$strip>;
|
|
1342
|
+
declare const AgentExecuteRequestSchema: z$1.ZodObject<{
|
|
1343
|
+
agentConfig: z$1.ZodObject<{
|
|
1344
|
+
provider: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1345
|
+
openai: "openai";
|
|
1346
|
+
anthropic: "anthropic";
|
|
1347
|
+
google: "google";
|
|
1348
|
+
microsoft: "microsoft";
|
|
1349
|
+
}>>;
|
|
1350
|
+
model: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
|
|
1351
|
+
provider: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1352
|
+
openai: "openai";
|
|
1353
|
+
anthropic: "anthropic";
|
|
1354
|
+
google: "google";
|
|
1355
|
+
microsoft: "microsoft";
|
|
1356
|
+
}>>;
|
|
1357
|
+
modelName: z$1.ZodString;
|
|
1358
|
+
apiKey: z$1.ZodOptional<z$1.ZodString>;
|
|
1359
|
+
baseURL: z$1.ZodOptional<z$1.ZodString>;
|
|
1360
|
+
}, z$1.core.$strip>]>>;
|
|
1361
|
+
systemPrompt: z$1.ZodOptional<z$1.ZodString>;
|
|
1362
|
+
cua: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1363
|
+
}, z$1.core.$strip>;
|
|
1364
|
+
executeOptions: z$1.ZodObject<{
|
|
1365
|
+
instruction: z$1.ZodString;
|
|
1366
|
+
maxSteps: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1367
|
+
highlightCursor: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1368
|
+
}, z$1.core.$strip>;
|
|
1369
|
+
frameId: z$1.ZodOptional<z$1.ZodString>;
|
|
1370
|
+
streamResponse: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1371
|
+
}, z$1.core.$strip>;
|
|
1372
|
+
declare const AgentExecuteResultSchema: z$1.ZodObject<{
|
|
1373
|
+
result: z$1.ZodObject<{
|
|
1374
|
+
success: z$1.ZodBoolean;
|
|
1375
|
+
message: z$1.ZodString;
|
|
1376
|
+
actions: z$1.ZodArray<z$1.ZodObject<{
|
|
1377
|
+
type: z$1.ZodString;
|
|
1378
|
+
reasoning: z$1.ZodOptional<z$1.ZodString>;
|
|
1379
|
+
taskCompleted: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1380
|
+
action: z$1.ZodOptional<z$1.ZodString>;
|
|
1381
|
+
timeMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1382
|
+
pageText: z$1.ZodOptional<z$1.ZodString>;
|
|
1383
|
+
pageUrl: z$1.ZodOptional<z$1.ZodString>;
|
|
1384
|
+
instruction: z$1.ZodOptional<z$1.ZodString>;
|
|
1385
|
+
}, z$1.core.$loose>>;
|
|
1386
|
+
completed: z$1.ZodBoolean;
|
|
1387
|
+
metadata: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
1388
|
+
usage: z$1.ZodOptional<z$1.ZodObject<{
|
|
1389
|
+
input_tokens: z$1.ZodNumber;
|
|
1390
|
+
output_tokens: z$1.ZodNumber;
|
|
1391
|
+
reasoning_tokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1392
|
+
cached_input_tokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1393
|
+
inference_time_ms: z$1.ZodNumber;
|
|
1394
|
+
}, z$1.core.$strip>>;
|
|
1395
|
+
}, z$1.core.$strip>;
|
|
1396
|
+
}, z$1.core.$strip>;
|
|
1397
|
+
declare const AgentExecuteResponseSchema: z$1.ZodObject<{
|
|
1398
|
+
success: z$1.ZodBoolean;
|
|
1399
|
+
data: z$1.ZodObject<{
|
|
1400
|
+
result: z$1.ZodObject<{
|
|
1401
|
+
success: z$1.ZodBoolean;
|
|
1402
|
+
message: z$1.ZodString;
|
|
1403
|
+
actions: z$1.ZodArray<z$1.ZodObject<{
|
|
1404
|
+
type: z$1.ZodString;
|
|
1405
|
+
reasoning: z$1.ZodOptional<z$1.ZodString>;
|
|
1406
|
+
taskCompleted: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1407
|
+
action: z$1.ZodOptional<z$1.ZodString>;
|
|
1408
|
+
timeMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1409
|
+
pageText: z$1.ZodOptional<z$1.ZodString>;
|
|
1410
|
+
pageUrl: z$1.ZodOptional<z$1.ZodString>;
|
|
1411
|
+
instruction: z$1.ZodOptional<z$1.ZodString>;
|
|
1412
|
+
}, z$1.core.$loose>>;
|
|
1413
|
+
completed: z$1.ZodBoolean;
|
|
1414
|
+
metadata: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
1415
|
+
usage: z$1.ZodOptional<z$1.ZodObject<{
|
|
1416
|
+
input_tokens: z$1.ZodNumber;
|
|
1417
|
+
output_tokens: z$1.ZodNumber;
|
|
1418
|
+
reasoning_tokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1419
|
+
cached_input_tokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1420
|
+
inference_time_ms: z$1.ZodNumber;
|
|
1421
|
+
}, z$1.core.$strip>>;
|
|
1422
|
+
}, z$1.core.$strip>;
|
|
1423
|
+
}, z$1.core.$strip>;
|
|
1424
|
+
}, z$1.core.$strip>;
|
|
1425
|
+
declare const NavigateOptionsSchema: z$1.ZodOptional<z$1.ZodObject<{
|
|
1426
|
+
referer: z$1.ZodOptional<z$1.ZodString>;
|
|
1427
|
+
timeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1428
|
+
waitUntil: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1429
|
+
load: "load";
|
|
1430
|
+
domcontentloaded: "domcontentloaded";
|
|
1431
|
+
networkidle: "networkidle";
|
|
1432
|
+
}>>;
|
|
1433
|
+
}, z$1.core.$strip>>;
|
|
1434
|
+
declare const NavigateRequestSchema: z$1.ZodObject<{
|
|
1435
|
+
url: z$1.ZodString;
|
|
1436
|
+
options: z$1.ZodOptional<z$1.ZodObject<{
|
|
1437
|
+
referer: z$1.ZodOptional<z$1.ZodString>;
|
|
1438
|
+
timeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1439
|
+
waitUntil: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1440
|
+
load: "load";
|
|
1441
|
+
domcontentloaded: "domcontentloaded";
|
|
1442
|
+
networkidle: "networkidle";
|
|
1443
|
+
}>>;
|
|
1444
|
+
}, z$1.core.$strip>>;
|
|
1445
|
+
frameId: z$1.ZodOptional<z$1.ZodString>;
|
|
1446
|
+
streamResponse: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1447
|
+
}, z$1.core.$strip>;
|
|
1448
|
+
declare const NavigateResultSchema: z$1.ZodObject<{
|
|
1449
|
+
result: z$1.ZodNullable<z$1.ZodUnknown>;
|
|
1450
|
+
actionId: z$1.ZodOptional<z$1.ZodString>;
|
|
1451
|
+
}, z$1.core.$strip>;
|
|
1452
|
+
declare const NavigateResponseSchema: z$1.ZodObject<{
|
|
1453
|
+
success: z$1.ZodBoolean;
|
|
1454
|
+
data: z$1.ZodObject<{
|
|
1455
|
+
result: z$1.ZodNullable<z$1.ZodUnknown>;
|
|
1456
|
+
actionId: z$1.ZodOptional<z$1.ZodString>;
|
|
1457
|
+
}, z$1.core.$strip>;
|
|
1458
|
+
}, z$1.core.$strip>;
|
|
1459
|
+
/** Token usage for a single action */
|
|
1460
|
+
declare const TokenUsageSchema: z$1.ZodObject<{
|
|
1461
|
+
inputTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1462
|
+
outputTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1463
|
+
reasoningTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1464
|
+
cachedInputTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1465
|
+
timeMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1466
|
+
}, z$1.core.$strip>;
|
|
1467
|
+
/** Action entry in replay metrics */
|
|
1468
|
+
declare const ReplayActionSchema: z$1.ZodObject<{
|
|
1469
|
+
method: z$1.ZodOptional<z$1.ZodString>;
|
|
1470
|
+
tokenUsage: z$1.ZodOptional<z$1.ZodObject<{
|
|
1471
|
+
inputTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1472
|
+
outputTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1473
|
+
reasoningTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1474
|
+
cachedInputTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1475
|
+
timeMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1476
|
+
}, z$1.core.$strip>>;
|
|
1477
|
+
}, z$1.core.$strip>;
|
|
1478
|
+
/** Page entry in replay metrics */
|
|
1479
|
+
declare const ReplayPageSchema: z$1.ZodObject<{
|
|
1480
|
+
actions: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
|
|
1481
|
+
method: z$1.ZodOptional<z$1.ZodString>;
|
|
1482
|
+
tokenUsage: z$1.ZodOptional<z$1.ZodObject<{
|
|
1483
|
+
inputTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1484
|
+
outputTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1485
|
+
reasoningTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1486
|
+
cachedInputTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1487
|
+
timeMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1488
|
+
}, z$1.core.$strip>>;
|
|
1489
|
+
}, z$1.core.$strip>>>;
|
|
1490
|
+
}, z$1.core.$strip>;
|
|
1491
|
+
/** Inner result data for replay */
|
|
1492
|
+
declare const ReplayResultSchema: z$1.ZodObject<{
|
|
1493
|
+
pages: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
|
|
1494
|
+
actions: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
|
|
1495
|
+
method: z$1.ZodOptional<z$1.ZodString>;
|
|
1496
|
+
tokenUsage: z$1.ZodOptional<z$1.ZodObject<{
|
|
1497
|
+
inputTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1498
|
+
outputTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1499
|
+
reasoningTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1500
|
+
cachedInputTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1501
|
+
timeMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1502
|
+
}, z$1.core.$strip>>;
|
|
1503
|
+
}, z$1.core.$strip>>>;
|
|
1504
|
+
}, z$1.core.$strip>>>;
|
|
1505
|
+
}, z$1.core.$strip>;
|
|
1506
|
+
declare const ReplayResponseSchema: z$1.ZodObject<{
|
|
1507
|
+
success: z$1.ZodBoolean;
|
|
1508
|
+
data: z$1.ZodObject<{
|
|
1509
|
+
pages: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
|
|
1510
|
+
actions: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
|
|
1511
|
+
method: z$1.ZodOptional<z$1.ZodString>;
|
|
1512
|
+
tokenUsage: z$1.ZodOptional<z$1.ZodObject<{
|
|
1513
|
+
inputTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1514
|
+
outputTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1515
|
+
reasoningTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1516
|
+
cachedInputTokens: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1517
|
+
timeMs: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1518
|
+
}, z$1.core.$strip>>;
|
|
1519
|
+
}, z$1.core.$strip>>>;
|
|
1520
|
+
}, z$1.core.$strip>>>;
|
|
1521
|
+
}, z$1.core.$strip>;
|
|
1522
|
+
}, z$1.core.$strip>;
|
|
1523
|
+
/** Status values for SSE stream events */
|
|
1524
|
+
declare const StreamEventStatusSchema: z$1.ZodEnum<{
|
|
1525
|
+
error: "error";
|
|
1526
|
+
starting: "starting";
|
|
1527
|
+
connected: "connected";
|
|
1528
|
+
running: "running";
|
|
1529
|
+
finished: "finished";
|
|
1530
|
+
}>;
|
|
1531
|
+
/** Type discriminator for SSE stream events */
|
|
1532
|
+
declare const StreamEventTypeSchema: z$1.ZodEnum<{
|
|
1533
|
+
system: "system";
|
|
1534
|
+
log: "log";
|
|
1535
|
+
}>;
|
|
1536
|
+
/** Data payload for system stream events */
|
|
1537
|
+
declare const StreamEventSystemDataSchema: z$1.ZodObject<{
|
|
1538
|
+
status: z$1.ZodEnum<{
|
|
1539
|
+
error: "error";
|
|
1540
|
+
starting: "starting";
|
|
1541
|
+
connected: "connected";
|
|
1542
|
+
running: "running";
|
|
1543
|
+
finished: "finished";
|
|
1544
|
+
}>;
|
|
1545
|
+
result: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
1546
|
+
error: z$1.ZodOptional<z$1.ZodString>;
|
|
1547
|
+
}, z$1.core.$strip>;
|
|
1548
|
+
/** Data payload for log stream events */
|
|
1549
|
+
declare const StreamEventLogDataSchema: z$1.ZodObject<{
|
|
1550
|
+
status: z$1.ZodLiteral<"running">;
|
|
1551
|
+
message: z$1.ZodString;
|
|
1552
|
+
}, z$1.core.$strip>;
|
|
1553
|
+
/**
|
|
1554
|
+
* SSE stream event sent during streaming responses.
|
|
1555
|
+
*
|
|
1556
|
+
* IMPORTANT: Key ordering matters for Stainless SDK generation.
|
|
1557
|
+
* The `data` field MUST be serialized first, with `status` as the first key within it.
|
|
1558
|
+
* This allows Stainless to use `data_starts_with: '{"data":{"status":"finished"'` for event handling.
|
|
1559
|
+
*
|
|
1560
|
+
* Expected serialization order: {"data":{"status":...},"type":...,"id":...}
|
|
1561
|
+
*/
|
|
1562
|
+
declare const StreamEventSchema: z$1.ZodObject<{
|
|
1563
|
+
data: z$1.ZodUnion<readonly [z$1.ZodObject<{
|
|
1564
|
+
status: z$1.ZodEnum<{
|
|
1565
|
+
error: "error";
|
|
1566
|
+
starting: "starting";
|
|
1567
|
+
connected: "connected";
|
|
1568
|
+
running: "running";
|
|
1569
|
+
finished: "finished";
|
|
1570
|
+
}>;
|
|
1571
|
+
result: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
1572
|
+
error: z$1.ZodOptional<z$1.ZodString>;
|
|
1573
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
1574
|
+
status: z$1.ZodLiteral<"running">;
|
|
1575
|
+
message: z$1.ZodString;
|
|
1576
|
+
}, z$1.core.$strip>]>;
|
|
1577
|
+
type: z$1.ZodEnum<{
|
|
1578
|
+
system: "system";
|
|
1579
|
+
log: "log";
|
|
1580
|
+
}>;
|
|
1581
|
+
id: z$1.ZodString;
|
|
1582
|
+
}, z$1.core.$strip>;
|
|
1583
|
+
/** OpenAPI security schemes for authentication */
|
|
1584
|
+
declare const openApiSecuritySchemes: {
|
|
1585
|
+
readonly BrowserbaseApiKey: {
|
|
1586
|
+
readonly type: "apiKey";
|
|
1587
|
+
readonly in: "header";
|
|
1588
|
+
readonly name: "x-bb-api-key";
|
|
1589
|
+
readonly description: "Browserbase API key for authentication";
|
|
1590
|
+
};
|
|
1591
|
+
readonly BrowserbaseProjectId: {
|
|
1592
|
+
readonly type: "apiKey";
|
|
1593
|
+
readonly in: "header";
|
|
1594
|
+
readonly name: "x-bb-project-id";
|
|
1595
|
+
readonly description: "Browserbase project ID";
|
|
1596
|
+
};
|
|
1597
|
+
readonly ModelApiKey: {
|
|
1598
|
+
readonly type: "apiKey";
|
|
1599
|
+
readonly in: "header";
|
|
1600
|
+
readonly name: "x-model-api-key";
|
|
1601
|
+
readonly description: "API key for the AI model provider (OpenAI, Anthropic, etc.)";
|
|
1602
|
+
};
|
|
1603
|
+
};
|
|
1604
|
+
/** OpenAPI links for session operations (used in SessionStart response) */
|
|
1605
|
+
declare const openApiLinks: {
|
|
1606
|
+
readonly SessionAct: {
|
|
1607
|
+
readonly operationId: "SessionAct";
|
|
1608
|
+
readonly parameters: {
|
|
1609
|
+
readonly id: "$response.body#/data/sessionId";
|
|
1610
|
+
};
|
|
1611
|
+
readonly description: "Perform an action on the session";
|
|
1612
|
+
};
|
|
1613
|
+
readonly SessionExtract: {
|
|
1614
|
+
readonly operationId: "SessionExtract";
|
|
1615
|
+
readonly parameters: {
|
|
1616
|
+
readonly id: "$response.body#/data/sessionId";
|
|
1617
|
+
};
|
|
1618
|
+
readonly description: "Extract data from the session";
|
|
1619
|
+
};
|
|
1620
|
+
readonly SessionObserve: {
|
|
1621
|
+
readonly operationId: "SessionObserve";
|
|
1622
|
+
readonly parameters: {
|
|
1623
|
+
readonly id: "$response.body#/data/sessionId";
|
|
1624
|
+
};
|
|
1625
|
+
readonly description: "Observe available actions on the session";
|
|
1626
|
+
};
|
|
1627
|
+
readonly SessionNavigate: {
|
|
1628
|
+
readonly operationId: "SessionNavigate";
|
|
1629
|
+
readonly parameters: {
|
|
1630
|
+
readonly id: "$response.body#/data/sessionId";
|
|
1631
|
+
};
|
|
1632
|
+
readonly description: "Navigate to a URL in the session";
|
|
1633
|
+
};
|
|
1634
|
+
readonly SessionAgentExecute: {
|
|
1635
|
+
readonly operationId: "SessionAgentExecute";
|
|
1636
|
+
readonly parameters: {
|
|
1637
|
+
readonly id: "$response.body#/data/sessionId";
|
|
1638
|
+
};
|
|
1639
|
+
readonly description: "Execute an agent on the session";
|
|
1640
|
+
};
|
|
1641
|
+
readonly SessionReplay: {
|
|
1642
|
+
readonly operationId: "SessionReplay";
|
|
1643
|
+
readonly parameters: {
|
|
1644
|
+
readonly id: "$response.body#/data/sessionId";
|
|
1645
|
+
};
|
|
1646
|
+
readonly description: "Replay session metrics";
|
|
1647
|
+
};
|
|
1648
|
+
readonly SessionEnd: {
|
|
1649
|
+
readonly operationId: "SessionEnd";
|
|
1650
|
+
readonly parameters: {
|
|
1651
|
+
readonly id: "$response.body#/data/sessionId";
|
|
1652
|
+
};
|
|
1653
|
+
readonly description: "End the session and release resources";
|
|
1654
|
+
};
|
|
1655
|
+
};
|
|
1656
|
+
/** OpenAPI operation metadata for each endpoint */
|
|
1657
|
+
declare const Operations: {
|
|
1658
|
+
readonly SessionStart: {
|
|
1659
|
+
readonly operationId: "SessionStart";
|
|
1660
|
+
readonly summary: "Start a new browser session";
|
|
1661
|
+
readonly description: "Creates a new browser session with the specified configuration. Returns a session ID used for all subsequent operations.";
|
|
1662
|
+
};
|
|
1663
|
+
readonly SessionEnd: {
|
|
1664
|
+
readonly operationId: "SessionEnd";
|
|
1665
|
+
readonly summary: "End a browser session";
|
|
1666
|
+
readonly description: "Terminates the browser session and releases all associated resources.";
|
|
1667
|
+
};
|
|
1668
|
+
readonly SessionAct: {
|
|
1669
|
+
readonly operationId: "SessionAct";
|
|
1670
|
+
readonly summary: "Perform an action";
|
|
1671
|
+
readonly description: "Executes a browser action using natural language instructions or a predefined Action object.";
|
|
1672
|
+
};
|
|
1673
|
+
readonly SessionExtract: {
|
|
1674
|
+
readonly operationId: "SessionExtract";
|
|
1675
|
+
readonly summary: "Extract data from the page";
|
|
1676
|
+
readonly description: "Extracts structured data from the current page using AI-powered analysis.";
|
|
1677
|
+
};
|
|
1678
|
+
readonly SessionObserve: {
|
|
1679
|
+
readonly operationId: "SessionObserve";
|
|
1680
|
+
readonly summary: "Observe available actions";
|
|
1681
|
+
readonly description: "Identifies and returns available actions on the current page that match the given instruction.";
|
|
1682
|
+
};
|
|
1683
|
+
readonly SessionNavigate: {
|
|
1684
|
+
readonly operationId: "SessionNavigate";
|
|
1685
|
+
readonly summary: "Navigate to a URL";
|
|
1686
|
+
readonly description: "Navigates the browser to the specified URL.";
|
|
1687
|
+
};
|
|
1688
|
+
readonly SessionAgentExecute: {
|
|
1689
|
+
readonly operationId: "SessionAgentExecute";
|
|
1690
|
+
readonly summary: "Execute an AI agent";
|
|
1691
|
+
readonly description: "Runs an autonomous AI agent that can perform complex multi-step browser tasks.";
|
|
1692
|
+
};
|
|
1693
|
+
readonly SessionReplay: {
|
|
1694
|
+
readonly operationId: "SessionReplay";
|
|
1695
|
+
readonly summary: "Replay session metrics";
|
|
1696
|
+
readonly description: "Retrieves replay metrics for a session.";
|
|
1697
|
+
};
|
|
1698
|
+
};
|
|
1699
|
+
type Action$1 = z$1.infer<typeof ActionSchema>;
|
|
1700
|
+
type ModelConfig = z$1.infer<typeof ModelConfigSchema>;
|
|
1701
|
+
type BrowserConfig = z$1.infer<typeof BrowserConfigSchema>;
|
|
1702
|
+
type SessionIdParams = z$1.infer<typeof SessionIdParamsSchema>;
|
|
1703
|
+
type SessionHeaders = z$1.infer<typeof SessionHeadersSchema>;
|
|
1704
|
+
type BrowserbaseViewport = z$1.infer<typeof BrowserbaseViewportSchema>;
|
|
1705
|
+
type BrowserbaseFingerprintScreen = z$1.infer<typeof BrowserbaseFingerprintScreenSchema>;
|
|
1706
|
+
type BrowserbaseFingerprint = z$1.infer<typeof BrowserbaseFingerprintSchema>;
|
|
1707
|
+
type BrowserbaseContext = z$1.infer<typeof BrowserbaseContextSchema>;
|
|
1708
|
+
type BrowserbaseBrowserSettings = z$1.infer<typeof BrowserbaseBrowserSettingsSchema>;
|
|
1709
|
+
type BrowserbaseProxyGeolocation = z$1.infer<typeof BrowserbaseProxyGeolocationSchema>;
|
|
1710
|
+
type BrowserbaseProxyConfig = z$1.infer<typeof BrowserbaseProxyConfigSchema>;
|
|
1711
|
+
type ExternalProxyConfig = z$1.infer<typeof ExternalProxyConfigSchema>;
|
|
1712
|
+
type BrowserbaseSessionCreateParams = z$1.infer<typeof BrowserbaseSessionCreateParamsSchema>;
|
|
1713
|
+
type SessionStartRequest = z$1.infer<typeof SessionStartRequestSchema>;
|
|
1714
|
+
type SessionStartResult = z$1.infer<typeof SessionStartResultSchema>;
|
|
1715
|
+
type SessionStartResponse = z$1.infer<typeof SessionStartResponseSchema>;
|
|
1716
|
+
type SessionEndResult = z$1.infer<typeof SessionEndResultSchema>;
|
|
1717
|
+
type SessionEndResponse = z$1.infer<typeof SessionEndResponseSchema>;
|
|
1718
|
+
type ActRequest = z$1.infer<typeof ActRequestSchema>;
|
|
1719
|
+
type ActResultData = z$1.infer<typeof ActResultDataSchema>;
|
|
1720
|
+
type ActResult$1 = z$1.infer<typeof ActResultSchema>;
|
|
1721
|
+
type ActResponse = z$1.infer<typeof ActResponseSchema>;
|
|
1722
|
+
type ExtractRequest = z$1.infer<typeof ExtractRequestSchema>;
|
|
1723
|
+
type ExtractResult$1 = z$1.infer<typeof ExtractResultSchema>;
|
|
1724
|
+
type ExtractResponse = z$1.infer<typeof ExtractResponseSchema>;
|
|
1725
|
+
type ObserveRequest = z$1.infer<typeof ObserveRequestSchema>;
|
|
1726
|
+
type ObserveResult = z$1.infer<typeof ObserveResultSchema>;
|
|
1727
|
+
type ObserveResponse = z$1.infer<typeof ObserveResponseSchema>;
|
|
1728
|
+
type AgentAction$1 = z$1.infer<typeof AgentActionSchema>;
|
|
1729
|
+
type AgentUsage = z$1.infer<typeof AgentUsageSchema>;
|
|
1730
|
+
type AgentResultData = z$1.infer<typeof AgentResultDataSchema>;
|
|
1731
|
+
type AgentExecuteRequest = z$1.infer<typeof AgentExecuteRequestSchema>;
|
|
1732
|
+
type AgentExecuteResult = z$1.infer<typeof AgentExecuteResultSchema>;
|
|
1733
|
+
type AgentExecuteResponse = z$1.infer<typeof AgentExecuteResponseSchema>;
|
|
1734
|
+
type NavigateRequest = z$1.infer<typeof NavigateRequestSchema>;
|
|
1735
|
+
type NavigateResult = z$1.infer<typeof NavigateResultSchema>;
|
|
1736
|
+
type NavigateResponse = z$1.infer<typeof NavigateResponseSchema>;
|
|
1737
|
+
type TokenUsage = z$1.infer<typeof TokenUsageSchema>;
|
|
1738
|
+
type ReplayAction = z$1.infer<typeof ReplayActionSchema>;
|
|
1739
|
+
type ReplayPage = z$1.infer<typeof ReplayPageSchema>;
|
|
1740
|
+
type ReplayResult = z$1.infer<typeof ReplayResultSchema>;
|
|
1741
|
+
type ReplayResponse = z$1.infer<typeof ReplayResponseSchema>;
|
|
1742
|
+
type StreamEventStatus = z$1.infer<typeof StreamEventStatusSchema>;
|
|
1743
|
+
type StreamEventType = z$1.infer<typeof StreamEventTypeSchema>;
|
|
1744
|
+
type StreamEventSystemData = z$1.infer<typeof StreamEventSystemDataSchema>;
|
|
1745
|
+
type StreamEventLogData = z$1.infer<typeof StreamEventLogDataSchema>;
|
|
1746
|
+
type StreamEvent = z$1.infer<typeof StreamEventSchema>;
|
|
1747
|
+
|
|
1748
|
+
declare const api_ActOptionsSchema: typeof ActOptionsSchema;
|
|
1749
|
+
type api_ActRequest = ActRequest;
|
|
1750
|
+
declare const api_ActRequestSchema: typeof ActRequestSchema;
|
|
1751
|
+
type api_ActResponse = ActResponse;
|
|
1752
|
+
declare const api_ActResponseSchema: typeof ActResponseSchema;
|
|
1753
|
+
type api_ActResultData = ActResultData;
|
|
1754
|
+
declare const api_ActResultDataSchema: typeof ActResultDataSchema;
|
|
1755
|
+
declare const api_ActResultSchema: typeof ActResultSchema;
|
|
1756
|
+
declare const api_ActionSchema: typeof ActionSchema;
|
|
1757
|
+
declare const api_AgentActionSchema: typeof AgentActionSchema;
|
|
1758
|
+
declare const api_AgentConfigSchema: typeof AgentConfigSchema;
|
|
1759
|
+
declare const api_AgentExecuteOptionsSchema: typeof AgentExecuteOptionsSchema;
|
|
1760
|
+
type api_AgentExecuteRequest = AgentExecuteRequest;
|
|
1761
|
+
declare const api_AgentExecuteRequestSchema: typeof AgentExecuteRequestSchema;
|
|
1762
|
+
type api_AgentExecuteResponse = AgentExecuteResponse;
|
|
1763
|
+
declare const api_AgentExecuteResponseSchema: typeof AgentExecuteResponseSchema;
|
|
1764
|
+
type api_AgentExecuteResult = AgentExecuteResult;
|
|
1765
|
+
declare const api_AgentExecuteResultSchema: typeof AgentExecuteResultSchema;
|
|
1766
|
+
type api_AgentResultData = AgentResultData;
|
|
1767
|
+
declare const api_AgentResultDataSchema: typeof AgentResultDataSchema;
|
|
1768
|
+
type api_AgentUsage = AgentUsage;
|
|
1769
|
+
declare const api_AgentUsageSchema: typeof AgentUsageSchema;
|
|
1770
|
+
type api_BrowserConfig = BrowserConfig;
|
|
1771
|
+
declare const api_BrowserConfigSchema: typeof BrowserConfigSchema;
|
|
1772
|
+
type api_BrowserbaseBrowserSettings = BrowserbaseBrowserSettings;
|
|
1773
|
+
declare const api_BrowserbaseBrowserSettingsSchema: typeof BrowserbaseBrowserSettingsSchema;
|
|
1774
|
+
type api_BrowserbaseContext = BrowserbaseContext;
|
|
1775
|
+
declare const api_BrowserbaseContextSchema: typeof BrowserbaseContextSchema;
|
|
1776
|
+
type api_BrowserbaseFingerprint = BrowserbaseFingerprint;
|
|
1777
|
+
declare const api_BrowserbaseFingerprintSchema: typeof BrowserbaseFingerprintSchema;
|
|
1778
|
+
type api_BrowserbaseFingerprintScreen = BrowserbaseFingerprintScreen;
|
|
1779
|
+
declare const api_BrowserbaseFingerprintScreenSchema: typeof BrowserbaseFingerprintScreenSchema;
|
|
1780
|
+
type api_BrowserbaseProxyConfig = BrowserbaseProxyConfig;
|
|
1781
|
+
declare const api_BrowserbaseProxyConfigSchema: typeof BrowserbaseProxyConfigSchema;
|
|
1782
|
+
type api_BrowserbaseProxyGeolocation = BrowserbaseProxyGeolocation;
|
|
1783
|
+
declare const api_BrowserbaseProxyGeolocationSchema: typeof BrowserbaseProxyGeolocationSchema;
|
|
1784
|
+
type api_BrowserbaseSessionCreateParams = BrowserbaseSessionCreateParams;
|
|
1785
|
+
declare const api_BrowserbaseSessionCreateParamsSchema: typeof BrowserbaseSessionCreateParamsSchema;
|
|
1786
|
+
type api_BrowserbaseViewport = BrowserbaseViewport;
|
|
1787
|
+
declare const api_BrowserbaseViewportSchema: typeof BrowserbaseViewportSchema;
|
|
1788
|
+
declare const api_ErrorResponseSchema: typeof ErrorResponseSchema;
|
|
1789
|
+
type api_ExternalProxyConfig = ExternalProxyConfig;
|
|
1790
|
+
declare const api_ExternalProxyConfigSchema: typeof ExternalProxyConfigSchema;
|
|
1791
|
+
declare const api_ExtractOptionsSchema: typeof ExtractOptionsSchema;
|
|
1792
|
+
type api_ExtractRequest = ExtractRequest;
|
|
1793
|
+
declare const api_ExtractRequestSchema: typeof ExtractRequestSchema;
|
|
1794
|
+
type api_ExtractResponse = ExtractResponse;
|
|
1795
|
+
declare const api_ExtractResponseSchema: typeof ExtractResponseSchema;
|
|
1796
|
+
declare const api_ExtractResultSchema: typeof ExtractResultSchema;
|
|
1797
|
+
declare const api_LocalBrowserLaunchOptionsSchema: typeof LocalBrowserLaunchOptionsSchema;
|
|
1798
|
+
type api_ModelConfig = ModelConfig;
|
|
1799
|
+
declare const api_ModelConfigObjectSchema: typeof ModelConfigObjectSchema;
|
|
1800
|
+
declare const api_ModelConfigSchema: typeof ModelConfigSchema;
|
|
1801
|
+
declare const api_ModelNameSchema: typeof ModelNameSchema;
|
|
1802
|
+
declare const api_NavigateOptionsSchema: typeof NavigateOptionsSchema;
|
|
1803
|
+
type api_NavigateRequest = NavigateRequest;
|
|
1804
|
+
declare const api_NavigateRequestSchema: typeof NavigateRequestSchema;
|
|
1805
|
+
type api_NavigateResponse = NavigateResponse;
|
|
1806
|
+
declare const api_NavigateResponseSchema: typeof NavigateResponseSchema;
|
|
1807
|
+
type api_NavigateResult = NavigateResult;
|
|
1808
|
+
declare const api_NavigateResultSchema: typeof NavigateResultSchema;
|
|
1809
|
+
declare const api_ObserveOptionsSchema: typeof ObserveOptionsSchema;
|
|
1810
|
+
type api_ObserveRequest = ObserveRequest;
|
|
1811
|
+
declare const api_ObserveRequestSchema: typeof ObserveRequestSchema;
|
|
1812
|
+
type api_ObserveResponse = ObserveResponse;
|
|
1813
|
+
declare const api_ObserveResponseSchema: typeof ObserveResponseSchema;
|
|
1814
|
+
type api_ObserveResult = ObserveResult;
|
|
1815
|
+
declare const api_ObserveResultSchema: typeof ObserveResultSchema;
|
|
1816
|
+
declare const api_Operations: typeof Operations;
|
|
1817
|
+
declare const api_ProxyConfigSchema: typeof ProxyConfigSchema;
|
|
1818
|
+
type api_ReplayAction = ReplayAction;
|
|
1819
|
+
declare const api_ReplayActionSchema: typeof ReplayActionSchema;
|
|
1820
|
+
type api_ReplayPage = ReplayPage;
|
|
1821
|
+
declare const api_ReplayPageSchema: typeof ReplayPageSchema;
|
|
1822
|
+
type api_ReplayResponse = ReplayResponse;
|
|
1823
|
+
declare const api_ReplayResponseSchema: typeof ReplayResponseSchema;
|
|
1824
|
+
type api_ReplayResult = ReplayResult;
|
|
1825
|
+
declare const api_ReplayResultSchema: typeof ReplayResultSchema;
|
|
1826
|
+
declare const api_SessionEndRequestSchema: typeof SessionEndRequestSchema;
|
|
1827
|
+
type api_SessionEndResponse = SessionEndResponse;
|
|
1828
|
+
declare const api_SessionEndResponseSchema: typeof SessionEndResponseSchema;
|
|
1829
|
+
type api_SessionEndResult = SessionEndResult;
|
|
1830
|
+
declare const api_SessionEndResultSchema: typeof SessionEndResultSchema;
|
|
1831
|
+
type api_SessionHeaders = SessionHeaders;
|
|
1832
|
+
declare const api_SessionHeadersSchema: typeof SessionHeadersSchema;
|
|
1833
|
+
type api_SessionIdParams = SessionIdParams;
|
|
1834
|
+
declare const api_SessionIdParamsSchema: typeof SessionIdParamsSchema;
|
|
1835
|
+
type api_SessionStartRequest = SessionStartRequest;
|
|
1836
|
+
declare const api_SessionStartRequestSchema: typeof SessionStartRequestSchema;
|
|
1837
|
+
type api_SessionStartResponse = SessionStartResponse;
|
|
1838
|
+
declare const api_SessionStartResponseSchema: typeof SessionStartResponseSchema;
|
|
1839
|
+
type api_SessionStartResult = SessionStartResult;
|
|
1840
|
+
declare const api_SessionStartResultSchema: typeof SessionStartResultSchema;
|
|
1841
|
+
type api_StreamEvent = StreamEvent;
|
|
1842
|
+
type api_StreamEventLogData = StreamEventLogData;
|
|
1843
|
+
declare const api_StreamEventLogDataSchema: typeof StreamEventLogDataSchema;
|
|
1844
|
+
declare const api_StreamEventSchema: typeof StreamEventSchema;
|
|
1845
|
+
type api_StreamEventStatus = StreamEventStatus;
|
|
1846
|
+
declare const api_StreamEventStatusSchema: typeof StreamEventStatusSchema;
|
|
1847
|
+
type api_StreamEventSystemData = StreamEventSystemData;
|
|
1848
|
+
declare const api_StreamEventSystemDataSchema: typeof StreamEventSystemDataSchema;
|
|
1849
|
+
type api_StreamEventType = StreamEventType;
|
|
1850
|
+
declare const api_StreamEventTypeSchema: typeof StreamEventTypeSchema;
|
|
1851
|
+
type api_TokenUsage = TokenUsage;
|
|
1852
|
+
declare const api_TokenUsageSchema: typeof TokenUsageSchema;
|
|
1853
|
+
declare const api_openApiLinks: typeof openApiLinks;
|
|
1854
|
+
declare const api_openApiSecuritySchemes: typeof openApiSecuritySchemes;
|
|
1855
|
+
declare namespace api {
|
|
1856
|
+
export { api_ActOptionsSchema as ActOptionsSchema, type api_ActRequest as ActRequest, api_ActRequestSchema as ActRequestSchema, type api_ActResponse as ActResponse, api_ActResponseSchema as ActResponseSchema, type ActResult$1 as ActResult, type api_ActResultData as ActResultData, api_ActResultDataSchema as ActResultDataSchema, api_ActResultSchema as ActResultSchema, type Action$1 as Action, api_ActionSchema as ActionSchema, type AgentAction$1 as AgentAction, api_AgentActionSchema as AgentActionSchema, api_AgentConfigSchema as AgentConfigSchema, api_AgentExecuteOptionsSchema as AgentExecuteOptionsSchema, type api_AgentExecuteRequest as AgentExecuteRequest, api_AgentExecuteRequestSchema as AgentExecuteRequestSchema, type api_AgentExecuteResponse as AgentExecuteResponse, api_AgentExecuteResponseSchema as AgentExecuteResponseSchema, type api_AgentExecuteResult as AgentExecuteResult, api_AgentExecuteResultSchema as AgentExecuteResultSchema, type api_AgentResultData as AgentResultData, api_AgentResultDataSchema as AgentResultDataSchema, type api_AgentUsage as AgentUsage, api_AgentUsageSchema as AgentUsageSchema, type api_BrowserConfig as BrowserConfig, api_BrowserConfigSchema as BrowserConfigSchema, type api_BrowserbaseBrowserSettings as BrowserbaseBrowserSettings, api_BrowserbaseBrowserSettingsSchema as BrowserbaseBrowserSettingsSchema, type api_BrowserbaseContext as BrowserbaseContext, api_BrowserbaseContextSchema as BrowserbaseContextSchema, type api_BrowserbaseFingerprint as BrowserbaseFingerprint, api_BrowserbaseFingerprintSchema as BrowserbaseFingerprintSchema, type api_BrowserbaseFingerprintScreen as BrowserbaseFingerprintScreen, api_BrowserbaseFingerprintScreenSchema as BrowserbaseFingerprintScreenSchema, type api_BrowserbaseProxyConfig as BrowserbaseProxyConfig, api_BrowserbaseProxyConfigSchema as BrowserbaseProxyConfigSchema, type api_BrowserbaseProxyGeolocation as BrowserbaseProxyGeolocation, api_BrowserbaseProxyGeolocationSchema as BrowserbaseProxyGeolocationSchema, type api_BrowserbaseSessionCreateParams as BrowserbaseSessionCreateParams, api_BrowserbaseSessionCreateParamsSchema as BrowserbaseSessionCreateParamsSchema, type api_BrowserbaseViewport as BrowserbaseViewport, api_BrowserbaseViewportSchema as BrowserbaseViewportSchema, api_ErrorResponseSchema as ErrorResponseSchema, type api_ExternalProxyConfig as ExternalProxyConfig, api_ExternalProxyConfigSchema as ExternalProxyConfigSchema, api_ExtractOptionsSchema as ExtractOptionsSchema, type api_ExtractRequest as ExtractRequest, api_ExtractRequestSchema as ExtractRequestSchema, type api_ExtractResponse as ExtractResponse, api_ExtractResponseSchema as ExtractResponseSchema, type ExtractResult$1 as ExtractResult, api_ExtractResultSchema as ExtractResultSchema, api_LocalBrowserLaunchOptionsSchema as LocalBrowserLaunchOptionsSchema, type api_ModelConfig as ModelConfig, api_ModelConfigObjectSchema as ModelConfigObjectSchema, api_ModelConfigSchema as ModelConfigSchema, api_ModelNameSchema as ModelNameSchema, api_NavigateOptionsSchema as NavigateOptionsSchema, type api_NavigateRequest as NavigateRequest, api_NavigateRequestSchema as NavigateRequestSchema, type api_NavigateResponse as NavigateResponse, api_NavigateResponseSchema as NavigateResponseSchema, type api_NavigateResult as NavigateResult, api_NavigateResultSchema as NavigateResultSchema, api_ObserveOptionsSchema as ObserveOptionsSchema, type api_ObserveRequest as ObserveRequest, api_ObserveRequestSchema as ObserveRequestSchema, type api_ObserveResponse as ObserveResponse, api_ObserveResponseSchema as ObserveResponseSchema, type api_ObserveResult as ObserveResult, api_ObserveResultSchema as ObserveResultSchema, api_Operations as Operations, api_ProxyConfigSchema as ProxyConfigSchema, type api_ReplayAction as ReplayAction, api_ReplayActionSchema as ReplayActionSchema, type api_ReplayPage as ReplayPage, api_ReplayPageSchema as ReplayPageSchema, type api_ReplayResponse as ReplayResponse, api_ReplayResponseSchema as ReplayResponseSchema, type api_ReplayResult as ReplayResult, api_ReplayResultSchema as ReplayResultSchema, api_SessionEndRequestSchema as SessionEndRequestSchema, type api_SessionEndResponse as SessionEndResponse, api_SessionEndResponseSchema as SessionEndResponseSchema, type api_SessionEndResult as SessionEndResult, api_SessionEndResultSchema as SessionEndResultSchema, type api_SessionHeaders as SessionHeaders, api_SessionHeadersSchema as SessionHeadersSchema, type api_SessionIdParams as SessionIdParams, api_SessionIdParamsSchema as SessionIdParamsSchema, type api_SessionStartRequest as SessionStartRequest, api_SessionStartRequestSchema as SessionStartRequestSchema, type api_SessionStartResponse as SessionStartResponse, api_SessionStartResponseSchema as SessionStartResponseSchema, type api_SessionStartResult as SessionStartResult, api_SessionStartResultSchema as SessionStartResultSchema, type api_StreamEvent as StreamEvent, type api_StreamEventLogData as StreamEventLogData, api_StreamEventLogDataSchema as StreamEventLogDataSchema, api_StreamEventSchema as StreamEventSchema, type api_StreamEventStatus as StreamEventStatus, api_StreamEventStatusSchema as StreamEventStatusSchema, type api_StreamEventSystemData as StreamEventSystemData, api_StreamEventSystemDataSchema as StreamEventSystemDataSchema, type api_StreamEventType as StreamEventType, api_StreamEventTypeSchema as StreamEventTypeSchema, type api_TokenUsage as TokenUsage, api_TokenUsageSchema as TokenUsageSchema, api_openApiLinks as openApiLinks, api_openApiSecuritySchemes as openApiSecuritySchemes };
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
declare class StagehandAPIError extends Error {
|
|
1860
|
+
constructor(message: string);
|
|
1861
|
+
}
|
|
1862
|
+
declare class StagehandAPIUnauthorizedError extends StagehandAPIError {
|
|
1863
|
+
constructor(message?: string);
|
|
1864
|
+
}
|
|
1865
|
+
declare class StagehandHttpError extends StagehandAPIError {
|
|
1866
|
+
constructor(message: string);
|
|
1867
|
+
}
|
|
1868
|
+
declare class StagehandServerError extends StagehandAPIError {
|
|
1869
|
+
constructor(message: string);
|
|
1870
|
+
}
|
|
1871
|
+
declare class StagehandResponseBodyError extends StagehandAPIError {
|
|
1872
|
+
constructor();
|
|
1873
|
+
}
|
|
1874
|
+
declare class StagehandResponseParseError extends StagehandAPIError {
|
|
1875
|
+
constructor(message: string);
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
interface ActOptions {
|
|
1879
|
+
model?: ModelConfiguration;
|
|
1880
|
+
variables?: Record<string, string>;
|
|
1881
|
+
timeout?: number;
|
|
1882
|
+
page?: Page$1 | Page$2 | Page$3 | Page;
|
|
1883
|
+
}
|
|
1884
|
+
interface ActResult {
|
|
1885
|
+
success: boolean;
|
|
1886
|
+
message: string;
|
|
1887
|
+
actionDescription: string;
|
|
1888
|
+
actions: Action[];
|
|
1889
|
+
}
|
|
1890
|
+
type ExtractResult<T extends StagehandZodSchema> = InferStagehandSchema<T>;
|
|
1891
|
+
interface Action {
|
|
1892
|
+
selector: string;
|
|
1893
|
+
description: string;
|
|
1894
|
+
method?: string;
|
|
1895
|
+
arguments?: string[];
|
|
1896
|
+
}
|
|
1897
|
+
interface HistoryEntry {
|
|
1898
|
+
method: "act" | "extract" | "observe" | "navigate" | "agent";
|
|
1899
|
+
parameters: unknown;
|
|
1900
|
+
result: unknown;
|
|
1901
|
+
timestamp: string;
|
|
1902
|
+
}
|
|
1903
|
+
interface ExtractOptions {
|
|
1904
|
+
model?: ModelConfiguration;
|
|
1905
|
+
timeout?: number;
|
|
1906
|
+
selector?: string;
|
|
1907
|
+
page?: Page$1 | Page$2 | Page$3 | Page;
|
|
1908
|
+
}
|
|
1909
|
+
declare const defaultExtractSchema: z.ZodObject<{
|
|
1910
|
+
extraction: z.ZodString;
|
|
1911
|
+
}, z.core.$strip>;
|
|
1912
|
+
declare const pageTextSchema: z.ZodObject<{
|
|
1913
|
+
pageText: z.ZodString;
|
|
1914
|
+
}, z.core.$strip>;
|
|
1915
|
+
interface ObserveOptions {
|
|
1916
|
+
model?: ModelConfiguration;
|
|
1917
|
+
timeout?: number;
|
|
1918
|
+
selector?: string;
|
|
1919
|
+
page?: Page$1 | Page$2 | Page$3 | Page;
|
|
1920
|
+
}
|
|
1921
|
+
declare enum V3FunctionName {
|
|
1922
|
+
ACT = "ACT",
|
|
1923
|
+
EXTRACT = "EXTRACT",
|
|
1924
|
+
OBSERVE = "OBSERVE",
|
|
1925
|
+
AGENT = "AGENT"
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
interface StagehandMetrics {
|
|
1929
|
+
actPromptTokens: number;
|
|
1930
|
+
actCompletionTokens: number;
|
|
1931
|
+
actReasoningTokens: number;
|
|
1932
|
+
actCachedInputTokens: number;
|
|
1933
|
+
actInferenceTimeMs: number;
|
|
1934
|
+
extractPromptTokens: number;
|
|
1935
|
+
extractCompletionTokens: number;
|
|
1936
|
+
extractReasoningTokens: number;
|
|
1937
|
+
extractCachedInputTokens: number;
|
|
1938
|
+
extractInferenceTimeMs: number;
|
|
1939
|
+
observePromptTokens: number;
|
|
1940
|
+
observeCompletionTokens: number;
|
|
1941
|
+
observeReasoningTokens: number;
|
|
1942
|
+
observeCachedInputTokens: number;
|
|
1943
|
+
observeInferenceTimeMs: number;
|
|
1944
|
+
agentPromptTokens: number;
|
|
1945
|
+
agentCompletionTokens: number;
|
|
1946
|
+
agentReasoningTokens: number;
|
|
1947
|
+
agentCachedInputTokens: number;
|
|
1948
|
+
agentInferenceTimeMs: number;
|
|
1949
|
+
totalPromptTokens: number;
|
|
1950
|
+
totalCompletionTokens: number;
|
|
1951
|
+
totalReasoningTokens: number;
|
|
1952
|
+
totalCachedInputTokens: number;
|
|
1953
|
+
totalInferenceTimeMs: number;
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
type V3Env = "LOCAL" | "BROWSERBASE";
|
|
1957
|
+
declare const localBrowserLaunchOptionsSchema: z.ZodObject<{
|
|
1958
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1959
|
+
executablePath: z.ZodOptional<z.ZodString>;
|
|
1960
|
+
userDataDir: z.ZodOptional<z.ZodString>;
|
|
1961
|
+
preserveUserDataDir: z.ZodOptional<z.ZodBoolean>;
|
|
1962
|
+
headless: z.ZodOptional<z.ZodBoolean>;
|
|
1963
|
+
devtools: z.ZodOptional<z.ZodBoolean>;
|
|
1964
|
+
chromiumSandbox: z.ZodOptional<z.ZodBoolean>;
|
|
1965
|
+
ignoreDefaultArgs: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
|
|
1966
|
+
proxy: z.ZodOptional<z.ZodObject<{
|
|
1967
|
+
server: z.ZodString;
|
|
1968
|
+
bypass: z.ZodOptional<z.ZodString>;
|
|
1969
|
+
username: z.ZodOptional<z.ZodString>;
|
|
1970
|
+
password: z.ZodOptional<z.ZodString>;
|
|
1971
|
+
}, z.core.$strip>>;
|
|
1972
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
1973
|
+
viewport: z.ZodOptional<z.ZodObject<{
|
|
1974
|
+
width: z.ZodNumber;
|
|
1975
|
+
height: z.ZodNumber;
|
|
1976
|
+
}, z.core.$strip>>;
|
|
1977
|
+
deviceScaleFactor: z.ZodOptional<z.ZodNumber>;
|
|
1978
|
+
hasTouch: z.ZodOptional<z.ZodBoolean>;
|
|
1979
|
+
ignoreHTTPSErrors: z.ZodOptional<z.ZodBoolean>;
|
|
1980
|
+
cdpUrl: z.ZodOptional<z.ZodString>;
|
|
1981
|
+
connectTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
1982
|
+
downloadsPath: z.ZodOptional<z.ZodString>;
|
|
1983
|
+
acceptDownloads: z.ZodOptional<z.ZodBoolean>;
|
|
1984
|
+
}, z.core.$strict>;
|
|
1985
|
+
type LocalBrowserLaunchOptions = z.infer<typeof LocalBrowserLaunchOptionsSchema>;
|
|
1986
|
+
/** Constructor options for V3 */
|
|
1987
|
+
interface V3Options {
|
|
1988
|
+
env: V3Env;
|
|
1989
|
+
apiKey?: string;
|
|
1990
|
+
projectId?: string;
|
|
1991
|
+
/**
|
|
1992
|
+
* Optional: fine-tune Browserbase session creation or resume an existing session.
|
|
1993
|
+
*/
|
|
1994
|
+
browserbaseSessionCreateParams?: BrowserbaseSessionCreateParams;
|
|
1995
|
+
browserbaseSessionID?: string;
|
|
1996
|
+
localBrowserLaunchOptions?: LocalBrowserLaunchOptions;
|
|
1997
|
+
model?: ModelConfiguration;
|
|
1998
|
+
llmClient?: LLMClient;
|
|
1999
|
+
systemPrompt?: string;
|
|
2000
|
+
logInferenceToFile?: boolean;
|
|
2001
|
+
experimental?: boolean;
|
|
2002
|
+
verbose?: 0 | 1 | 2;
|
|
2003
|
+
selfHeal?: boolean;
|
|
2004
|
+
waitForCaptchaSolves?: boolean;
|
|
2005
|
+
actTimeoutMs?: number;
|
|
2006
|
+
/** Disable pino logging backend (useful for tests or minimal environments). */
|
|
2007
|
+
disablePino?: boolean;
|
|
2008
|
+
/** Optional external logger hook for integrating with host apps. */
|
|
2009
|
+
logger?: (line: LogLine) => void;
|
|
2010
|
+
/** Directory used to persist cached actions for act(). */
|
|
2011
|
+
cacheDir?: string;
|
|
2012
|
+
domSettleTimeout?: number;
|
|
2013
|
+
disableAPI?: boolean;
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
declare class StagehandError extends Error {
|
|
2017
|
+
constructor(message: string);
|
|
2018
|
+
}
|
|
2019
|
+
declare class StagehandDefaultError extends StagehandError {
|
|
2020
|
+
constructor(error?: unknown);
|
|
2021
|
+
}
|
|
2022
|
+
declare class StagehandEnvironmentError extends StagehandError {
|
|
2023
|
+
constructor(currentEnvironment: string, requiredEnvironment: string, feature: string);
|
|
2024
|
+
}
|
|
2025
|
+
declare class MissingEnvironmentVariableError extends StagehandError {
|
|
2026
|
+
constructor(missingEnvironmentVariable: string, feature: string);
|
|
2027
|
+
}
|
|
2028
|
+
declare class UnsupportedModelError extends StagehandError {
|
|
2029
|
+
constructor(supportedModels: string[], feature?: string);
|
|
2030
|
+
}
|
|
2031
|
+
declare class UnsupportedModelProviderError extends StagehandError {
|
|
2032
|
+
constructor(supportedProviders: string[], feature?: string);
|
|
2033
|
+
}
|
|
2034
|
+
declare class UnsupportedAISDKModelProviderError extends StagehandError {
|
|
2035
|
+
constructor(provider: string, supportedProviders: string[]);
|
|
2036
|
+
}
|
|
2037
|
+
declare class InvalidAISDKModelFormatError extends StagehandError {
|
|
2038
|
+
constructor(modelName: string);
|
|
2039
|
+
}
|
|
2040
|
+
declare class StagehandNotInitializedError extends StagehandError {
|
|
2041
|
+
constructor(prop: string);
|
|
2042
|
+
}
|
|
2043
|
+
declare class BrowserbaseSessionNotFoundError extends StagehandError {
|
|
2044
|
+
constructor();
|
|
2045
|
+
}
|
|
2046
|
+
declare class CaptchaTimeoutError extends StagehandError {
|
|
2047
|
+
constructor();
|
|
2048
|
+
}
|
|
2049
|
+
declare class MissingLLMConfigurationError extends StagehandError {
|
|
2050
|
+
constructor();
|
|
2051
|
+
}
|
|
2052
|
+
declare class HandlerNotInitializedError extends StagehandError {
|
|
2053
|
+
constructor(handlerType: string);
|
|
2054
|
+
}
|
|
2055
|
+
declare class StagehandInvalidArgumentError extends StagehandError {
|
|
2056
|
+
constructor(message: string);
|
|
2057
|
+
}
|
|
2058
|
+
declare class StagehandElementNotFoundError extends StagehandError {
|
|
2059
|
+
constructor(xpaths: string[]);
|
|
2060
|
+
}
|
|
2061
|
+
declare class AgentScreenshotProviderError extends StagehandError {
|
|
2062
|
+
constructor(message: string);
|
|
2063
|
+
}
|
|
2064
|
+
declare class StagehandMissingArgumentError extends StagehandError {
|
|
2065
|
+
constructor(message: string);
|
|
2066
|
+
}
|
|
2067
|
+
declare class CreateChatCompletionResponseError extends StagehandError {
|
|
2068
|
+
constructor(message: string);
|
|
2069
|
+
}
|
|
2070
|
+
declare class StagehandEvalError extends StagehandError {
|
|
2071
|
+
constructor(message: string);
|
|
2072
|
+
}
|
|
2073
|
+
declare class StagehandDomProcessError extends StagehandError {
|
|
2074
|
+
constructor(message: string);
|
|
2075
|
+
}
|
|
2076
|
+
declare class StagehandClickError extends StagehandError {
|
|
2077
|
+
constructor(message: string, selector: string);
|
|
2078
|
+
}
|
|
2079
|
+
declare class LLMResponseError extends StagehandError {
|
|
2080
|
+
constructor(primitive: string, message: string);
|
|
2081
|
+
}
|
|
2082
|
+
declare class StagehandIframeError extends StagehandError {
|
|
2083
|
+
constructor(frameUrl: string, message: string);
|
|
2084
|
+
}
|
|
2085
|
+
declare class ContentFrameNotFoundError extends StagehandError {
|
|
2086
|
+
constructor(selector: string);
|
|
2087
|
+
}
|
|
2088
|
+
declare class XPathResolutionError extends StagehandError {
|
|
2089
|
+
constructor(xpath: string);
|
|
2090
|
+
}
|
|
2091
|
+
declare class ExperimentalApiConflictError extends StagehandError {
|
|
2092
|
+
constructor();
|
|
2093
|
+
}
|
|
2094
|
+
declare class ExperimentalNotConfiguredError extends StagehandError {
|
|
2095
|
+
constructor(featureName: string);
|
|
2096
|
+
}
|
|
2097
|
+
declare class CuaModelRequiredError extends StagehandError {
|
|
2098
|
+
constructor(availableModels: readonly string[]);
|
|
2099
|
+
}
|
|
2100
|
+
declare class ZodSchemaValidationError extends Error {
|
|
2101
|
+
readonly received: unknown;
|
|
2102
|
+
readonly issues: ReturnType<ZodError["format"]>;
|
|
2103
|
+
constructor(received: unknown, issues: ReturnType<ZodError["format"]>);
|
|
2104
|
+
}
|
|
2105
|
+
declare class StagehandInitError extends StagehandError {
|
|
2106
|
+
constructor(message: string);
|
|
2107
|
+
}
|
|
2108
|
+
declare class MCPConnectionError extends StagehandError {
|
|
2109
|
+
readonly serverUrl: string;
|
|
2110
|
+
readonly originalError: unknown;
|
|
2111
|
+
constructor(serverUrl: string, originalError: unknown);
|
|
2112
|
+
}
|
|
2113
|
+
declare class StagehandShadowRootMissingError extends StagehandError {
|
|
2114
|
+
constructor(detail?: string);
|
|
2115
|
+
}
|
|
2116
|
+
declare class StagehandShadowSegmentEmptyError extends StagehandError {
|
|
2117
|
+
constructor();
|
|
2118
|
+
}
|
|
2119
|
+
declare class StagehandShadowSegmentNotFoundError extends StagehandError {
|
|
2120
|
+
constructor(segment: string, hint?: string);
|
|
2121
|
+
}
|
|
2122
|
+
declare class ElementNotVisibleError extends StagehandError {
|
|
2123
|
+
constructor(selector: string);
|
|
2124
|
+
}
|
|
2125
|
+
declare class ResponseBodyError extends StagehandError {
|
|
2126
|
+
constructor(message: string);
|
|
2127
|
+
}
|
|
2128
|
+
declare class ResponseParseError extends StagehandError {
|
|
2129
|
+
constructor(message: string);
|
|
2130
|
+
}
|
|
2131
|
+
declare class TimeoutError extends StagehandError {
|
|
2132
|
+
constructor(operation: string, timeoutMs: number);
|
|
2133
|
+
}
|
|
2134
|
+
declare class ActTimeoutError extends TimeoutError {
|
|
2135
|
+
constructor(timeoutMs: number);
|
|
2136
|
+
}
|
|
2137
|
+
declare class ExtractTimeoutError extends TimeoutError {
|
|
2138
|
+
constructor(timeoutMs: number);
|
|
2139
|
+
}
|
|
2140
|
+
declare class ObserveTimeoutError extends TimeoutError {
|
|
2141
|
+
constructor(timeoutMs: number);
|
|
2142
|
+
}
|
|
2143
|
+
declare class PageNotFoundError extends StagehandError {
|
|
2144
|
+
constructor(identifier: string);
|
|
2145
|
+
}
|
|
2146
|
+
declare class ConnectionTimeoutError extends StagehandError {
|
|
2147
|
+
constructor(message: string);
|
|
2148
|
+
}
|
|
2149
|
+
declare class StreamingCallbacksInNonStreamingModeError extends StagehandError {
|
|
2150
|
+
readonly invalidCallbacks: string[];
|
|
2151
|
+
constructor(invalidCallbacks: string[]);
|
|
2152
|
+
}
|
|
2153
|
+
declare class AgentAbortError extends StagehandError {
|
|
2154
|
+
readonly reason: string;
|
|
2155
|
+
constructor(reason?: string);
|
|
2156
|
+
}
|
|
2157
|
+
declare class StagehandClosedError extends StagehandError {
|
|
2158
|
+
constructor();
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
declare class AISdkClient extends LLMClient {
|
|
2162
|
+
type: "aisdk";
|
|
2163
|
+
private model;
|
|
2164
|
+
constructor({ model }: {
|
|
2165
|
+
model: LanguageModelV2;
|
|
2166
|
+
});
|
|
2167
|
+
createChatCompletion<T = ChatCompletion>({ options, }: CreateChatCompletionOptions): Promise<T>;
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
/**
|
|
2171
|
+
* Constructor parameters for StagehandAPIClient
|
|
2172
|
+
*/
|
|
2173
|
+
interface StagehandAPIConstructorParams {
|
|
2174
|
+
apiKey: string;
|
|
2175
|
+
projectId: string;
|
|
2176
|
+
logger: (message: LogLine) => void;
|
|
2177
|
+
}
|
|
2178
|
+
/**
|
|
2179
|
+
* Parameters for starting a session via the API client.
|
|
2180
|
+
* Extends Api.SessionStartRequest with client-specific field (modelApiKey).
|
|
2181
|
+
*
|
|
2182
|
+
* Wire format: Api.SessionStartRequest (modelApiKey sent via header, not body)
|
|
2183
|
+
*/
|
|
2184
|
+
interface ClientSessionStartParams extends SessionStartRequest {
|
|
2185
|
+
/** Model API key - sent via x-model-api-key header, not in request body */
|
|
2186
|
+
modelApiKey: string;
|
|
2187
|
+
}
|
|
2188
|
+
/**
|
|
2189
|
+
* Client parameters for act() method.
|
|
2190
|
+
* Derives structure from Api.ActRequest but uses SDK's ActOptions (which includes `page`).
|
|
2191
|
+
* Before serialization, `page` is stripped to produce Api.ActRequest wire format.
|
|
2192
|
+
*/
|
|
2193
|
+
interface ClientActParameters {
|
|
2194
|
+
input: ActRequest["input"];
|
|
2195
|
+
options?: ActOptions;
|
|
2196
|
+
frameId?: ActRequest["frameId"];
|
|
2197
|
+
}
|
|
2198
|
+
/**
|
|
2199
|
+
* Client parameters for extract() method.
|
|
2200
|
+
* Derives structure from Api.ExtractRequest but uses SDK's ExtractOptions (which includes `page`)
|
|
2201
|
+
* and accepts Zod schema (converted to JSON schema for wire format).
|
|
2202
|
+
*/
|
|
2203
|
+
interface ClientExtractParameters {
|
|
2204
|
+
instruction?: ExtractRequest["instruction"];
|
|
2205
|
+
schema?: StagehandZodSchema;
|
|
2206
|
+
options?: ExtractOptions;
|
|
2207
|
+
frameId?: ExtractRequest["frameId"];
|
|
2208
|
+
}
|
|
2209
|
+
/**
|
|
2210
|
+
* Client parameters for observe() method.
|
|
2211
|
+
* Derives structure from Api.ObserveRequest but uses SDK's ObserveOptions (which includes `page`).
|
|
2212
|
+
* Before serialization, `page` is stripped to produce Api.ObserveRequest wire format.
|
|
2213
|
+
*/
|
|
2214
|
+
interface ClientObserveParameters {
|
|
2215
|
+
instruction?: ObserveRequest["instruction"];
|
|
2216
|
+
options?: ObserveOptions;
|
|
2217
|
+
frameId?: ObserveRequest["frameId"];
|
|
2218
|
+
}
|
|
2219
|
+
declare class StagehandAPIClient {
|
|
2220
|
+
private apiKey;
|
|
2221
|
+
private projectId;
|
|
2222
|
+
private sessionId?;
|
|
2223
|
+
private modelApiKey;
|
|
2224
|
+
private modelProvider?;
|
|
2225
|
+
private logger;
|
|
2226
|
+
private fetchWithCookies;
|
|
2227
|
+
constructor({ apiKey, projectId, logger }: StagehandAPIConstructorParams);
|
|
2228
|
+
init({ modelName, modelApiKey, domSettleTimeoutMs, verbose, systemPrompt, selfHeal, browserbaseSessionCreateParams, browserbaseSessionID, }: ClientSessionStartParams): Promise<SessionStartResult>;
|
|
2229
|
+
act({ input, options, frameId, }: ClientActParameters): Promise<ActResult>;
|
|
2230
|
+
extract<T extends StagehandZodSchema>({ instruction, schema: zodSchema, options, frameId, }: ClientExtractParameters): Promise<ExtractResult<T>>;
|
|
2231
|
+
observe({ instruction, options, frameId, }: ClientObserveParameters): Promise<Action[]>;
|
|
2232
|
+
goto(url: string, options?: NavigateRequest["options"], frameId?: string): Promise<SerializableResponse | null>;
|
|
2233
|
+
agentExecute(agentConfig: AgentConfig, executeOptions: AgentExecuteOptions | string, frameId?: string): Promise<AgentResult>;
|
|
2234
|
+
end(): Promise<Response>;
|
|
2235
|
+
getReplayMetrics(): Promise<StagehandMetrics>;
|
|
2236
|
+
/**
|
|
2237
|
+
* Prepares a model configuration for the API payload by ensuring the `apiKey`
|
|
2238
|
+
* is included. If the model is passed as a string, converts it to an object
|
|
2239
|
+
* with `modelName` and `apiKey`.
|
|
2240
|
+
*
|
|
2241
|
+
* In API mode, we only attempt to load an API key from env vars when the
|
|
2242
|
+
* model provider differs from the one used to init the session.
|
|
2243
|
+
*/
|
|
2244
|
+
private prepareModelConfig;
|
|
2245
|
+
private execute;
|
|
2246
|
+
private request;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
/**
|
|
2250
|
+
* V3Context
|
|
2251
|
+
*
|
|
2252
|
+
* Owns the root CDP connection and wires Target/Page events into Page.
|
|
2253
|
+
* Maintains one Page per top-level target, adopts OOPIF child sessions into the owner Page,
|
|
2254
|
+
* and tracks target→page and (root) frame→target mappings for lookups.
|
|
2255
|
+
*
|
|
2256
|
+
* IMPORTANT: FrameId → session ownership is managed inside Page (via its FrameRegistry).
|
|
2257
|
+
* Context never “guesses” owners; it simply forwards events (with the emitting session)
|
|
2258
|
+
* so Page can record the correct owner at event time.
|
|
2259
|
+
*/
|
|
2260
|
+
declare class V3Context {
|
|
2261
|
+
readonly conn: CdpConnection;
|
|
2262
|
+
private readonly env;
|
|
2263
|
+
private readonly apiClient;
|
|
2264
|
+
private readonly localBrowserLaunchOptions;
|
|
2265
|
+
private constructor();
|
|
2266
|
+
private readonly _piercerInstalled;
|
|
2267
|
+
private _lastPopupSignalAt;
|
|
2268
|
+
private sessionKey;
|
|
2269
|
+
private readonly _sessionInit;
|
|
2270
|
+
private pagesByTarget;
|
|
2271
|
+
private mainFrameToTarget;
|
|
2272
|
+
private sessionOwnerPage;
|
|
2273
|
+
private frameOwnerPage;
|
|
2274
|
+
private pendingOopifByMainFrame;
|
|
2275
|
+
private createdAtByTarget;
|
|
2276
|
+
private typeByTarget;
|
|
2277
|
+
private _pageOrder;
|
|
2278
|
+
private pendingCreatedTargetUrl;
|
|
2279
|
+
private readonly initScripts;
|
|
2280
|
+
/**
|
|
2281
|
+
* Create a Context for a given CDP websocket URL and bootstrap target wiring.
|
|
2282
|
+
*/
|
|
2283
|
+
static create(wsUrl: string, opts?: {
|
|
2284
|
+
env?: "LOCAL" | "BROWSERBASE";
|
|
2285
|
+
apiClient?: StagehandAPIClient | null;
|
|
2286
|
+
localBrowserLaunchOptions?: LocalBrowserLaunchOptions | null;
|
|
2287
|
+
}): Promise<V3Context>;
|
|
2288
|
+
/**
|
|
2289
|
+
* Wait until at least one top-level Page has been created and registered.
|
|
2290
|
+
* We poll internal maps that bootstrap/onAttachedToTarget populate.
|
|
2291
|
+
*/
|
|
2292
|
+
private waitForFirstTopLevelPage;
|
|
2293
|
+
private waitForInitialTopLevelTargets;
|
|
2294
|
+
private ensurePiercer;
|
|
2295
|
+
/** Mark a page target as the most-recent one (active). */
|
|
2296
|
+
private _pushActive;
|
|
2297
|
+
/** Remove a page target from the recency list (used on close). */
|
|
2298
|
+
private _removeFromOrder;
|
|
2299
|
+
/** Return the current active Page (most-recent page that still exists). */
|
|
2300
|
+
activePage(): Page | undefined;
|
|
2301
|
+
/** Explicitly mark a known Page as the most-recent active page (and focus it). */
|
|
2302
|
+
setActivePage(page: Page): void;
|
|
2303
|
+
addInitScript<Arg>(script: InitScriptSource<Arg>, arg?: Arg): Promise<void>;
|
|
2304
|
+
/**
|
|
2305
|
+
* Return top-level `Page`s (oldest → newest). OOPIF targets are not included.
|
|
2306
|
+
*/
|
|
2307
|
+
pages(): Page[];
|
|
2308
|
+
private applyInitScriptsToPage;
|
|
2309
|
+
/**
|
|
2310
|
+
* Resolve an owning `Page` by the **top-level main frame id**.
|
|
2311
|
+
* Note: child (OOPIF) roots are intentionally not present in this mapping.
|
|
2312
|
+
*/
|
|
2313
|
+
resolvePageByMainFrameId(frameId: string): Page | undefined;
|
|
2314
|
+
/**
|
|
2315
|
+
* Serialize the full frame tree for a given top-level main frame id.
|
|
2316
|
+
*/
|
|
2317
|
+
getFullFrameTreeByMainFrameId(rootMainFrameId: string): Promise<Protocol.Page.FrameTree>;
|
|
2318
|
+
/**
|
|
2319
|
+
* Create a new top-level page (tab) with the given URL and return its Page object.
|
|
2320
|
+
* Waits until the target is attached and registered.
|
|
2321
|
+
*/
|
|
2322
|
+
newPage(url?: string): Promise<Page>;
|
|
2323
|
+
/**
|
|
2324
|
+
* Close CDP and clear all mappings. Best-effort cleanup.
|
|
2325
|
+
*/
|
|
2326
|
+
close(): Promise<void>;
|
|
2327
|
+
/**
|
|
2328
|
+
* Bootstrap target lifecycle:
|
|
2329
|
+
* - Attach to existing targets.
|
|
2330
|
+
* - Attach on `Target.targetCreated` (fallback for OOPIFs).
|
|
2331
|
+
* - Handle auto-attach events.
|
|
2332
|
+
* - Clean up on detach/destroy.
|
|
2333
|
+
*/
|
|
2334
|
+
private bootstrap;
|
|
2335
|
+
/**
|
|
2336
|
+
* Handle a newly attached target (top-level or potential OOPIF):
|
|
2337
|
+
* - Enable Page domain and lifecycle events.
|
|
2338
|
+
* - If top-level → create Page, wire listeners, resume.
|
|
2339
|
+
* - Else → probe child root frame id via `Page.getFrameTree` and adopt immediately
|
|
2340
|
+
* if the parent is known; otherwise stage until parent `frameAttached`.
|
|
2341
|
+
* - Resume the target only after listeners are wired.
|
|
2342
|
+
*/
|
|
2343
|
+
private onAttachedToTarget;
|
|
2344
|
+
/**
|
|
2345
|
+
* Detach handler:
|
|
2346
|
+
* - Remove child session ownership and prune its subtree.
|
|
2347
|
+
* - If a top-level target, cleanup its `Page` and mappings.
|
|
2348
|
+
* - Drop any staged child for this session.
|
|
2349
|
+
*/
|
|
2350
|
+
private onDetachedFromTarget;
|
|
2351
|
+
/**
|
|
2352
|
+
* Cleanup a top-level Page by target id, removing its root and staged children.
|
|
2353
|
+
*/
|
|
2354
|
+
private cleanupByTarget;
|
|
2355
|
+
/**
|
|
2356
|
+
* Wire Page-domain frame events for a session into the owning Page & mappings.
|
|
2357
|
+
* We forward the *emitting session* with every event so Page can stamp ownership precisely.
|
|
2358
|
+
*/
|
|
2359
|
+
private installFrameEventBridges;
|
|
2360
|
+
/**
|
|
2361
|
+
* Register that a session belongs to a Page (used by event routing).
|
|
2362
|
+
*/
|
|
2363
|
+
private wireSessionToOwnerPage;
|
|
2364
|
+
/**
|
|
2365
|
+
* Utility: reverse-lookup the top-level target id that owns a given Page.
|
|
2366
|
+
*/
|
|
2367
|
+
private findTargetIdByPage;
|
|
2368
|
+
private _notePopupSignal;
|
|
2369
|
+
/**
|
|
2370
|
+
* Await the current active page, waiting briefly if a popup/open was just triggered.
|
|
2371
|
+
* Normal path returns immediately; popup path waits up to timeoutMs for the new page.
|
|
2372
|
+
*/
|
|
2373
|
+
awaitActivePage(timeoutMs?: number): Promise<Page>;
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
type AgentReplayStep = AgentReplayActStep | AgentReplayFillFormStep | AgentReplayGotoStep | AgentReplayScrollStep | AgentReplayWaitStep | AgentReplayNavBackStep | AgentReplayKeysStep | {
|
|
2377
|
+
type: string;
|
|
2378
|
+
[key: string]: unknown;
|
|
2379
|
+
};
|
|
2380
|
+
interface AgentReplayActStep {
|
|
2381
|
+
type: "act";
|
|
2382
|
+
instruction: string;
|
|
2383
|
+
actions?: Action[];
|
|
2384
|
+
actionDescription?: string;
|
|
2385
|
+
message?: string;
|
|
2386
|
+
timeout?: number;
|
|
2387
|
+
}
|
|
2388
|
+
interface AgentReplayFillFormStep {
|
|
2389
|
+
type: "fillForm";
|
|
2390
|
+
fields?: Array<{
|
|
2391
|
+
action: string;
|
|
2392
|
+
value: string;
|
|
2393
|
+
}>;
|
|
2394
|
+
observeResults?: Action[];
|
|
2395
|
+
actions?: Action[];
|
|
2396
|
+
}
|
|
2397
|
+
interface AgentReplayGotoStep {
|
|
2398
|
+
type: "goto";
|
|
2399
|
+
url: string;
|
|
2400
|
+
waitUntil?: LoadState;
|
|
2401
|
+
}
|
|
2402
|
+
interface AgentReplayScrollStep {
|
|
2403
|
+
type: "scroll";
|
|
2404
|
+
deltaX?: number;
|
|
2405
|
+
deltaY?: number;
|
|
2406
|
+
anchor?: {
|
|
2407
|
+
x: number;
|
|
2408
|
+
y: number;
|
|
2409
|
+
};
|
|
2410
|
+
}
|
|
2411
|
+
interface AgentReplayWaitStep {
|
|
2412
|
+
type: "wait";
|
|
2413
|
+
timeMs: number;
|
|
2414
|
+
}
|
|
2415
|
+
interface AgentReplayNavBackStep {
|
|
2416
|
+
type: "navback";
|
|
2417
|
+
waitUntil?: LoadState;
|
|
2418
|
+
}
|
|
2419
|
+
interface AgentReplayKeysStep {
|
|
2420
|
+
type: "keys";
|
|
2421
|
+
instruction?: string;
|
|
2422
|
+
playwrightArguments: {
|
|
2423
|
+
method: "type" | "press";
|
|
2424
|
+
text?: string;
|
|
2425
|
+
keys?: string;
|
|
2426
|
+
times?: number;
|
|
2427
|
+
};
|
|
2428
|
+
}
|
|
2429
|
+
|
|
2430
|
+
/**
|
|
2431
|
+
* Response
|
|
2432
|
+
* -----------------
|
|
2433
|
+
*
|
|
2434
|
+
* This module implements a Playwright-inspired response wrapper that exposes
|
|
2435
|
+
* navigation metadata and helpers for retrieving HTTP response bodies. The
|
|
2436
|
+
* abstraction is consumed by navigation routines (e.g. `Page.goto`) so callers
|
|
2437
|
+
* can synchronously inspect status codes, lazily fetch body text, or await the
|
|
2438
|
+
* network layer finishing the request. The implementation is built directly on
|
|
2439
|
+
* Chrome DevTools Protocol primitives – it holds the originating `requestId`
|
|
2440
|
+
* so it can request payloads via `Network.getResponseBody`, and it listens for
|
|
2441
|
+
* `responseReceivedExtraInfo`, `loadingFinished`, and `loadingFailed` events to
|
|
2442
|
+
* hydrate the richer header view and resolve callers waiting on completion.
|
|
2443
|
+
*/
|
|
2444
|
+
|
|
2445
|
+
type ServerAddr = {
|
|
2446
|
+
ipAddress: string;
|
|
2447
|
+
port: number;
|
|
2448
|
+
};
|
|
2449
|
+
/**
|
|
2450
|
+
* Thin wrapper around CDP response metadata that mirrors the ergonomics of
|
|
2451
|
+
* Playwright's `Response` class. The class intentionally keeps the same method
|
|
2452
|
+
* names so upstream integrations can transition with minimal code changes.
|
|
2453
|
+
*/
|
|
2454
|
+
declare class Response$1 {
|
|
2455
|
+
private readonly page;
|
|
2456
|
+
private readonly session;
|
|
2457
|
+
private readonly requestId;
|
|
2458
|
+
private readonly frameId?;
|
|
2459
|
+
private readonly loaderId?;
|
|
2460
|
+
private readonly response;
|
|
2461
|
+
private readonly fromServiceWorkerFlag;
|
|
2462
|
+
private readonly serverAddress?;
|
|
2463
|
+
private headersObject;
|
|
2464
|
+
private headersArrayCache;
|
|
2465
|
+
private allHeadersCache;
|
|
2466
|
+
private readonly headerValuesMap;
|
|
2467
|
+
private finishedDeferred;
|
|
2468
|
+
private finishedSettled;
|
|
2469
|
+
private extraInfoHeaders;
|
|
2470
|
+
private extraInfoHeadersText;
|
|
2471
|
+
/**
|
|
2472
|
+
* Build a response wrapper from the CDP notification associated with a
|
|
2473
|
+
* navigation. The constructor captures the owning page/session so follow-up
|
|
2474
|
+
* methods (body/text/json) can query CDP on-demand. The `response` payload is
|
|
2475
|
+
* the raw `Protocol.Network.Response` object emitted by Chrome.
|
|
2476
|
+
*/
|
|
2477
|
+
constructor(params: {
|
|
2478
|
+
page: Page;
|
|
2479
|
+
session: CDPSessionLike;
|
|
2480
|
+
requestId: string;
|
|
2481
|
+
frameId?: string;
|
|
2482
|
+
loaderId?: string;
|
|
2483
|
+
response: Protocol.Network.Response;
|
|
2484
|
+
fromServiceWorker: boolean;
|
|
2485
|
+
});
|
|
2486
|
+
/** URL associated with the navigation request. */
|
|
2487
|
+
url(): string;
|
|
2488
|
+
/** HTTP status code reported by Chrome. */
|
|
2489
|
+
status(): number;
|
|
2490
|
+
/** Human-readable status text that accompanied the response. */
|
|
2491
|
+
statusText(): string;
|
|
2492
|
+
/** Convenience predicate that checks for 2xx statuses. */
|
|
2493
|
+
ok(): boolean;
|
|
2494
|
+
/** Returns the Stagehand frame object that initiated the navigation. */
|
|
2495
|
+
frame(): Frame | null;
|
|
2496
|
+
/** Indicates whether the response was serviced by a Service Worker. */
|
|
2497
|
+
fromServiceWorker(): boolean;
|
|
2498
|
+
/**
|
|
2499
|
+
* Returns TLS security metadata when provided by the browser. In practice
|
|
2500
|
+
* this includes certificate issuer, protocol, and validity interval.
|
|
2501
|
+
*/
|
|
2502
|
+
securityDetails(): Promise<Protocol.Network.SecurityDetails | null>;
|
|
2503
|
+
/** Returns the resolved server address for the navigation when available. */
|
|
2504
|
+
serverAddr(): Promise<ServerAddr | null>;
|
|
2505
|
+
/**
|
|
2506
|
+
* Returns the response headers normalised to lowercase keys. Matches the
|
|
2507
|
+
* behaviour of Playwright's `headers()` by eliding duplicate header entries.
|
|
2508
|
+
*/
|
|
2509
|
+
headers(): Record<string, string>;
|
|
2510
|
+
/**
|
|
2511
|
+
* Returns all headers including those only surfaced through
|
|
2512
|
+
* `responseReceivedExtraInfo` such as `set-cookie`. Values are reported as the
|
|
2513
|
+
* browser sends them (no further splitting or concatenation).
|
|
2514
|
+
*/
|
|
2515
|
+
allHeaders(): Promise<Record<string, string>>;
|
|
2516
|
+
/** Returns a concatenated header string for the supplied header name. */
|
|
2517
|
+
headerValue(name: string): Promise<string | null>;
|
|
2518
|
+
/** Returns all values for a header (case-insensitive lookup). */
|
|
2519
|
+
headerValues(name: string): Promise<string[]>;
|
|
2520
|
+
/**
|
|
2521
|
+
* Returns header entries preserving their original wire casing and ordering.
|
|
2522
|
+
* Falls back to the CDP object when the raw header text is unavailable.
|
|
2523
|
+
*/
|
|
2524
|
+
headersArray(): Promise<Array<{
|
|
2525
|
+
name: string;
|
|
2526
|
+
value: string;
|
|
2527
|
+
}>>;
|
|
2528
|
+
/**
|
|
2529
|
+
* Requests the raw response body from Chrome DevTools Protocol. The method is
|
|
2530
|
+
* intentionally lazy because not every caller needs the payload, and CDP only
|
|
2531
|
+
* allows retrieving it once the response completes.
|
|
2532
|
+
*/
|
|
2533
|
+
body(): Promise<Buffer>;
|
|
2534
|
+
/** Decodes the response body as UTF-8 text. */
|
|
2535
|
+
text(): Promise<string>;
|
|
2536
|
+
/** Parses the response body as JSON and throws if parsing fails. */
|
|
2537
|
+
json<T = unknown>(): Promise<T>;
|
|
2538
|
+
/**
|
|
2539
|
+
* Resolves once the underlying network request completes or fails. Mirrors
|
|
2540
|
+
* Playwright's behaviour by resolving to `null` on success and to an `Error`
|
|
2541
|
+
* instance when Chrome reports `Network.loadingFailed`.
|
|
2542
|
+
*/
|
|
2543
|
+
finished(): Promise<null | Error>;
|
|
2544
|
+
/**
|
|
2545
|
+
* Internal helper invoked by the navigation tracker when CDP reports extra
|
|
2546
|
+
* header information. This keeps the cached header views in sync with the
|
|
2547
|
+
* richer metadata.
|
|
2548
|
+
*/
|
|
2549
|
+
applyExtraInfo(event: Protocol.Network.ResponseReceivedExtraInfoEvent): void;
|
|
2550
|
+
/**
|
|
2551
|
+
* Internal helper for creating a Response object from a Serializable
|
|
2552
|
+
* goto response from the Stagehand API
|
|
2553
|
+
*/
|
|
2554
|
+
static fromSerializable(serialized: SerializableResponse, context: {
|
|
2555
|
+
page: Page;
|
|
2556
|
+
session: CDPSessionLike;
|
|
2557
|
+
}): Response$1;
|
|
2558
|
+
/** Marks the response as finished and resolves the `finished()` promise. */
|
|
2559
|
+
markFinished(error: Error | null): void;
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
type AnyPage = Page$1 | Page$2 | Page$3 | Page;
|
|
2563
|
+
|
|
2564
|
+
type LoadState = "load" | "domcontentloaded" | "networkidle";
|
|
2565
|
+
|
|
2566
|
+
type ScreenshotAnimationsOption = "disabled" | "allow";
|
|
2567
|
+
type ScreenshotCaretOption = "hide" | "initial";
|
|
2568
|
+
type ScreenshotScaleOption = "css" | "device";
|
|
2569
|
+
interface ScreenshotClip {
|
|
2570
|
+
x: number;
|
|
2571
|
+
y: number;
|
|
2572
|
+
width: number;
|
|
2573
|
+
height: number;
|
|
2574
|
+
}
|
|
2575
|
+
interface ScreenshotOptions {
|
|
2576
|
+
animations?: ScreenshotAnimationsOption;
|
|
2577
|
+
caret?: ScreenshotCaretOption;
|
|
2578
|
+
clip?: ScreenshotClip;
|
|
2579
|
+
fullPage?: boolean;
|
|
2580
|
+
mask?: Locator[];
|
|
2581
|
+
maskColor?: string;
|
|
2582
|
+
omitBackground?: boolean;
|
|
2583
|
+
path?: string;
|
|
2584
|
+
quality?: number;
|
|
2585
|
+
scale?: ScreenshotScaleOption;
|
|
2586
|
+
style?: string;
|
|
2587
|
+
timeout?: number;
|
|
2588
|
+
type?: "png" | "jpeg";
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
declare class Page {
|
|
2592
|
+
private readonly conn;
|
|
2593
|
+
private readonly mainSession;
|
|
2594
|
+
private readonly _targetId;
|
|
2595
|
+
/** Every CDP child session this page owns (top-level + adopted OOPIF sessions). */
|
|
2596
|
+
private readonly sessions;
|
|
2597
|
+
/** Unified truth for frame topology + ownership. */
|
|
2598
|
+
private readonly registry;
|
|
2599
|
+
/** A convenience wrapper bound to the current main frame id (top-level session). */
|
|
2600
|
+
private mainFrameWrapper;
|
|
2601
|
+
/** Compact ordinal per frameId (used by snapshot encoding). */
|
|
2602
|
+
private frameOrdinals;
|
|
2603
|
+
private nextOrdinal;
|
|
2604
|
+
/** cache Frames per frameId so everyone uses the same one */
|
|
2605
|
+
private readonly frameCache;
|
|
2606
|
+
private readonly browserIsRemote;
|
|
2607
|
+
/** Stable id for Frames created by this Page (use top-level TargetId). */
|
|
2608
|
+
private readonly pageId;
|
|
2609
|
+
/** Cached current URL for synchronous page.url() */
|
|
2610
|
+
private _currentUrl;
|
|
2611
|
+
private navigationCommandSeq;
|
|
2612
|
+
private latestNavigationCommandId;
|
|
2613
|
+
private readonly networkManager;
|
|
2614
|
+
/** Optional API client for routing page operations to the API */
|
|
2615
|
+
private readonly apiClient;
|
|
2616
|
+
private readonly consoleListeners;
|
|
2617
|
+
private readonly consoleHandlers;
|
|
2618
|
+
/** Document-start scripts installed across every session this page owns. */
|
|
2619
|
+
private readonly initScripts;
|
|
2620
|
+
private constructor();
|
|
2621
|
+
private installInitScriptOnSession;
|
|
2622
|
+
private applyInitScriptsToSession;
|
|
2623
|
+
registerInitScript(source: string): Promise<void>;
|
|
2624
|
+
private cursorEnabled;
|
|
2625
|
+
private ensureCursorScript;
|
|
2626
|
+
enableCursorOverlay(): Promise<void>;
|
|
2627
|
+
private updateCursor;
|
|
2628
|
+
addInitScript<Arg>(script: InitScriptSource<Arg>, arg?: Arg): Promise<void>;
|
|
2629
|
+
/**
|
|
2630
|
+
* Factory: create Page and seed registry with the shallow tree from Page.getFrameTree.
|
|
2631
|
+
* Assumes Page domain is already enabled on the session passed in.
|
|
2632
|
+
*/
|
|
2633
|
+
static create(conn: CdpConnection, session: CDPSessionLike, targetId: string, apiClient?: StagehandAPIClient | null, localBrowserLaunchOptions?: LocalBrowserLaunchOptions | null, browserIsRemote?: boolean): Promise<Page>;
|
|
2634
|
+
/**
|
|
2635
|
+
* Parent/child session emitted a `frameAttached`.
|
|
2636
|
+
* Topology update + ownership stamped to **emitting session**.
|
|
2637
|
+
*/
|
|
2638
|
+
onFrameAttached(frameId: string, parentId: string | null, session: CDPSessionLike): void;
|
|
2639
|
+
/**
|
|
2640
|
+
* Parent/child session emitted a `frameDetached`.
|
|
2641
|
+
*/
|
|
2642
|
+
onFrameDetached(frameId: string, reason?: "remove" | "swap" | string): void;
|
|
2643
|
+
/**
|
|
2644
|
+
* Parent/child session emitted a `frameNavigated`.
|
|
2645
|
+
* Topology + ownership update. Handles root swaps.
|
|
2646
|
+
*/
|
|
2647
|
+
onFrameNavigated(frame: Protocol.Page.Frame, session: CDPSessionLike): void;
|
|
2648
|
+
onNavigatedWithinDocument(frameId: string, url: string, session: CDPSessionLike): void;
|
|
2649
|
+
/**
|
|
2650
|
+
* An OOPIF child session whose **main** frame id equals the parent iframe’s frameId
|
|
2651
|
+
* has been attached; adopt the session into this Page and seed ownership for its subtree.
|
|
2652
|
+
*/
|
|
2653
|
+
adoptOopifSession(childSession: CDPSessionLike, childMainFrameId: string): void;
|
|
2654
|
+
/** Detach an adopted child session and prune its subtree */
|
|
2655
|
+
detachOopifSession(sessionId: string): void;
|
|
2656
|
+
/** Return the owning CDP session for a frameId (falls back to main session) */
|
|
2657
|
+
getSessionForFrame(frameId: string): CDPSessionLike;
|
|
2658
|
+
/** Always returns a Frame bound to the owning session */
|
|
2659
|
+
frameForId(frameId: string): Frame;
|
|
2660
|
+
/** Expose a session by id (used by snapshot to resolve session id -> session) */
|
|
2661
|
+
getSessionById(id: string): CDPSessionLike | undefined;
|
|
2662
|
+
registerSessionForNetwork(session: CDPSessionLike): void;
|
|
2663
|
+
unregisterSessionForNetwork(sessionId: string | undefined): void;
|
|
2664
|
+
on(event: "console", listener: ConsoleListener): Page;
|
|
2665
|
+
once(event: "console", listener: ConsoleListener): Page;
|
|
2666
|
+
off(event: "console", listener: ConsoleListener): Page;
|
|
2667
|
+
targetId(): string;
|
|
2668
|
+
/**
|
|
2669
|
+
* Send a CDP command through the main session.
|
|
2670
|
+
* Allows external consumers to execute arbitrary Chrome DevTools Protocol commands.
|
|
2671
|
+
*
|
|
2672
|
+
* @param method - The CDP method name (e.g., "Page.enable", "Runtime.evaluate")
|
|
2673
|
+
* @param params - Optional parameters for the CDP command
|
|
2674
|
+
* @returns Promise resolving to the typed CDP response
|
|
2675
|
+
*
|
|
2676
|
+
* @example
|
|
2677
|
+
* // Enable the Runtime domain
|
|
2678
|
+
* await page.sendCDP("Runtime.enable");
|
|
2679
|
+
*
|
|
2680
|
+
* @example
|
|
2681
|
+
* // Evaluate JavaScript with typed response
|
|
2682
|
+
* const result = await page.sendCDP<Protocol.Runtime.EvaluateResponse>(
|
|
2683
|
+
* "Runtime.evaluate",
|
|
2684
|
+
* { expression: "1 + 1" }
|
|
2685
|
+
* );
|
|
2686
|
+
*/
|
|
2687
|
+
sendCDP<T = unknown>(method: string, params?: object): Promise<T>;
|
|
2688
|
+
/** Seed the cached URL before navigation events converge. */
|
|
2689
|
+
seedCurrentUrl(url: string | undefined | null): void;
|
|
2690
|
+
mainFrameId(): string;
|
|
2691
|
+
mainFrame(): Frame;
|
|
2692
|
+
/**
|
|
2693
|
+
* Close this top-level page (tab). Best-effort via Target.closeTarget.
|
|
2694
|
+
*/
|
|
2695
|
+
close(): Promise<void>;
|
|
2696
|
+
getFullFrameTree(): Protocol.Page.FrameTree;
|
|
2697
|
+
asProtocolFrameTree(rootMainFrameId: string): Protocol.Page.FrameTree;
|
|
2698
|
+
private ensureOrdinal;
|
|
2699
|
+
/** Public getter for snapshot code / handlers. */
|
|
2700
|
+
getOrdinal(frameId: string): number;
|
|
2701
|
+
listAllFrameIds(): string[];
|
|
2702
|
+
private ensureConsoleTaps;
|
|
2703
|
+
private installConsoleTap;
|
|
2704
|
+
private sessionKey;
|
|
2705
|
+
private resolveSessionByKey;
|
|
2706
|
+
private teardownConsoleTap;
|
|
2707
|
+
private removeAllConsoleTaps;
|
|
2708
|
+
private emitConsole;
|
|
2709
|
+
/**
|
|
2710
|
+
* Navigate the page; optionally wait for a lifecycle state.
|
|
2711
|
+
* Waits on the **current** main frame and follows root swaps during navigation.
|
|
2712
|
+
*/
|
|
2713
|
+
goto(url: string, options?: {
|
|
2714
|
+
waitUntil?: LoadState;
|
|
2715
|
+
timeoutMs?: number;
|
|
2716
|
+
}): Promise<Response$1 | null>;
|
|
2717
|
+
/**
|
|
2718
|
+
* Reload the page; optionally wait for a lifecycle state.
|
|
2719
|
+
*/
|
|
2720
|
+
reload(options?: {
|
|
2721
|
+
waitUntil?: LoadState;
|
|
2722
|
+
timeoutMs?: number;
|
|
2723
|
+
ignoreCache?: boolean;
|
|
2724
|
+
}): Promise<Response$1 | null>;
|
|
2725
|
+
/**
|
|
2726
|
+
* Navigate back in history if possible; optionally wait for a lifecycle state.
|
|
2727
|
+
*/
|
|
2728
|
+
goBack(options?: {
|
|
2729
|
+
waitUntil?: LoadState;
|
|
2730
|
+
timeoutMs?: number;
|
|
2731
|
+
}): Promise<Response$1 | null>;
|
|
2732
|
+
/**
|
|
2733
|
+
* Navigate forward in history if possible; optionally wait for a lifecycle state.
|
|
2734
|
+
*/
|
|
2735
|
+
goForward(options?: {
|
|
2736
|
+
waitUntil?: LoadState;
|
|
2737
|
+
timeoutMs?: number;
|
|
2738
|
+
}): Promise<Response$1 | null>;
|
|
2739
|
+
/**
|
|
2740
|
+
* Return the current page URL (synchronous, cached from navigation events).
|
|
2741
|
+
*/
|
|
2742
|
+
url(): string;
|
|
2743
|
+
private beginNavigationCommand;
|
|
2744
|
+
isCurrentNavigationCommand(id: number): boolean;
|
|
2745
|
+
/**
|
|
2746
|
+
* Return the current page title.
|
|
2747
|
+
* Prefers reading from the active document via Runtime.evaluate to reflect dynamic changes.
|
|
2748
|
+
* Falls back to navigation history title if evaluation is unavailable.
|
|
2749
|
+
*/
|
|
2750
|
+
title(): Promise<string>;
|
|
2751
|
+
/**
|
|
2752
|
+
* Capture a screenshot with Playwright-style options.
|
|
2753
|
+
*
|
|
2754
|
+
* @param options Optional screenshot configuration.
|
|
2755
|
+
* @param options.animations Control CSS/Web animations during capture. Use
|
|
2756
|
+
* "disabled" to fast-forward finite animations and pause infinite ones.
|
|
2757
|
+
* @param options.caret Either hide the text caret (default) or leave it
|
|
2758
|
+
* visible via "initial".
|
|
2759
|
+
* @param options.clip Restrict capture to a specific rectangle (in CSS
|
|
2760
|
+
* pixels). Cannot be combined with `fullPage`.
|
|
2761
|
+
* @param options.fullPage Capture the full scrollable page instead of the
|
|
2762
|
+
* current viewport.
|
|
2763
|
+
* @param options.mask Array of locators that should be covered with an
|
|
2764
|
+
* overlay while the screenshot is taken.
|
|
2765
|
+
* @param options.maskColor CSS color used for the mask overlay (default
|
|
2766
|
+
* `#FF00FF`).
|
|
2767
|
+
* @param options.omitBackground Make the default page background transparent
|
|
2768
|
+
* (PNG only).
|
|
2769
|
+
* @param options.path File path to write the screenshot to. The file extension
|
|
2770
|
+
* determines the image type when `type` is not explicitly provided.
|
|
2771
|
+
* @param options.quality JPEG quality (0–100). Only applies when
|
|
2772
|
+
* `type === "jpeg"`.
|
|
2773
|
+
* @param options.scale Render scale: use "css" for one pixel per CSS pixel,
|
|
2774
|
+
* otherwise the default "device" leverages the current device pixel ratio.
|
|
2775
|
+
* @param options.style Additional CSS text injected into every frame before
|
|
2776
|
+
* capture (removed afterwards).
|
|
2777
|
+
* @param options.timeout Maximum capture duration in milliseconds before a
|
|
2778
|
+
* timeout error is thrown.
|
|
2779
|
+
* @param options.type Image format (`"png"` by default).
|
|
2780
|
+
*/
|
|
2781
|
+
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
2782
|
+
/**
|
|
2783
|
+
* Create a locator bound to the current main frame.
|
|
2784
|
+
*/
|
|
2785
|
+
locator(selector: string): ReturnType<Frame["locator"]>;
|
|
2786
|
+
/**
|
|
2787
|
+
* Deep locator that supports cross-iframe traversal.
|
|
2788
|
+
* - Recognizes '>>' hop notation to enter iframe contexts.
|
|
2789
|
+
* - Supports deep XPath that includes iframe steps (e.g., '/html/body/iframe[2]//div').
|
|
2790
|
+
* Returns a Locator scoped to the appropriate frame.
|
|
2791
|
+
*/
|
|
2792
|
+
deepLocator(selector: string): DeepLocatorDelegate;
|
|
2793
|
+
/**
|
|
2794
|
+
* Frame locator similar to Playwright: targets iframe elements and scopes
|
|
2795
|
+
* subsequent locators to that frame. Supports chaining.
|
|
2796
|
+
*/
|
|
2797
|
+
frameLocator(selector: string): FrameLocator;
|
|
2798
|
+
/**
|
|
2799
|
+
* List all frames belonging to this page as Frame objects bound to their owning sessions.
|
|
2800
|
+
* The list is ordered by a stable ordinal assigned during the page lifetime.
|
|
2801
|
+
*/
|
|
2802
|
+
frames(): Frame[];
|
|
2803
|
+
/**
|
|
2804
|
+
* Wait until the page reaches a lifecycle state on the current main frame.
|
|
2805
|
+
* Mirrors Playwright's API signatures.
|
|
2806
|
+
*/
|
|
2807
|
+
waitForLoadState(state: LoadState, timeoutMs?: number): Promise<void>;
|
|
2808
|
+
/**
|
|
2809
|
+
* Wait for a specified amount of time.
|
|
2810
|
+
*
|
|
2811
|
+
* @param ms The number of milliseconds to wait.
|
|
2812
|
+
*/
|
|
2813
|
+
waitForTimeout(ms: number): Promise<void>;
|
|
2814
|
+
/**
|
|
2815
|
+
* Evaluate a function or expression in the current main frame's main world.
|
|
2816
|
+
* - If a string is provided, it is treated as a JS expression.
|
|
2817
|
+
* - If a function is provided, it is stringified and invoked with the optional argument.
|
|
2818
|
+
* - The return value should be JSON-serializable. Non-serializable objects will
|
|
2819
|
+
* best-effort serialize via JSON.stringify inside the page context.
|
|
2820
|
+
*/
|
|
2821
|
+
evaluate<R = unknown, Arg = unknown>(pageFunctionOrExpression: string | ((arg: Arg) => R | Promise<R>), arg?: Arg): Promise<R>;
|
|
2822
|
+
/**
|
|
2823
|
+
* Force the page viewport to an exact CSS size and device scale factor.
|
|
2824
|
+
* Ensures screenshots match width x height pixels when deviceScaleFactor = 1.
|
|
2825
|
+
*/
|
|
2826
|
+
setViewportSize(width: number, height: number, options?: {
|
|
2827
|
+
deviceScaleFactor?: number;
|
|
2828
|
+
}): Promise<void>;
|
|
2829
|
+
/**
|
|
2830
|
+
* Click at absolute page coordinates (CSS pixels).
|
|
2831
|
+
* Dispatches mouseMoved → mousePressed → mouseReleased via CDP Input domain
|
|
2832
|
+
* on the top-level page target's session. Coordinates are relative to the
|
|
2833
|
+
* viewport origin (top-left). Does not scroll.
|
|
2834
|
+
*/
|
|
2835
|
+
click(x: number, y: number, options?: {
|
|
2836
|
+
button?: "left" | "right" | "middle";
|
|
2837
|
+
clickCount?: number;
|
|
2838
|
+
returnXpath?: boolean;
|
|
2839
|
+
}): Promise<string>;
|
|
2840
|
+
/**
|
|
2841
|
+
* Hover at absolute page coordinates (CSS pixels).
|
|
2842
|
+
* Dispatches mouseMoved via CDP Input domain on the top-level page target's
|
|
2843
|
+
* session.
|
|
2844
|
+
*/
|
|
2845
|
+
hover(x: number, y: number, options?: {
|
|
2846
|
+
returnXpath?: boolean;
|
|
2847
|
+
}): Promise<string>;
|
|
2848
|
+
scroll(x: number, y: number, deltaX: number, deltaY: number, options?: {
|
|
2849
|
+
returnXpath?: boolean;
|
|
2850
|
+
}): Promise<string>;
|
|
2851
|
+
/**
|
|
2852
|
+
* Drag from (fromX, fromY) to (toX, toY) using mouse events.
|
|
2853
|
+
* Sends mouseMoved → mousePressed → mouseMoved (steps) → mouseReleased.
|
|
2854
|
+
*/
|
|
2855
|
+
dragAndDrop(fromX: number, fromY: number, toX: number, toY: number, options?: {
|
|
2856
|
+
button?: "left" | "right" | "middle";
|
|
2857
|
+
steps?: number;
|
|
2858
|
+
delay?: number;
|
|
2859
|
+
returnXpath?: boolean;
|
|
2860
|
+
}): Promise<[string, string]>;
|
|
2861
|
+
/**
|
|
2862
|
+
* Type a string by dispatching keyDown/keyUp events per character.
|
|
2863
|
+
* Focus must already be on the desired element. Uses CDP Input.dispatchKeyEvent
|
|
2864
|
+
* and never falls back to Input.insertText. Optional delay applies between
|
|
2865
|
+
* successive characters.
|
|
2866
|
+
*/
|
|
2867
|
+
type(text: string, options?: {
|
|
2868
|
+
delay?: number;
|
|
2869
|
+
withMistakes?: boolean;
|
|
2870
|
+
}): Promise<void>;
|
|
2871
|
+
/**
|
|
2872
|
+
* Press a single key or key combination (keyDown then keyUp).
|
|
2873
|
+
* For printable characters, uses the text path on keyDown; for named keys, sets key/code/VK.
|
|
2874
|
+
* Supports key combinations with modifiers like "Cmd+A", "Ctrl+C", "Shift+Tab", etc.
|
|
2875
|
+
*/
|
|
2876
|
+
keyPress(key: string, options?: {
|
|
2877
|
+
delay?: number;
|
|
2878
|
+
}): Promise<void>;
|
|
2879
|
+
private _pressedModifiers;
|
|
2880
|
+
/** Press a key down without releasing it */
|
|
2881
|
+
private keyDown;
|
|
2882
|
+
/** Release a pressed key */
|
|
2883
|
+
private keyUp;
|
|
2884
|
+
/** Normalize key names to match CDP expectations */
|
|
2885
|
+
private normalizeModifierKey;
|
|
2886
|
+
/**
|
|
2887
|
+
* Get the map of named keys with their properties
|
|
2888
|
+
*/
|
|
2889
|
+
private getNamedKeys;
|
|
2890
|
+
/**
|
|
2891
|
+
* Minimal description for printable keys (letters/digits/space) to provide code and VK.
|
|
2892
|
+
* Used when non-Shift modifiers are pressed to avoid sending text while keeping accelerator info.
|
|
2893
|
+
*/
|
|
2894
|
+
private describePrintableKey;
|
|
2895
|
+
private isMacOS;
|
|
2896
|
+
/**
|
|
2897
|
+
* Return Chromium mac editing commands (without trailing ':') for a given code like 'KeyA'
|
|
2898
|
+
* Only used on macOS to trigger system editing shortcuts (e.g., selectAll, copy, paste...).
|
|
2899
|
+
*/
|
|
2900
|
+
private macCommandsFor;
|
|
2901
|
+
/** Resolve the main-world execution context for the current main frame. */
|
|
2902
|
+
private mainWorldExecutionContextId;
|
|
2903
|
+
/**
|
|
2904
|
+
* Wait until the **current** main frame reaches a lifecycle state.
|
|
2905
|
+
* - Fast path via `document.readyState`.
|
|
2906
|
+
* - Event path listens at the session level and compares incoming `frameId`
|
|
2907
|
+
* to `mainFrameId()` **at event time** to follow root swaps.
|
|
2908
|
+
*/
|
|
2909
|
+
waitForMainLoadState(state: LoadState, timeoutMs?: number): Promise<void>;
|
|
2910
|
+
}
|
|
2911
|
+
|
|
2912
|
+
interface AgentContext {
|
|
2913
|
+
options: AgentExecuteOptionsBase;
|
|
2914
|
+
maxSteps: number;
|
|
2915
|
+
systemPrompt: string;
|
|
2916
|
+
allTools: ToolSet;
|
|
2917
|
+
messages: ModelMessage[];
|
|
2918
|
+
wrappedModel: ReturnType<typeof wrapLanguageModel>;
|
|
2919
|
+
initialPageUrl: string;
|
|
2920
|
+
}
|
|
2921
|
+
interface AgentState {
|
|
2922
|
+
collectedReasoning: string[];
|
|
2923
|
+
actions: AgentAction[];
|
|
2924
|
+
finalMessage: string;
|
|
2925
|
+
completed: boolean;
|
|
2926
|
+
currentPageUrl: string;
|
|
2927
|
+
}
|
|
2928
|
+
interface AgentAction {
|
|
2929
|
+
type: string;
|
|
2930
|
+
reasoning?: string;
|
|
2931
|
+
taskCompleted?: boolean;
|
|
2932
|
+
action?: string;
|
|
2933
|
+
timeMs?: number;
|
|
2934
|
+
pageText?: string;
|
|
2935
|
+
pageUrl?: string;
|
|
2936
|
+
instruction?: string;
|
|
2937
|
+
[key: string]: unknown;
|
|
2938
|
+
}
|
|
2939
|
+
interface AgentResult {
|
|
2940
|
+
success: boolean;
|
|
2941
|
+
message: string;
|
|
2942
|
+
actions: AgentAction[];
|
|
2943
|
+
completed: boolean;
|
|
2944
|
+
metadata?: Record<string, unknown>;
|
|
2945
|
+
usage?: {
|
|
2946
|
+
input_tokens: number;
|
|
2947
|
+
output_tokens: number;
|
|
2948
|
+
reasoning_tokens?: number;
|
|
2949
|
+
cached_input_tokens?: number;
|
|
2950
|
+
inference_time_ms: number;
|
|
2951
|
+
};
|
|
2952
|
+
/**
|
|
2953
|
+
* The conversation messages from this execution.
|
|
2954
|
+
* Pass these to a subsequent execute() call via the `messages` option to continue the conversation.
|
|
2955
|
+
* @experimental
|
|
2956
|
+
*/
|
|
2957
|
+
messages?: ModelMessage[];
|
|
2958
|
+
}
|
|
2959
|
+
type AgentStreamResult = StreamTextResult<ToolSet, never> & {
|
|
2960
|
+
result: Promise<AgentResult>;
|
|
2961
|
+
};
|
|
2962
|
+
/**
|
|
2963
|
+
* Base callbacks shared between execute (non-streaming) and streaming modes.
|
|
2964
|
+
*/
|
|
2965
|
+
interface AgentCallbacks {
|
|
2966
|
+
/**
|
|
2967
|
+
* Optional function called before each step to modify settings.
|
|
2968
|
+
* You can change the model, tool choices, active tools, system prompt,
|
|
2969
|
+
* and input messages for each step.
|
|
2970
|
+
*/
|
|
2971
|
+
prepareStep?: PrepareStepFunction<ToolSet>;
|
|
2972
|
+
/**
|
|
2973
|
+
* Callback called when each step (LLM call) is finished.
|
|
2974
|
+
* This is called for intermediate steps as well as the final step.
|
|
2975
|
+
*/
|
|
2976
|
+
onStepFinish?: GenerateTextOnStepFinishCallback<ToolSet> | StreamTextOnStepFinishCallback<ToolSet>;
|
|
2977
|
+
}
|
|
2978
|
+
/**
|
|
2979
|
+
* Error message type for streaming-only callbacks used in non-streaming mode.
|
|
2980
|
+
* This provides a clear error message when users try to use streaming callbacks without stream: true.
|
|
2981
|
+
*/
|
|
2982
|
+
type StreamingCallbackNotAvailable = "This callback requires 'stream: true' in AgentConfig. Set stream: true to use streaming callbacks like onChunk, onFinish, onError, and onAbort.";
|
|
2983
|
+
/**
|
|
2984
|
+
* Error message for safety confirmation callback misuse.
|
|
2985
|
+
* Safety confirmations are only available for non-streaming CUA agent executions.
|
|
2986
|
+
*/
|
|
2987
|
+
type SafetyConfirmationCallbackNotAvailable = "Safety confirmation callbacks are only available via non-streaming AgentExecuteOptions.callbacks when using mode: 'cua'.";
|
|
2988
|
+
/**
|
|
2989
|
+
* Callbacks specific to the non-streaming execute method.
|
|
2990
|
+
*/
|
|
2991
|
+
interface AgentExecuteCallbacks extends AgentCallbacks {
|
|
2992
|
+
/**
|
|
2993
|
+
* Callback called when each step (LLM call) is finished.
|
|
2994
|
+
*/
|
|
2995
|
+
onStepFinish?: GenerateTextOnStepFinishCallback<ToolSet>;
|
|
2996
|
+
/**
|
|
2997
|
+
* Callback for handling safety confirmation requests from CUA providers.
|
|
2998
|
+
* Only available when running an agent configured with mode: "cua".
|
|
2999
|
+
*/
|
|
3000
|
+
onSafetyConfirmation?: SafetyConfirmationHandler;
|
|
3001
|
+
/**
|
|
3002
|
+
* NOT AVAILABLE in non-streaming mode.
|
|
3003
|
+
* This callback requires `stream: true` in AgentConfig.
|
|
3004
|
+
*
|
|
3005
|
+
* @example
|
|
3006
|
+
* ```typescript
|
|
3007
|
+
* // Enable streaming to use onChunk:
|
|
3008
|
+
* const agent = stagehand.agent({ stream: true });
|
|
3009
|
+
* await agent.execute({
|
|
3010
|
+
* instruction: "...",
|
|
3011
|
+
* callbacks: { onChunk: async (chunk) => console.log(chunk) }
|
|
3012
|
+
* });
|
|
3013
|
+
* ```
|
|
3014
|
+
*/
|
|
3015
|
+
onChunk?: StreamingCallbackNotAvailable;
|
|
3016
|
+
/**
|
|
3017
|
+
* NOT AVAILABLE in non-streaming mode.
|
|
3018
|
+
* This callback requires `stream: true` in AgentConfig.
|
|
3019
|
+
*
|
|
3020
|
+
* @example
|
|
3021
|
+
* ```typescript
|
|
3022
|
+
* // Enable streaming to use onFinish:
|
|
3023
|
+
* const agent = stagehand.agent({ stream: true });
|
|
3024
|
+
* await agent.execute({
|
|
3025
|
+
* instruction: "...",
|
|
3026
|
+
* callbacks: { onFinish: (event) => console.log("Done!", event) }
|
|
3027
|
+
* });
|
|
3028
|
+
* ```
|
|
3029
|
+
*/
|
|
3030
|
+
onFinish?: StreamingCallbackNotAvailable;
|
|
3031
|
+
/**
|
|
3032
|
+
* NOT AVAILABLE in non-streaming mode.
|
|
3033
|
+
* This callback requires `stream: true` in AgentConfig.
|
|
3034
|
+
*
|
|
3035
|
+
* @example
|
|
3036
|
+
* ```typescript
|
|
3037
|
+
* // Enable streaming to use onError:
|
|
3038
|
+
* const agent = stagehand.agent({ stream: true });
|
|
3039
|
+
* await agent.execute({
|
|
3040
|
+
* instruction: "...",
|
|
3041
|
+
* callbacks: { onError: ({ error }) => console.error(error) }
|
|
3042
|
+
* });
|
|
3043
|
+
* ```
|
|
3044
|
+
*/
|
|
3045
|
+
onError?: StreamingCallbackNotAvailable;
|
|
3046
|
+
/**
|
|
3047
|
+
* NOT AVAILABLE in non-streaming mode.
|
|
3048
|
+
* This callback requires `stream: true` in AgentConfig.
|
|
3049
|
+
*
|
|
3050
|
+
* @example
|
|
3051
|
+
* ```typescript
|
|
3052
|
+
* // Enable streaming to use onAbort:
|
|
3053
|
+
* const agent = stagehand.agent({ stream: true });
|
|
3054
|
+
* await agent.execute({
|
|
3055
|
+
* instruction: "...",
|
|
3056
|
+
* callbacks: { onAbort: (event) => console.log("Aborted", event.steps) }
|
|
3057
|
+
* });
|
|
3058
|
+
* ```
|
|
3059
|
+
*/
|
|
3060
|
+
onAbort?: StreamingCallbackNotAvailable;
|
|
3061
|
+
}
|
|
3062
|
+
/**
|
|
3063
|
+
* Callbacks specific to the streaming mode.
|
|
3064
|
+
*/
|
|
3065
|
+
interface AgentStreamCallbacks extends AgentCallbacks {
|
|
3066
|
+
/**
|
|
3067
|
+
* Callback called when each step (LLM call) is finished during streaming.
|
|
3068
|
+
*/
|
|
3069
|
+
onStepFinish?: StreamTextOnStepFinishCallback<ToolSet>;
|
|
3070
|
+
/**
|
|
3071
|
+
* Callback called when an error occurs during streaming.
|
|
3072
|
+
* Use this to log errors or handle error states.
|
|
3073
|
+
*/
|
|
3074
|
+
onError?: StreamTextOnErrorCallback;
|
|
3075
|
+
/**
|
|
3076
|
+
* Callback called for each chunk of the stream.
|
|
3077
|
+
* Stream processing will pause until the callback promise resolves.
|
|
3078
|
+
*/
|
|
3079
|
+
onChunk?: StreamTextOnChunkCallback<ToolSet>;
|
|
3080
|
+
/**
|
|
3081
|
+
* Callback called when the stream finishes.
|
|
3082
|
+
*/
|
|
3083
|
+
onFinish?: StreamTextOnFinishCallback<ToolSet>;
|
|
3084
|
+
/**
|
|
3085
|
+
* Callback called when the stream is aborted.
|
|
3086
|
+
*/
|
|
3087
|
+
onAbort?: (event: {
|
|
3088
|
+
steps: Array<StepResult<ToolSet>>;
|
|
3089
|
+
}) => PromiseLike<void> | void;
|
|
3090
|
+
/**
|
|
3091
|
+
* NOT AVAILABLE in streaming mode.
|
|
3092
|
+
* Safety confirmations currently require non-streaming execute() on CUA agents.
|
|
3093
|
+
*/
|
|
3094
|
+
onSafetyConfirmation?: SafetyConfirmationCallbackNotAvailable;
|
|
3095
|
+
}
|
|
3096
|
+
/**
|
|
3097
|
+
* Base options for agent execution (without callbacks).
|
|
3098
|
+
*/
|
|
3099
|
+
interface AgentExecuteOptionsBase {
|
|
3100
|
+
instruction: string;
|
|
3101
|
+
maxSteps?: number;
|
|
3102
|
+
page?: Page$1 | Page$2 | Page$3 | Page;
|
|
3103
|
+
highlightCursor?: boolean;
|
|
3104
|
+
/**
|
|
3105
|
+
* Previous conversation messages to continue from.
|
|
3106
|
+
* Pass the `messages` from a previous AgentResult to continue that conversation.
|
|
3107
|
+
* @experimental
|
|
3108
|
+
*/
|
|
3109
|
+
messages?: ModelMessage[];
|
|
3110
|
+
/**
|
|
3111
|
+
* An AbortSignal that can be used to cancel the agent execution.
|
|
3112
|
+
* When aborted, the agent will stop and return a partial result.
|
|
3113
|
+
* @experimental
|
|
3114
|
+
*
|
|
3115
|
+
* @example
|
|
3116
|
+
* ```typescript
|
|
3117
|
+
* const controller = new AbortController();
|
|
3118
|
+
* setTimeout(() => controller.abort(), 30000); // 30 second timeout
|
|
3119
|
+
*
|
|
3120
|
+
* const result = await agent.execute({
|
|
3121
|
+
* instruction: "...",
|
|
3122
|
+
* signal: controller.signal
|
|
3123
|
+
* });
|
|
3124
|
+
* ```
|
|
3125
|
+
*/
|
|
3126
|
+
signal?: AbortSignal;
|
|
3127
|
+
/**
|
|
3128
|
+
* Tools to exclude from this execution.
|
|
3129
|
+
* Pass an array of tool names to prevent the agent from using those tools.
|
|
3130
|
+
*
|
|
3131
|
+
* **Note:** Not supported in CUA mode (`mode: "cua"`).
|
|
3132
|
+
*
|
|
3133
|
+
* **Available tools by mode:**
|
|
3134
|
+
*
|
|
3135
|
+
* **DOM mode (default):**
|
|
3136
|
+
* - `act` - Perform semantic actions (click, type, etc.)
|
|
3137
|
+
* - `fillForm` - Fill form fields using DOM selectors
|
|
3138
|
+
* - `ariaTree` - Get accessibility tree of the page
|
|
3139
|
+
* - `extract` - Extract structured data from page
|
|
3140
|
+
* - `goto` - Navigate to a URL
|
|
3141
|
+
* - `scroll` - Scroll using semantic directions (up/down/left/right)
|
|
3142
|
+
* - `keys` - Press keyboard keys
|
|
3143
|
+
* - `navback` - Navigate back in history
|
|
3144
|
+
* - `screenshot` - Take a screenshot
|
|
3145
|
+
* - `think` - Agent reasoning/planning step
|
|
3146
|
+
* - `wait` - Wait for time or condition
|
|
3147
|
+
* - `close` - Mark task as complete
|
|
3148
|
+
* - `search` - Web search (requires BRAVE_API_KEY)
|
|
3149
|
+
*
|
|
3150
|
+
* **Hybrid mode:**
|
|
3151
|
+
* - `click` - Click at specific coordinates
|
|
3152
|
+
* - `type` - Type text at coordinates
|
|
3153
|
+
* - `dragAndDrop` - Drag from one point to another
|
|
3154
|
+
* - `clickAndHold` - Click and hold at coordinates
|
|
3155
|
+
* - `fillFormVision` - Fill forms using vision/coordinates
|
|
3156
|
+
* - `act` - Perform semantic actions
|
|
3157
|
+
* - `ariaTree` - Get accessibility tree
|
|
3158
|
+
* - `extract` - Extract data from page
|
|
3159
|
+
* - `goto` - Navigate to URL
|
|
3160
|
+
* - `scroll` - Scroll using coordinates
|
|
3161
|
+
* - `keys` - Press keyboard keys
|
|
3162
|
+
* - `navback` - Navigate back
|
|
3163
|
+
* - `screenshot` - Take screenshot
|
|
3164
|
+
* - `think` - Agent reasoning step
|
|
3165
|
+
* - `wait` - Wait for time/condition
|
|
3166
|
+
* - `close` - Mark task complete
|
|
3167
|
+
* - `search` - Web search (requires BRAVE_API_KEY)
|
|
3168
|
+
*
|
|
3169
|
+
* @experimental
|
|
3170
|
+
* @example
|
|
3171
|
+
* ```typescript
|
|
3172
|
+
* // Exclude screenshot and extract tools
|
|
3173
|
+
* const result = await agent.execute({
|
|
3174
|
+
* instruction: "Click the submit button",
|
|
3175
|
+
* excludeTools: ["screenshot", "extract"]
|
|
3176
|
+
* });
|
|
3177
|
+
* ```
|
|
3178
|
+
*/
|
|
3179
|
+
excludeTools?: string[];
|
|
3180
|
+
}
|
|
3181
|
+
/**
|
|
3182
|
+
* Options for non-streaming agent execution.
|
|
3183
|
+
* Only accepts AgentExecuteCallbacks (no streaming-specific callbacks like onChunk, onFinish).
|
|
3184
|
+
*/
|
|
3185
|
+
interface AgentExecuteOptions extends AgentExecuteOptionsBase {
|
|
3186
|
+
/**
|
|
3187
|
+
* Callbacks for non-streaming agent execution.
|
|
3188
|
+
* For streaming callbacks (onChunk, onFinish, onError, onAbort), use stream: true in AgentConfig.
|
|
3189
|
+
*/
|
|
3190
|
+
callbacks?: AgentExecuteCallbacks;
|
|
3191
|
+
}
|
|
3192
|
+
/**
|
|
3193
|
+
* Options for streaming agent execution.
|
|
3194
|
+
* Accepts AgentStreamCallbacks including onChunk, onFinish, onError, and onAbort.
|
|
3195
|
+
*/
|
|
3196
|
+
interface AgentStreamExecuteOptions extends AgentExecuteOptionsBase {
|
|
3197
|
+
/**
|
|
3198
|
+
* Callbacks for streaming agent execution.
|
|
3199
|
+
* Includes streaming-specific callbacks: onChunk, onFinish, onError, onAbort.
|
|
3200
|
+
*/
|
|
3201
|
+
callbacks?: AgentStreamCallbacks;
|
|
3202
|
+
}
|
|
3203
|
+
type AgentType = "openai" | "anthropic" | "google" | "microsoft";
|
|
3204
|
+
declare const AVAILABLE_CUA_MODELS: readonly ["openai/computer-use-preview", "openai/computer-use-preview-2025-03-11", "anthropic/claude-3-7-sonnet-latest", "anthropic/claude-opus-4-5-20251101", "anthropic/claude-haiku-4-5-20251001", "anthropic/claude-sonnet-4-20250514", "anthropic/claude-sonnet-4-5-20250929", "google/gemini-2.5-computer-use-preview-10-2025", "microsoft/fara-7b"];
|
|
3205
|
+
type AvailableCuaModel = (typeof AVAILABLE_CUA_MODELS)[number];
|
|
3206
|
+
interface AgentExecutionOptions<TOptions extends AgentExecuteOptions = AgentExecuteOptions> {
|
|
3207
|
+
options: TOptions;
|
|
3208
|
+
logger: (message: LogLine) => void;
|
|
3209
|
+
retries?: number;
|
|
3210
|
+
}
|
|
3211
|
+
interface AgentHandlerOptions {
|
|
3212
|
+
modelName: string;
|
|
3213
|
+
clientOptions?: ClientOptions;
|
|
3214
|
+
userProvidedInstructions?: string;
|
|
3215
|
+
experimental?: boolean;
|
|
3216
|
+
}
|
|
3217
|
+
interface ActionExecutionResult {
|
|
3218
|
+
success: boolean;
|
|
3219
|
+
error?: string;
|
|
3220
|
+
data?: unknown;
|
|
3221
|
+
}
|
|
3222
|
+
/**
|
|
3223
|
+
* Represents a safety check that requires user confirmation before proceeding.
|
|
3224
|
+
* These are issued by CUA providers (OpenAI, Google) when the agent attempts
|
|
3225
|
+
* potentially risky actions.
|
|
3226
|
+
*/
|
|
3227
|
+
interface SafetyCheck {
|
|
3228
|
+
/** Unique identifier for this safety check */
|
|
3229
|
+
id: string;
|
|
3230
|
+
/** Code identifying the type of safety concern */
|
|
3231
|
+
code: string;
|
|
3232
|
+
/** Human-readable description of the safety concern */
|
|
3233
|
+
message: string;
|
|
3234
|
+
}
|
|
3235
|
+
/**
|
|
3236
|
+
* Response from the user for a safety confirmation request.
|
|
3237
|
+
*/
|
|
3238
|
+
interface SafetyConfirmationResponse {
|
|
3239
|
+
/** Whether the user acknowledged/approved the safety checks */
|
|
3240
|
+
acknowledged: boolean;
|
|
3241
|
+
}
|
|
3242
|
+
/**
|
|
3243
|
+
* Callback for handling safety confirmation requests.
|
|
3244
|
+
* Called when the CUA provider issues safety checks that require user confirmation.
|
|
3245
|
+
* The callback should return a promise that resolves when the user has made a decision.
|
|
3246
|
+
*
|
|
3247
|
+
* @param safetyChecks - Array of safety checks requiring confirmation
|
|
3248
|
+
* @returns Promise resolving to the user's response
|
|
3249
|
+
*
|
|
3250
|
+
* @example
|
|
3251
|
+
* ```typescript
|
|
3252
|
+
* const agent = stagehand.agent({
|
|
3253
|
+
* mode: "cua",
|
|
3254
|
+
* });
|
|
3255
|
+
* await agent.execute({
|
|
3256
|
+
* instruction: "...",
|
|
3257
|
+
* callbacks: {
|
|
3258
|
+
* onSafetyConfirmation: async (checks) => {
|
|
3259
|
+
* console.log("Safety checks:", checks);
|
|
3260
|
+
* const userApproved = await showConfirmationDialog(checks);
|
|
3261
|
+
* return { acknowledged: userApproved };
|
|
3262
|
+
* },
|
|
3263
|
+
* },
|
|
3264
|
+
* });
|
|
3265
|
+
* ```
|
|
3266
|
+
*/
|
|
3267
|
+
type SafetyConfirmationHandler = (safetyChecks: SafetyCheck[]) => Promise<SafetyConfirmationResponse>;
|
|
3268
|
+
interface ToolUseItem extends ResponseItem {
|
|
3269
|
+
type: "tool_use";
|
|
3270
|
+
id: string;
|
|
3271
|
+
name: string;
|
|
3272
|
+
input: Record<string, unknown>;
|
|
3273
|
+
}
|
|
3274
|
+
interface AnthropicMessage {
|
|
3275
|
+
role: string;
|
|
3276
|
+
content: string | Array<AnthropicContentBlock>;
|
|
3277
|
+
}
|
|
3278
|
+
interface AnthropicContentBlock {
|
|
3279
|
+
type: string;
|
|
3280
|
+
[key: string]: unknown;
|
|
3281
|
+
}
|
|
3282
|
+
interface AnthropicTextBlock extends AnthropicContentBlock {
|
|
3283
|
+
type: "text";
|
|
3284
|
+
text: string;
|
|
3285
|
+
}
|
|
3286
|
+
interface AnthropicToolResult {
|
|
3287
|
+
type: "tool_result";
|
|
3288
|
+
tool_use_id: string;
|
|
3289
|
+
content: string | Array<AnthropicContentBlock>;
|
|
3290
|
+
}
|
|
3291
|
+
interface ResponseItem {
|
|
3292
|
+
type: string;
|
|
3293
|
+
id: string;
|
|
3294
|
+
[key: string]: unknown;
|
|
3295
|
+
}
|
|
3296
|
+
interface ComputerCallItem extends ResponseItem {
|
|
3297
|
+
type: "computer_call";
|
|
3298
|
+
call_id: string;
|
|
3299
|
+
action: {
|
|
3300
|
+
type: string;
|
|
3301
|
+
[key: string]: unknown;
|
|
3302
|
+
};
|
|
3303
|
+
pending_safety_checks?: Array<{
|
|
3304
|
+
id: string;
|
|
3305
|
+
code: string;
|
|
3306
|
+
message: string;
|
|
3307
|
+
}>;
|
|
3308
|
+
}
|
|
3309
|
+
interface FunctionCallItem extends ResponseItem {
|
|
3310
|
+
type: "function_call";
|
|
3311
|
+
call_id: string;
|
|
3312
|
+
name: string;
|
|
3313
|
+
arguments: string;
|
|
3314
|
+
}
|
|
3315
|
+
type ResponseInputItem = {
|
|
3316
|
+
role: string;
|
|
3317
|
+
content: string;
|
|
3318
|
+
} | {
|
|
3319
|
+
type: "computer_call_output";
|
|
3320
|
+
call_id: string;
|
|
3321
|
+
output: {
|
|
3322
|
+
type: "input_image";
|
|
3323
|
+
image_url: string;
|
|
3324
|
+
current_url?: string;
|
|
3325
|
+
error?: string;
|
|
3326
|
+
[key: string]: unknown;
|
|
3327
|
+
} | string;
|
|
3328
|
+
acknowledged_safety_checks?: Array<{
|
|
3329
|
+
id: string;
|
|
3330
|
+
code: string;
|
|
3331
|
+
message: string;
|
|
3332
|
+
}>;
|
|
3333
|
+
} | {
|
|
3334
|
+
type: "function_call_output";
|
|
3335
|
+
call_id: string;
|
|
3336
|
+
output: string;
|
|
3337
|
+
};
|
|
3338
|
+
interface AgentInstance {
|
|
3339
|
+
execute: (instructionOrOptions: string | AgentExecuteOptions) => Promise<AgentResult>;
|
|
3340
|
+
}
|
|
3341
|
+
type AgentProviderType = AgentType;
|
|
3342
|
+
type AgentModelConfig<TModelName extends string = string> = {
|
|
3343
|
+
modelName: TModelName;
|
|
3344
|
+
} & Record<string, unknown>;
|
|
3345
|
+
/**
|
|
3346
|
+
* Agent tool mode determines which set of tools are available to the agent.
|
|
3347
|
+
* - 'dom': Uses DOM-based tools (act, fillForm) - better for structured page interactions
|
|
3348
|
+
* - 'hybrid': Uses coordinate-based tools (click, type, dragAndDrop, etc.) - better for visual/screenshot-based interactions
|
|
3349
|
+
* - 'cua': Uses Computer Use Agent (CUA) providers like Anthropic Claude or Google Gemini for screenshot-based automation
|
|
3350
|
+
*/
|
|
3351
|
+
type AgentToolMode = "dom" | "hybrid" | "cua";
|
|
3352
|
+
type AgentConfig = {
|
|
3353
|
+
/**
|
|
3354
|
+
* Custom system prompt to provide to the agent. Overrides the default system prompt.
|
|
3355
|
+
*/
|
|
3356
|
+
systemPrompt?: string;
|
|
3357
|
+
/**
|
|
3358
|
+
* MCP integrations - Array of Client objects
|
|
3359
|
+
*/
|
|
3360
|
+
integrations?: (Client | string)[];
|
|
3361
|
+
/**
|
|
3362
|
+
* Tools passed to the agent client
|
|
3363
|
+
*/
|
|
3364
|
+
tools?: ToolSet;
|
|
3365
|
+
/**
|
|
3366
|
+
* @deprecated Use `mode: "cua"` instead. This option will be removed in a future version.
|
|
3367
|
+
* Enables Computer Use Agent (CUA) mode.
|
|
3368
|
+
*/
|
|
3369
|
+
cua?: boolean;
|
|
3370
|
+
/**
|
|
3371
|
+
* The model to use for agent functionality
|
|
3372
|
+
*/
|
|
3373
|
+
model?: string | AgentModelConfig<string>;
|
|
3374
|
+
/**
|
|
3375
|
+
* The model to use for tool execution (observe/act calls within agent tools).
|
|
3376
|
+
* If not specified, inherits from the main model configuration.
|
|
3377
|
+
* Format: "provider/model" (e.g., "openai/gpt-4o-mini", "google/gemini-2.0-flash-exp")
|
|
3378
|
+
*/
|
|
3379
|
+
executionModel?: string | AgentModelConfig<string>;
|
|
3380
|
+
/**
|
|
3381
|
+
* Enable streaming mode for the agent.
|
|
3382
|
+
* When true, execute() returns AgentStreamResult with textStream for incremental output.
|
|
3383
|
+
* When false (default), execute() returns AgentResult after completion.
|
|
3384
|
+
*/
|
|
3385
|
+
stream?: boolean;
|
|
3386
|
+
/**
|
|
3387
|
+
* Tool mode for the agent. Determines which set of tools are available.
|
|
3388
|
+
* - 'dom' (default): Uses DOM-based tools (act, fillForm) for structured interactions
|
|
3389
|
+
* - 'hybrid': Uses coordinate-based tools (click, type, dragAndDrop, clickAndHold, fillFormVision)
|
|
3390
|
+
* for visual/screenshot-based interactions
|
|
3391
|
+
* - 'cua': Uses Computer Use Agent (CUA) providers for screenshot-based automation
|
|
3392
|
+
*/
|
|
3393
|
+
mode?: AgentToolMode;
|
|
3394
|
+
};
|
|
3395
|
+
/**
|
|
3396
|
+
* Agent instance returned when stream: true is set in AgentConfig.
|
|
3397
|
+
* execute() returns a streaming result that can be consumed incrementally.
|
|
3398
|
+
* Accepts AgentStreamExecuteOptions with streaming-specific callbacks.
|
|
3399
|
+
*/
|
|
3400
|
+
interface StreamingAgentInstance {
|
|
3401
|
+
execute: (instructionOrOptions: string | AgentStreamExecuteOptions) => Promise<AgentStreamResult>;
|
|
3402
|
+
}
|
|
3403
|
+
/**
|
|
3404
|
+
* Agent instance returned when stream is false or not set in AgentConfig.
|
|
3405
|
+
* execute() returns a result after the agent completes.
|
|
3406
|
+
* Accepts AgentExecuteOptions with non-streaming callbacks only.
|
|
3407
|
+
*/
|
|
3408
|
+
interface NonStreamingAgentInstance {
|
|
3409
|
+
execute: (instructionOrOptions: string | AgentExecuteOptions) => Promise<AgentResult>;
|
|
3410
|
+
}
|
|
3411
|
+
/**
|
|
3412
|
+
* Content item type for toModelOutput return values.
|
|
3413
|
+
* Used in tool definitions to return text and/or media to the model.
|
|
3414
|
+
*/
|
|
3415
|
+
type ModelOutputContentItem = {
|
|
3416
|
+
type: "text";
|
|
3417
|
+
text: string;
|
|
3418
|
+
} | {
|
|
3419
|
+
type: "media";
|
|
3420
|
+
mediaType: string;
|
|
3421
|
+
data: string;
|
|
3422
|
+
};
|
|
3423
|
+
interface ClickToolResult {
|
|
3424
|
+
success: boolean;
|
|
3425
|
+
describe?: string;
|
|
3426
|
+
coordinates?: number[];
|
|
3427
|
+
error?: string;
|
|
3428
|
+
screenshotBase64?: string;
|
|
3429
|
+
}
|
|
3430
|
+
interface TypeToolResult {
|
|
3431
|
+
success: boolean;
|
|
3432
|
+
describe?: string;
|
|
3433
|
+
text?: string;
|
|
3434
|
+
error?: string;
|
|
3435
|
+
screenshotBase64?: string;
|
|
3436
|
+
}
|
|
3437
|
+
interface DragAndDropToolResult {
|
|
3438
|
+
success: boolean;
|
|
3439
|
+
describe?: string;
|
|
3440
|
+
error?: string;
|
|
3441
|
+
screenshotBase64?: string;
|
|
3442
|
+
}
|
|
3443
|
+
interface FillFormField {
|
|
3444
|
+
action: string;
|
|
3445
|
+
value: string;
|
|
3446
|
+
coordinates: {
|
|
3447
|
+
x: number;
|
|
3448
|
+
y: number;
|
|
3449
|
+
};
|
|
3450
|
+
}
|
|
3451
|
+
interface FillFormVisionToolResult {
|
|
3452
|
+
success: boolean;
|
|
3453
|
+
playwrightArguments?: FillFormField[];
|
|
3454
|
+
error?: string;
|
|
3455
|
+
screenshotBase64?: string;
|
|
3456
|
+
}
|
|
3457
|
+
interface ScrollVisionToolResult {
|
|
3458
|
+
success: boolean;
|
|
3459
|
+
message: string;
|
|
3460
|
+
scrolledPixels: number;
|
|
3461
|
+
screenshotBase64?: string;
|
|
3462
|
+
}
|
|
3463
|
+
interface WaitToolResult {
|
|
3464
|
+
success: boolean;
|
|
3465
|
+
waited: number;
|
|
3466
|
+
screenshotBase64?: string;
|
|
3467
|
+
}
|
|
3468
|
+
|
|
3469
|
+
type OpenAIClientOptions = Pick<ClientOptions$1, "baseURL" | "apiKey">;
|
|
3470
|
+
type AnthropicClientOptions = Pick<ClientOptions$2, "baseURL" | "apiKey">;
|
|
3471
|
+
interface GoogleServiceAccountCredentials {
|
|
3472
|
+
type?: string;
|
|
3473
|
+
project_id?: string;
|
|
3474
|
+
private_key_id?: string;
|
|
3475
|
+
private_key?: string;
|
|
3476
|
+
client_email?: string;
|
|
3477
|
+
client_id?: string;
|
|
3478
|
+
auth_uri?: string;
|
|
3479
|
+
token_uri?: string;
|
|
3480
|
+
auth_provider_x509_cert_url?: string;
|
|
3481
|
+
client_x509_cert_url?: string;
|
|
3482
|
+
universe_domain?: string;
|
|
3483
|
+
}
|
|
3484
|
+
type GoogleVertexProviderSettings = Pick<GoogleVertexProviderSettings$1, "project" | "location"> & {
|
|
3485
|
+
googleAuthOptions?: {
|
|
3486
|
+
credentials?: GoogleServiceAccountCredentials;
|
|
3487
|
+
};
|
|
3488
|
+
};
|
|
3489
|
+
type AnthropicJsonSchemaObject = {
|
|
3490
|
+
definitions?: {
|
|
3491
|
+
MySchema?: {
|
|
3492
|
+
properties?: Record<string, unknown>;
|
|
3493
|
+
required?: string[];
|
|
3494
|
+
};
|
|
3495
|
+
};
|
|
3496
|
+
properties?: Record<string, unknown>;
|
|
3497
|
+
required?: string[];
|
|
3498
|
+
} & Record<string, unknown>;
|
|
3499
|
+
interface LLMTool {
|
|
3500
|
+
type: "function";
|
|
3501
|
+
name: string;
|
|
3502
|
+
description: string;
|
|
3503
|
+
parameters: Record<string, unknown>;
|
|
3504
|
+
}
|
|
3505
|
+
type AISDKProvider = (modelName: string) => LanguageModelV2;
|
|
3506
|
+
type AISDKCustomProvider = (options: ClientOptions) => AISDKProvider;
|
|
3507
|
+
type AvailableModel = "gpt-4.1" | "gpt-4.1-mini" | "gpt-4.1-nano" | "o4-mini" | "o3" | "o3-mini" | "o1" | "o1-mini" | "gpt-4o" | "gpt-4o-mini" | "gpt-4o-2024-08-06" | "gpt-4.5-preview" | "o1-preview" | "claude-3-5-sonnet-latest" | "claude-3-5-sonnet-20241022" | "claude-3-5-sonnet-20240620" | "claude-3-7-sonnet-latest" | "claude-3-7-sonnet-20250219" | "cerebras-llama-3.3-70b" | "cerebras-llama-3.1-8b" | "groq-llama-3.3-70b-versatile" | "groq-llama-3.3-70b-specdec" | "gemini-1.5-flash" | "gemini-1.5-pro" | "gemini-1.5-flash-8b" | "gemini-2.0-flash-lite" | "gemini-2.0-flash" | "gemini-2.5-flash-preview-04-17" | "gemini-2.5-pro-preview-03-25" | string;
|
|
3508
|
+
type ModelProvider = "openai" | "anthropic" | "cerebras" | "groq" | "google" | "aisdk";
|
|
3509
|
+
type ClientOptions = (OpenAIClientOptions | AnthropicClientOptions | GoogleVertexProviderSettings) & {
|
|
3510
|
+
apiKey?: string;
|
|
3511
|
+
provider?: AgentProviderType;
|
|
3512
|
+
baseURL?: string;
|
|
3513
|
+
/** OpenAI organization ID */
|
|
3514
|
+
organization?: string;
|
|
3515
|
+
/** Delay between agent actions in ms */
|
|
3516
|
+
waitBetweenActions?: number;
|
|
3517
|
+
/** Anthropic thinking budget for extended thinking */
|
|
3518
|
+
thinkingBudget?: number;
|
|
3519
|
+
/** Environment type for CUA agents (browser, mac, windows, ubuntu) */
|
|
3520
|
+
environment?: string;
|
|
3521
|
+
/** Max images for Microsoft FARA agent */
|
|
3522
|
+
maxImages?: number;
|
|
3523
|
+
/** Temperature for model inference */
|
|
3524
|
+
temperature?: number;
|
|
3525
|
+
};
|
|
3526
|
+
type ModelConfiguration = AvailableModel | (ClientOptions & {
|
|
3527
|
+
modelName: AvailableModel;
|
|
3528
|
+
});
|
|
3529
|
+
|
|
3530
|
+
interface ChatMessage {
|
|
3531
|
+
role: "system" | "user" | "assistant";
|
|
3532
|
+
content: ChatMessageContent;
|
|
3533
|
+
}
|
|
3534
|
+
type ChatMessageContent = string | (ChatMessageImageContent | ChatMessageTextContent)[];
|
|
3535
|
+
interface ChatMessageImageContent {
|
|
3536
|
+
type: string;
|
|
3537
|
+
image_url?: {
|
|
3538
|
+
url: string;
|
|
3539
|
+
};
|
|
3540
|
+
text?: string;
|
|
3541
|
+
source?: {
|
|
3542
|
+
type: string;
|
|
3543
|
+
media_type: string;
|
|
3544
|
+
data: string;
|
|
3545
|
+
};
|
|
3546
|
+
}
|
|
3547
|
+
interface ChatMessageTextContent {
|
|
3548
|
+
type: string;
|
|
3549
|
+
text: string;
|
|
3550
|
+
}
|
|
3551
|
+
declare const AnnotatedScreenshotText = "This is a screenshot of the current page state with the elements annotated on it. Each element id is annotated with a number to the top left of it. Duplicate annotations at the same location are under each other vertically.";
|
|
3552
|
+
interface ChatCompletionOptions {
|
|
3553
|
+
messages: ChatMessage[];
|
|
3554
|
+
temperature?: number;
|
|
3555
|
+
top_p?: number;
|
|
3556
|
+
frequency_penalty?: number;
|
|
3557
|
+
presence_penalty?: number;
|
|
3558
|
+
image?: {
|
|
3559
|
+
buffer: Buffer;
|
|
3560
|
+
description?: string;
|
|
3561
|
+
};
|
|
3562
|
+
response_model?: {
|
|
3563
|
+
name: string;
|
|
3564
|
+
schema: StagehandZodSchema;
|
|
3565
|
+
};
|
|
3566
|
+
tools?: LLMTool[];
|
|
3567
|
+
tool_choice?: "auto" | "none" | "required";
|
|
3568
|
+
maxOutputTokens?: number;
|
|
3569
|
+
requestId?: string;
|
|
3570
|
+
}
|
|
3571
|
+
type LLMResponse = {
|
|
3572
|
+
id: string;
|
|
3573
|
+
object: string;
|
|
3574
|
+
created: number;
|
|
3575
|
+
model: string;
|
|
3576
|
+
choices: {
|
|
3577
|
+
index: number;
|
|
3578
|
+
message: {
|
|
3579
|
+
role: string;
|
|
3580
|
+
content: string | null;
|
|
3581
|
+
tool_calls: {
|
|
3582
|
+
id: string;
|
|
3583
|
+
type: string;
|
|
3584
|
+
function: {
|
|
3585
|
+
name: string;
|
|
3586
|
+
arguments: string;
|
|
3587
|
+
};
|
|
3588
|
+
}[];
|
|
3589
|
+
};
|
|
3590
|
+
finish_reason: string;
|
|
3591
|
+
}[];
|
|
3592
|
+
usage: {
|
|
3593
|
+
prompt_tokens: number;
|
|
3594
|
+
completion_tokens: number;
|
|
3595
|
+
total_tokens: number;
|
|
3596
|
+
};
|
|
3597
|
+
};
|
|
3598
|
+
interface CreateChatCompletionOptions {
|
|
3599
|
+
options: ChatCompletionOptions;
|
|
3600
|
+
logger: (message: LogLine) => void;
|
|
3601
|
+
retries?: number;
|
|
3602
|
+
}
|
|
3603
|
+
/** Simple usage shape if your LLM returns usage tokens. */
|
|
3604
|
+
interface LLMUsage {
|
|
3605
|
+
prompt_tokens: number;
|
|
3606
|
+
completion_tokens: number;
|
|
3607
|
+
total_tokens: number;
|
|
3608
|
+
reasoning_tokens?: number;
|
|
3609
|
+
cached_input_tokens?: number;
|
|
3610
|
+
}
|
|
3611
|
+
/**
|
|
3612
|
+
* For calls that use a schema: the LLMClient may return { data: T; usage?: LLMUsage }
|
|
3613
|
+
*/
|
|
3614
|
+
interface LLMParsedResponse<T> {
|
|
3615
|
+
data: T;
|
|
3616
|
+
usage?: LLMUsage;
|
|
3617
|
+
}
|
|
3618
|
+
declare abstract class LLMClient {
|
|
3619
|
+
type: "openai" | "anthropic" | "cerebras" | "groq" | (string & {});
|
|
3620
|
+
modelName: AvailableModel | (string & {});
|
|
3621
|
+
hasVision: boolean;
|
|
3622
|
+
clientOptions: ClientOptions;
|
|
3623
|
+
userProvidedInstructions?: string;
|
|
3624
|
+
constructor(modelName: AvailableModel, userProvidedInstructions?: string);
|
|
3625
|
+
abstract createChatCompletion<T>(options: CreateChatCompletionOptions & {
|
|
3626
|
+
options: {
|
|
3627
|
+
response_model: {
|
|
3628
|
+
name: string;
|
|
3629
|
+
schema: StagehandZodSchema;
|
|
3630
|
+
};
|
|
3631
|
+
};
|
|
3632
|
+
}): Promise<LLMParsedResponse<T>>;
|
|
3633
|
+
abstract createChatCompletion<T = LLMResponse>(options: CreateChatCompletionOptions): Promise<T>;
|
|
3634
|
+
generateObject: typeof generateObject;
|
|
3635
|
+
generateText: typeof generateText;
|
|
3636
|
+
streamText: typeof streamText;
|
|
3637
|
+
streamObject: typeof streamObject;
|
|
3638
|
+
generateImage: typeof experimental_generateImage;
|
|
3639
|
+
embed: typeof embed;
|
|
3640
|
+
embedMany: typeof embedMany;
|
|
3641
|
+
transcribe: typeof experimental_transcribe;
|
|
3642
|
+
generateSpeech: typeof experimental_generateSpeech;
|
|
3643
|
+
getLanguageModel?(): LanguageModelV2;
|
|
3644
|
+
}
|
|
3645
|
+
|
|
3646
|
+
/**
|
|
3647
|
+
* V3
|
|
3648
|
+
*
|
|
3649
|
+
* Purpose:
|
|
3650
|
+
* A high-level orchestrator for Stagehand V3. Abstracts away whether the browser
|
|
3651
|
+
* runs **locally via Chrome** or remotely on **Browserbase**, and exposes simple
|
|
3652
|
+
* entrypoints (`act`, `extract`, `observe`) that delegate to the corresponding
|
|
3653
|
+
* handler classes.
|
|
3654
|
+
*
|
|
3655
|
+
* Responsibilities:
|
|
3656
|
+
* - Bootstraps Chrome or Browserbase, ensures a working CDP WebSocket, and builds a `V3Context`.
|
|
3657
|
+
* - Manages lifecycle: init, context access, cleanup.
|
|
3658
|
+
* - Bridges external page objects (Playwright/Puppeteer) into internal frameIds for handlers.
|
|
3659
|
+
* - Provides a stable API surface for downstream code regardless of runtime environment.
|
|
3660
|
+
*/
|
|
3661
|
+
declare class V3 {
|
|
3662
|
+
private readonly opts;
|
|
3663
|
+
private state;
|
|
3664
|
+
private actHandler;
|
|
3665
|
+
private extractHandler;
|
|
3666
|
+
private observeHandler;
|
|
3667
|
+
private ctx;
|
|
3668
|
+
llmClient: LLMClient;
|
|
3669
|
+
/**
|
|
3670
|
+
* Event bus for internal communication.
|
|
3671
|
+
* Emits events like 'screenshot' when screenshots are captured during agent execution.
|
|
3672
|
+
*/
|
|
3673
|
+
readonly bus: EventEmitter;
|
|
3674
|
+
private modelName;
|
|
3675
|
+
private modelClientOptions;
|
|
3676
|
+
private llmProvider;
|
|
3677
|
+
private overrideLlmClients;
|
|
3678
|
+
private readonly domSettleTimeoutMs?;
|
|
3679
|
+
private _isClosing;
|
|
3680
|
+
browserbaseSessionId?: string;
|
|
3681
|
+
private browserbaseSessionUrl?;
|
|
3682
|
+
private browserbaseDebugUrl?;
|
|
3683
|
+
get browserbaseSessionID(): string | undefined;
|
|
3684
|
+
get browserbaseSessionURL(): string | undefined;
|
|
3685
|
+
get browserbaseDebugURL(): string | undefined;
|
|
3686
|
+
/**
|
|
3687
|
+
* Returns true if the browser is running on Browserbase.
|
|
3688
|
+
*/
|
|
3689
|
+
get isBrowserbase(): boolean;
|
|
3690
|
+
private _onCdpClosed;
|
|
3691
|
+
readonly experimental: boolean;
|
|
3692
|
+
readonly logInferenceToFile: boolean;
|
|
3693
|
+
readonly disableAPI: boolean;
|
|
3694
|
+
private externalLogger?;
|
|
3695
|
+
verbose: 0 | 1 | 2;
|
|
3696
|
+
private stagehandLogger;
|
|
3697
|
+
private _history;
|
|
3698
|
+
private readonly instanceId;
|
|
3699
|
+
private static _processGuardsInstalled;
|
|
3700
|
+
private static _instances;
|
|
3701
|
+
private cacheStorage;
|
|
3702
|
+
private actCache;
|
|
3703
|
+
private agentCache;
|
|
3704
|
+
private apiClient;
|
|
3705
|
+
private proxyAuthHandlers;
|
|
3706
|
+
stagehandMetrics: StagehandMetrics;
|
|
3707
|
+
constructor(opts: V3Options);
|
|
3708
|
+
/**
|
|
3709
|
+
* Async property for metrics so callers can `await v3.metrics`.
|
|
3710
|
+
* When using API mode, fetches metrics from the API. Otherwise returns local metrics.
|
|
3711
|
+
*/
|
|
3712
|
+
get metrics(): Promise<StagehandMetrics>;
|
|
3713
|
+
private resolveLlmClient;
|
|
3714
|
+
private beginAgentReplayRecording;
|
|
3715
|
+
private endAgentReplayRecording;
|
|
3716
|
+
private discardAgentReplayRecording;
|
|
3717
|
+
private isAgentReplayRecording;
|
|
3718
|
+
isAgentReplayActive(): boolean;
|
|
3719
|
+
recordAgentReplayStep(step: AgentReplayStep): void;
|
|
3720
|
+
/**
|
|
3721
|
+
* Async property for history so callers can `await v3.history`.
|
|
3722
|
+
* Returns a frozen copy to avoid external mutation.
|
|
3723
|
+
*/
|
|
3724
|
+
get history(): Promise<ReadonlyArray<HistoryEntry>>;
|
|
3725
|
+
addToHistory(method: HistoryEntry["method"], parameters: unknown, result?: unknown): void;
|
|
3726
|
+
updateMetrics(functionName: V3FunctionName, promptTokens: number, completionTokens: number, reasoningTokens: number, cachedInputTokens: number, inferenceTimeMs: number): void;
|
|
3727
|
+
private updateTotalMetrics;
|
|
3728
|
+
private _immediateShutdown;
|
|
3729
|
+
private static _installProcessGuards;
|
|
3730
|
+
/**
|
|
3731
|
+
* Entrypoint: initializes handlers, launches Chrome or Browserbase,
|
|
3732
|
+
* and sets up a CDP context.
|
|
3733
|
+
*/
|
|
3734
|
+
init(): Promise<void>;
|
|
3735
|
+
/** Apply post-connect local browser options that require CDP. */
|
|
3736
|
+
private _applyPostConnectLocalOptions;
|
|
3737
|
+
private _ensureBrowserbaseDownloadsEnabled;
|
|
3738
|
+
private resetBrowserbaseSessionMetadata;
|
|
3739
|
+
/**
|
|
3740
|
+
* Run an "act" instruction through the ActHandler.
|
|
3741
|
+
*
|
|
3742
|
+
* New API:
|
|
3743
|
+
* - act(instruction: string, options?: ActOptions)
|
|
3744
|
+
* - act(action: Action, options?: ActOptions)
|
|
3745
|
+
*/
|
|
3746
|
+
act(instruction: string, options?: ActOptions): Promise<ActResult>;
|
|
3747
|
+
act(action: Action, options?: ActOptions): Promise<ActResult>;
|
|
3748
|
+
/**
|
|
3749
|
+
* Run an "extract" instruction through the ExtractHandler.
|
|
3750
|
+
*
|
|
3751
|
+
* Accepted forms:
|
|
3752
|
+
* - extract() → pageText
|
|
3753
|
+
* - extract(options) → pageText
|
|
3754
|
+
* - extract(instruction) → defaultExtractSchema
|
|
3755
|
+
* - extract(instruction, schema) → schema-inferred
|
|
3756
|
+
* - extract(instruction, schema, options)
|
|
3757
|
+
*/
|
|
3758
|
+
extract(): Promise<z.infer<typeof pageTextSchema>>;
|
|
3759
|
+
extract(options: ExtractOptions): Promise<z.infer<typeof pageTextSchema>>;
|
|
3760
|
+
extract(instruction: string, options?: ExtractOptions): Promise<z.infer<typeof defaultExtractSchema>>;
|
|
3761
|
+
extract<T extends StagehandZodSchema>(instruction: string, schema: T, options?: ExtractOptions): Promise<InferStagehandSchema<T>>;
|
|
3762
|
+
/**
|
|
3763
|
+
* Run an "observe" instruction through the ObserveHandler.
|
|
3764
|
+
*/
|
|
3765
|
+
observe(): Promise<Action[]>;
|
|
3766
|
+
observe(options: ObserveOptions): Promise<Action[]>;
|
|
3767
|
+
observe(instruction: string, options?: ObserveOptions): Promise<Action[]>;
|
|
3768
|
+
/** Return the browser-level CDP WebSocket endpoint. */
|
|
3769
|
+
connectURL(): string;
|
|
3770
|
+
/** Expose the current CDP-backed context. */
|
|
3771
|
+
get context(): V3Context;
|
|
3772
|
+
/** Best-effort cleanup of context and launched resources. */
|
|
3773
|
+
close(opts?: {
|
|
3774
|
+
force?: boolean;
|
|
3775
|
+
}): Promise<void>;
|
|
3776
|
+
/** Guard: ensure Browserbase credentials exist in options. */
|
|
3777
|
+
private requireBrowserbaseCreds;
|
|
3778
|
+
get logger(): (logLine: LogLine) => void;
|
|
3779
|
+
/**
|
|
3780
|
+
* Normalize a Playwright/Puppeteer page object into its top frame id,
|
|
3781
|
+
* so handlers can resolve it to a `Page` within our V3Context.
|
|
3782
|
+
*/
|
|
3783
|
+
private resolveTopFrameId;
|
|
3784
|
+
private isPlaywrightPage;
|
|
3785
|
+
private isPatchrightPage;
|
|
3786
|
+
private isPuppeteerPage;
|
|
3787
|
+
/** Resolve an external page reference or fall back to the active V3 page. */
|
|
3788
|
+
private resolvePage;
|
|
3789
|
+
private normalizeToV3Page;
|
|
3790
|
+
private _logBrowserbaseSessionStatus;
|
|
3791
|
+
/**
|
|
3792
|
+
* Prepares shared context for agent execution (both execute and stream).
|
|
3793
|
+
* Extracts duplicated setup logic into a single helper.
|
|
3794
|
+
*/
|
|
3795
|
+
private prepareAgentExecution;
|
|
3796
|
+
/**
|
|
3797
|
+
* Create a v3 agent instance (AISDK tool-based) with execute().
|
|
3798
|
+
* Mirrors the v2 Stagehand.agent() tool mode (no CUA provider here).
|
|
3799
|
+
*
|
|
3800
|
+
* @overload When stream: true, returns a streaming agent where execute() returns AgentStreamResult
|
|
3801
|
+
* @overload When stream is false/undefined, returns a non-streaming agent where execute() returns AgentResult
|
|
3802
|
+
*/
|
|
3803
|
+
agent(options: AgentConfig & {
|
|
3804
|
+
stream: true;
|
|
3805
|
+
}): {
|
|
3806
|
+
execute: (instructionOrOptions: string | AgentStreamExecuteOptions) => Promise<AgentStreamResult>;
|
|
3807
|
+
};
|
|
3808
|
+
agent(options?: AgentConfig & {
|
|
3809
|
+
stream?: false;
|
|
3810
|
+
}): {
|
|
3811
|
+
execute: (instructionOrOptions: string | AgentExecuteOptions) => Promise<AgentResult>;
|
|
3812
|
+
};
|
|
3813
|
+
}
|
|
3814
|
+
|
|
3815
|
+
/**
|
|
3816
|
+
* Abstract base class for agent clients
|
|
3817
|
+
* This provides a common interface for all agent implementations
|
|
3818
|
+
*/
|
|
3819
|
+
declare abstract class AgentClient {
|
|
3820
|
+
type: AgentType;
|
|
3821
|
+
modelName: string;
|
|
3822
|
+
clientOptions: ClientOptions;
|
|
3823
|
+
userProvidedInstructions?: string;
|
|
3824
|
+
constructor(type: AgentType, modelName: string, userProvidedInstructions?: string);
|
|
3825
|
+
abstract execute(options: AgentExecutionOptions): Promise<AgentResult>;
|
|
3826
|
+
abstract captureScreenshot(options?: Record<string, unknown>): Promise<unknown>;
|
|
3827
|
+
abstract setViewport(width: number, height: number): void;
|
|
3828
|
+
abstract setCurrentUrl(url: string): void;
|
|
3829
|
+
abstract setScreenshotProvider(provider: () => Promise<string>): void;
|
|
3830
|
+
abstract setActionHandler(handler: (action: AgentAction) => Promise<void>): void;
|
|
3831
|
+
}
|
|
3832
|
+
|
|
3833
|
+
declare const modelToAgentProviderMap: Record<string, AgentProviderType>;
|
|
3834
|
+
/**
|
|
3835
|
+
* Provider for agent clients
|
|
3836
|
+
* This class is responsible for creating the appropriate agent client
|
|
3837
|
+
* based on the provider type
|
|
3838
|
+
*/
|
|
3839
|
+
declare class AgentProvider {
|
|
3840
|
+
private logger;
|
|
3841
|
+
/**
|
|
3842
|
+
* Create a new agent provider
|
|
3843
|
+
*/
|
|
3844
|
+
constructor(logger: (message: LogLine) => void);
|
|
3845
|
+
getClient(modelName: string, clientOptions?: ClientOptions, userProvidedInstructions?: string, tools?: ToolSet$1): AgentClient;
|
|
3846
|
+
static getAgentProvider(modelName: string): AgentProviderType;
|
|
3847
|
+
}
|
|
3848
|
+
|
|
3849
|
+
declare const gotoTool: (v3: V3) => ai.Tool<{
|
|
3850
|
+
url: string;
|
|
3851
|
+
}, {
|
|
3852
|
+
success: boolean;
|
|
3853
|
+
url: string;
|
|
3854
|
+
error?: undefined;
|
|
3855
|
+
} | {
|
|
3856
|
+
success: boolean;
|
|
3857
|
+
error: any;
|
|
3858
|
+
url?: undefined;
|
|
3859
|
+
}>;
|
|
3860
|
+
|
|
3861
|
+
declare const actTool: (v3: V3, executionModel?: string) => ai.Tool<{
|
|
3862
|
+
action: string;
|
|
3863
|
+
}, {
|
|
3864
|
+
success: boolean;
|
|
3865
|
+
action: string;
|
|
3866
|
+
playwrightArguments: Action;
|
|
3867
|
+
error?: undefined;
|
|
3868
|
+
} | {
|
|
3869
|
+
success: boolean;
|
|
3870
|
+
error: any;
|
|
3871
|
+
action?: undefined;
|
|
3872
|
+
playwrightArguments?: undefined;
|
|
3873
|
+
}>;
|
|
3874
|
+
|
|
3875
|
+
declare const screenshotTool: (v3: V3) => ai.Tool<Record<string, never>, {
|
|
3876
|
+
base64: string;
|
|
3877
|
+
timestamp: number;
|
|
3878
|
+
pageUrl: string;
|
|
3879
|
+
}>;
|
|
3880
|
+
|
|
3881
|
+
declare const waitTool: (v3: V3, mode?: AgentToolMode) => ai.Tool<{
|
|
3882
|
+
timeMs: number;
|
|
3883
|
+
}, WaitToolResult>;
|
|
3884
|
+
|
|
3885
|
+
declare const navBackTool: (v3: V3) => ai.Tool<{
|
|
3886
|
+
reasoningText: string;
|
|
3887
|
+
}, {
|
|
3888
|
+
success: boolean;
|
|
3889
|
+
}>;
|
|
3890
|
+
|
|
3891
|
+
declare const closeTool: () => ai.Tool<{
|
|
3892
|
+
reasoning: string;
|
|
3893
|
+
taskComplete: boolean;
|
|
3894
|
+
}, {
|
|
3895
|
+
success: boolean;
|
|
3896
|
+
reasoning: string;
|
|
3897
|
+
taskComplete: boolean;
|
|
3898
|
+
}>;
|
|
3899
|
+
|
|
3900
|
+
declare const ariaTreeTool: (v3: V3) => ai.Tool<Record<string, never>, {
|
|
3901
|
+
content: string;
|
|
3902
|
+
pageUrl: string;
|
|
3903
|
+
}>;
|
|
3904
|
+
|
|
3905
|
+
declare const fillFormTool: (v3: V3, executionModel?: string) => ai.Tool<{
|
|
3906
|
+
fields: {
|
|
3907
|
+
action: string;
|
|
3908
|
+
value: string;
|
|
3909
|
+
}[];
|
|
3910
|
+
}, {
|
|
3911
|
+
success: boolean;
|
|
3912
|
+
actions: unknown[];
|
|
3913
|
+
playwrightArguments: Action[];
|
|
3914
|
+
}>;
|
|
3915
|
+
|
|
3916
|
+
/**
|
|
3917
|
+
* Simple scroll tool for DOM mode (non-grounding models).
|
|
3918
|
+
* No coordinates - scrolls from viewport center.
|
|
3919
|
+
*/
|
|
3920
|
+
declare const scrollTool: (v3: V3) => ai.Tool<{
|
|
3921
|
+
direction: "up" | "down";
|
|
3922
|
+
percentage?: number;
|
|
3923
|
+
}, {
|
|
3924
|
+
success: boolean;
|
|
3925
|
+
message: string;
|
|
3926
|
+
scrolledPixels: number;
|
|
3927
|
+
}>;
|
|
3928
|
+
/**
|
|
3929
|
+
* Scroll tool for hybrid mode (grounding models).
|
|
3930
|
+
* Supports optional coordinates for scrolling within nested scrollable elements.
|
|
3931
|
+
*/
|
|
3932
|
+
declare const scrollVisionTool: (v3: V3, provider?: string) => ai.Tool<{
|
|
3933
|
+
direction: "up" | "down";
|
|
3934
|
+
coordinates?: number[];
|
|
3935
|
+
percentage?: number;
|
|
3936
|
+
}, ScrollVisionToolResult>;
|
|
3937
|
+
|
|
3938
|
+
declare const extractTool: (v3: V3, executionModel?: string, logger?: (message: LogLine) => void) => ai.Tool<{
|
|
3939
|
+
instruction: string;
|
|
3940
|
+
schema?: string;
|
|
3941
|
+
}, {
|
|
3942
|
+
success: boolean;
|
|
3943
|
+
result: any;
|
|
3944
|
+
error?: undefined;
|
|
3945
|
+
} | {
|
|
3946
|
+
success: boolean;
|
|
3947
|
+
error: any;
|
|
3948
|
+
result?: undefined;
|
|
3949
|
+
}>;
|
|
3950
|
+
|
|
3951
|
+
declare const clickTool: (v3: V3, provider?: string) => ai.Tool<{
|
|
3952
|
+
describe: string;
|
|
3953
|
+
coordinates: number[];
|
|
3954
|
+
}, ClickToolResult>;
|
|
3955
|
+
|
|
3956
|
+
declare const typeTool: (v3: V3, provider?: string) => ai.Tool<{
|
|
3957
|
+
describe: string;
|
|
3958
|
+
text: string;
|
|
3959
|
+
coordinates: number[];
|
|
3960
|
+
}, TypeToolResult>;
|
|
3961
|
+
|
|
3962
|
+
declare const dragAndDropTool: (v3: V3, provider?: string) => ai.Tool<{
|
|
3963
|
+
describe: string;
|
|
3964
|
+
startCoordinates: number[];
|
|
3965
|
+
endCoordinates: number[];
|
|
3966
|
+
}, DragAndDropToolResult>;
|
|
3967
|
+
|
|
3968
|
+
declare const clickAndHoldTool: (v3: V3, provider?: string) => ai.Tool<{
|
|
3969
|
+
describe: string;
|
|
3970
|
+
duration: number;
|
|
3971
|
+
coordinates: number[];
|
|
3972
|
+
}, {
|
|
3973
|
+
success: boolean;
|
|
3974
|
+
describe: string;
|
|
3975
|
+
error?: undefined;
|
|
3976
|
+
} | {
|
|
3977
|
+
success: boolean;
|
|
3978
|
+
error: string;
|
|
3979
|
+
describe?: undefined;
|
|
3980
|
+
}>;
|
|
3981
|
+
|
|
3982
|
+
declare const keysTool: (v3: V3) => ai.Tool<{
|
|
3983
|
+
method: "type" | "press";
|
|
3984
|
+
value: string;
|
|
3985
|
+
repeat?: number;
|
|
3986
|
+
}, {
|
|
3987
|
+
success: boolean;
|
|
3988
|
+
method: "type";
|
|
3989
|
+
value: string;
|
|
3990
|
+
times: number;
|
|
3991
|
+
error?: undefined;
|
|
3992
|
+
} | {
|
|
3993
|
+
success: boolean;
|
|
3994
|
+
method: "press";
|
|
3995
|
+
value: string;
|
|
3996
|
+
times: number;
|
|
3997
|
+
error?: undefined;
|
|
3998
|
+
} | {
|
|
3999
|
+
success: boolean;
|
|
4000
|
+
error: string;
|
|
4001
|
+
method?: undefined;
|
|
4002
|
+
value?: undefined;
|
|
4003
|
+
times?: undefined;
|
|
4004
|
+
}>;
|
|
4005
|
+
|
|
4006
|
+
declare const fillFormVisionTool: (v3: V3, provider?: string) => ai.Tool<{
|
|
4007
|
+
fields: {
|
|
4008
|
+
action: string;
|
|
4009
|
+
value: string;
|
|
4010
|
+
coordinates: {
|
|
4011
|
+
x: number;
|
|
4012
|
+
y: number;
|
|
4013
|
+
};
|
|
4014
|
+
}[];
|
|
4015
|
+
}, FillFormVisionToolResult>;
|
|
4016
|
+
|
|
4017
|
+
declare const thinkTool: () => ai.Tool<{
|
|
4018
|
+
reasoning: string;
|
|
4019
|
+
}, {
|
|
4020
|
+
acknowledged: boolean;
|
|
4021
|
+
message: string;
|
|
4022
|
+
}>;
|
|
4023
|
+
|
|
4024
|
+
interface BraveSearchResult {
|
|
4025
|
+
title: string;
|
|
4026
|
+
url: string;
|
|
4027
|
+
description?: string;
|
|
4028
|
+
}
|
|
4029
|
+
declare const searchTool: (v3: V3) => ai.Tool<{
|
|
4030
|
+
query: string;
|
|
4031
|
+
}, {
|
|
4032
|
+
timestamp: number;
|
|
4033
|
+
data?: {
|
|
4034
|
+
results: BraveSearchResult[];
|
|
4035
|
+
};
|
|
4036
|
+
error?: string;
|
|
4037
|
+
}>;
|
|
4038
|
+
|
|
4039
|
+
interface V3AgentToolOptions {
|
|
4040
|
+
executionModel?: string;
|
|
4041
|
+
logger?: (message: LogLine) => void;
|
|
4042
|
+
/**
|
|
4043
|
+
* Tool mode determines which set of tools are available.
|
|
4044
|
+
* - 'dom' (default): Uses DOM-based tools (act, fillForm) - removes coordinate-based tools
|
|
4045
|
+
* - 'hybrid': Uses coordinate-based tools (click, type, dragAndDrop, etc.) - removes fillForm
|
|
4046
|
+
*/
|
|
4047
|
+
mode?: AgentToolMode;
|
|
4048
|
+
/**
|
|
4049
|
+
* The model provider. Used for model-specific coordinate handling
|
|
4050
|
+
*/
|
|
4051
|
+
provider?: string;
|
|
4052
|
+
/**
|
|
4053
|
+
* Tools to exclude from the available toolset.
|
|
4054
|
+
* These tools will be filtered out after mode-based filtering.
|
|
4055
|
+
*/
|
|
4056
|
+
excludeTools?: string[];
|
|
4057
|
+
}
|
|
4058
|
+
declare function createAgentTools(v3: V3, options?: V3AgentToolOptions): ToolSet;
|
|
4059
|
+
type AgentTools = ReturnType<typeof createAgentTools>;
|
|
4060
|
+
/**
|
|
4061
|
+
* Type map of all agent tools for strong typing of tool calls and results.
|
|
4062
|
+
* Note: `search` is optional as it's only available when BRAVE_API_KEY is configured.
|
|
4063
|
+
*/
|
|
4064
|
+
type AgentToolTypesMap = {
|
|
4065
|
+
act: ReturnType<typeof actTool>;
|
|
4066
|
+
ariaTree: ReturnType<typeof ariaTreeTool>;
|
|
4067
|
+
click: ReturnType<typeof clickTool>;
|
|
4068
|
+
clickAndHold: ReturnType<typeof clickAndHoldTool>;
|
|
4069
|
+
close: ReturnType<typeof closeTool>;
|
|
4070
|
+
dragAndDrop: ReturnType<typeof dragAndDropTool>;
|
|
4071
|
+
extract: ReturnType<typeof extractTool>;
|
|
4072
|
+
fillForm: ReturnType<typeof fillFormTool>;
|
|
4073
|
+
fillFormVision: ReturnType<typeof fillFormVisionTool>;
|
|
4074
|
+
goto: ReturnType<typeof gotoTool>;
|
|
4075
|
+
keys: ReturnType<typeof keysTool>;
|
|
4076
|
+
navback: ReturnType<typeof navBackTool>;
|
|
4077
|
+
screenshot: ReturnType<typeof screenshotTool>;
|
|
4078
|
+
scroll: ReturnType<typeof scrollTool> | ReturnType<typeof scrollVisionTool>;
|
|
4079
|
+
search?: ReturnType<typeof searchTool>;
|
|
4080
|
+
think: ReturnType<typeof thinkTool>;
|
|
4081
|
+
type: ReturnType<typeof typeTool>;
|
|
4082
|
+
wait: ReturnType<typeof waitTool>;
|
|
4083
|
+
};
|
|
4084
|
+
/**
|
|
4085
|
+
* Inferred UI tools type for type-safe tool inputs and outputs.
|
|
4086
|
+
* Use with UIMessage for full type safety in UI contexts.
|
|
4087
|
+
*/
|
|
4088
|
+
type AgentUITools = InferUITools<AgentToolTypesMap>;
|
|
4089
|
+
/**
|
|
4090
|
+
* Union type for all possible agent tool calls.
|
|
4091
|
+
* Provides type-safe access to tool call arguments.
|
|
4092
|
+
*/
|
|
4093
|
+
type AgentToolCall = {
|
|
4094
|
+
[K in keyof AgentToolTypesMap]: {
|
|
4095
|
+
toolName: K;
|
|
4096
|
+
toolCallId: string;
|
|
4097
|
+
args: AgentUITools[K]["input"];
|
|
4098
|
+
};
|
|
4099
|
+
}[keyof AgentToolTypesMap];
|
|
4100
|
+
/**
|
|
4101
|
+
* Union type for all possible agent tool results.
|
|
4102
|
+
* Provides type-safe access to tool result values.
|
|
4103
|
+
*/
|
|
4104
|
+
type AgentToolResult = {
|
|
4105
|
+
[K in keyof AgentToolTypesMap]: {
|
|
4106
|
+
toolName: K;
|
|
4107
|
+
toolCallId: string;
|
|
4108
|
+
result: AgentUITools[K]["output"];
|
|
4109
|
+
};
|
|
4110
|
+
}[keyof AgentToolTypesMap];
|
|
4111
|
+
|
|
4112
|
+
declare function validateZodSchema(schema: StagehandZodSchema, data: unknown): boolean;
|
|
4113
|
+
/**
|
|
4114
|
+
* Detects if the code is running in the Bun runtime environment.
|
|
4115
|
+
* @returns {boolean} True if running in Bun, false otherwise.
|
|
4116
|
+
*/
|
|
4117
|
+
declare function isRunningInBun(): boolean;
|
|
4118
|
+
declare function toGeminiSchema(zodSchema: StagehandZodSchema): Schema;
|
|
4119
|
+
declare function getZodType(schema: StagehandZodSchema): string;
|
|
4120
|
+
/**
|
|
4121
|
+
* Recursively traverses a given Zod schema, scanning for any fields of type `z.string().url()`.
|
|
4122
|
+
* For each such field, it replaces the `z.string().url()` with `z.number()`.
|
|
4123
|
+
*
|
|
4124
|
+
* This function is used internally by higher-level utilities (e.g., transforming entire object schemas)
|
|
4125
|
+
* and handles nested objects, arrays, unions, intersections, optionals.
|
|
4126
|
+
*
|
|
4127
|
+
* @param schema - The Zod schema to transform.
|
|
4128
|
+
* @param currentPath - An array of string/number keys representing the current schema path (used internally for recursion).
|
|
4129
|
+
* @returns A two-element tuple:
|
|
4130
|
+
* 1. The updated Zod schema, with any `.url()` fields replaced by `z.number()`.
|
|
4131
|
+
* 2. An array of {@link ZodPathSegments} objects representing each replaced field, including the path segments.
|
|
4132
|
+
*/
|
|
4133
|
+
declare function transformSchema(schema: StagehandZodSchema, currentPath: Array<string | number>): [StagehandZodSchema, ZodPathSegments[]];
|
|
4134
|
+
/**
|
|
4135
|
+
* Once we get the final extracted object that has numeric IDs in place of URLs,
|
|
4136
|
+
* use `injectUrls` to walk the object and replace numeric IDs
|
|
4137
|
+
* with the real URL strings from idToUrlMapping. The `path` may include `*`
|
|
4138
|
+
* for array indices (indicating "all items in the array").
|
|
4139
|
+
*/
|
|
4140
|
+
declare function injectUrls(obj: unknown, path: Array<string | number>, idToUrlMapping: Record<string, string>): void;
|
|
4141
|
+
/**
|
|
4142
|
+
* Mapping from LLM provider names to their corresponding environment variable names for API keys.
|
|
4143
|
+
*/
|
|
4144
|
+
declare const providerEnvVarMap: Partial<Record<ModelProvider | string, string | Array<string>>>;
|
|
4145
|
+
/**
|
|
4146
|
+
* Loads an API key for a provider, checking environment variables.
|
|
4147
|
+
* @param provider The name of the provider (e.g., 'openai', 'anthropic')
|
|
4148
|
+
* @param logger Optional logger for info/error messages
|
|
4149
|
+
* @returns The API key if found, undefined otherwise
|
|
4150
|
+
*/
|
|
4151
|
+
declare function loadApiKeyFromEnv(provider: string | undefined, logger: (logLine: LogLine) => void): string | undefined;
|
|
4152
|
+
declare function trimTrailingTextNode(path: string | undefined): string | undefined;
|
|
4153
|
+
interface JsonSchemaProperty {
|
|
4154
|
+
type: string;
|
|
4155
|
+
enum?: unknown[];
|
|
4156
|
+
items?: JsonSchemaProperty;
|
|
4157
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
4158
|
+
required?: string[];
|
|
4159
|
+
minimum?: number;
|
|
4160
|
+
maximum?: number;
|
|
4161
|
+
description?: string;
|
|
4162
|
+
format?: string;
|
|
4163
|
+
}
|
|
4164
|
+
interface JsonSchema extends JsonSchemaProperty {
|
|
4165
|
+
type: string;
|
|
4166
|
+
}
|
|
4167
|
+
/**
|
|
4168
|
+
* Converts a JSON Schema object to a Zod schema
|
|
4169
|
+
* @param schema The JSON Schema object to convert
|
|
4170
|
+
* @returns A Zod schema equivalent to the input JSON Schema
|
|
4171
|
+
*/
|
|
4172
|
+
declare function jsonSchemaToZod(schema: JsonSchema): ZodTypeAny;
|
|
4173
|
+
|
|
4174
|
+
interface ConnectToMCPServerOptions {
|
|
4175
|
+
serverUrl: string | URL;
|
|
4176
|
+
clientOptions?: ClientOptions$3;
|
|
4177
|
+
}
|
|
4178
|
+
interface StdioServerConfig {
|
|
4179
|
+
command: string;
|
|
4180
|
+
args?: string[];
|
|
4181
|
+
env?: Record<string, string>;
|
|
4182
|
+
}
|
|
4183
|
+
declare const connectToMCPServer: (serverConfig: string | URL | StdioServerConfig | ConnectToMCPServerOptions) => Promise<Client>;
|
|
4184
|
+
|
|
4185
|
+
/**
|
|
4186
|
+
* V3Evaluator mirrors Evaluator but operates on a V3 instance instead of Stagehand.
|
|
4187
|
+
* It uses the V3 page/screenshot APIs and constructs an LLM client to run
|
|
4188
|
+
* structured evaluations (YES/NO with reasoning) on screenshots and/or text.
|
|
4189
|
+
*/
|
|
4190
|
+
|
|
4191
|
+
declare class V3Evaluator {
|
|
4192
|
+
private v3;
|
|
4193
|
+
private modelName;
|
|
4194
|
+
private modelClientOptions;
|
|
4195
|
+
private silentLogger;
|
|
4196
|
+
constructor(v3: V3, modelName?: AvailableModel, modelClientOptions?: ClientOptions);
|
|
4197
|
+
private getClient;
|
|
4198
|
+
ask(options: EvaluateOptions): Promise<EvaluationResult>;
|
|
4199
|
+
batchAsk(options: BatchAskOptions): Promise<EvaluationResult[]>;
|
|
4200
|
+
private _evaluateWithMultipleScreenshots;
|
|
4201
|
+
}
|
|
4202
|
+
|
|
4203
|
+
export { type AISDKCustomProvider, type AISDKProvider, AISdkClient, AVAILABLE_CUA_MODELS, type ActOptions, type ActResult, ActTimeoutError, type Action, type ActionExecutionResult, AgentAbortError, type AgentAction, type AgentCallbacks, type AgentConfig, type AgentContext, type AgentExecuteCallbacks, type AgentExecuteOptions, type AgentExecuteOptionsBase, type AgentExecutionOptions, type AgentHandlerOptions, type AgentInstance, type AgentModelConfig, AgentProvider, type AgentProviderType, type AgentResult, AgentScreenshotProviderError, type AgentState, type AgentStreamCallbacks, type AgentStreamExecuteOptions, type AgentStreamResult, type AgentToolCall, type AgentToolMode, type AgentToolResult, type AgentToolTypesMap, type AgentTools, type AgentType, type AgentUITools, AnnotatedScreenshotText, type AnthropicClientOptions, type AnthropicContentBlock, type AnthropicJsonSchemaObject, type AnthropicMessage, type AnthropicTextBlock, type AnthropicToolResult, type AnyPage, api as Api, type AvailableCuaModel, type AvailableModel, BrowserbaseSessionNotFoundError, CaptchaTimeoutError, type ChatCompletionOptions, type ChatMessage, type ChatMessageContent, type ChatMessageImageContent, type ChatMessageTextContent, type ClickToolResult, type ClientOptions, type ComputerCallItem, ConnectionTimeoutError, type ConsoleListener, ConsoleMessage, ContentFrameNotFoundError, type CreateChatCompletionOptions, CreateChatCompletionResponseError, CuaModelRequiredError, type DragAndDropToolResult, ElementNotVisibleError, ExperimentalApiConflictError, ExperimentalNotConfiguredError, type ExtractOptions, type ExtractResult, ExtractTimeoutError, type FillFormField, type FillFormVisionToolResult, type FunctionCallItem, type GoogleServiceAccountCredentials, type GoogleVertexProviderSettings, HandlerNotInitializedError, type HistoryEntry, type InferStagehandSchema, InvalidAISDKModelFormatError, type JsonSchema, type JsonSchemaDocument, type JsonSchemaProperty, LLMClient, type LLMParsedResponse, type LLMResponse, LLMResponseError, type LLMTool, type LLMUsage, LOG_LEVEL_NAMES, type LoadState, type LocalBrowserLaunchOptions, type LogLevel, type LogLine, type Logger, MCPConnectionError, MissingEnvironmentVariableError, MissingLLMConfigurationError, type ModelConfiguration, type ModelOutputContentItem, type ModelProvider, type NonStreamingAgentInstance, type ObserveOptions, ObserveTimeoutError, type OpenAIClientOptions, Page, PageNotFoundError, Response$1 as Response, ResponseBodyError, type ResponseInputItem, type ResponseItem, ResponseParseError, type SafetyCheck, type SafetyConfirmationHandler, type SafetyConfirmationResponse, type ScrollVisionToolResult, V3 as Stagehand, StagehandAPIError, StagehandAPIUnauthorizedError, StagehandClickError, StagehandClosedError, StagehandDefaultError, StagehandDomProcessError, StagehandElementNotFoundError, StagehandEnvironmentError, StagehandError, StagehandEvalError, StagehandHttpError, StagehandIframeError, StagehandInitError, StagehandInvalidArgumentError, type StagehandMetrics, StagehandMissingArgumentError, StagehandNotInitializedError, StagehandResponseBodyError, StagehandResponseParseError, StagehandServerError, StagehandShadowRootMissingError, StagehandShadowSegmentEmptyError, StagehandShadowSegmentNotFoundError, type StagehandZodObject, type StagehandZodSchema, type StreamingAgentInstance, StreamingCallbacksInNonStreamingModeError, TimeoutError, type ToolUseItem, type TypeToolResult, UnsupportedAISDKModelProviderError, UnsupportedModelError, UnsupportedModelProviderError, V3, type V3Env, V3Evaluator, V3FunctionName, type V3Options, type WaitToolResult, XPathResolutionError, ZodSchemaValidationError, connectToMCPServer, defaultExtractSchema, getZodType, injectUrls, isRunningInBun, isZod3Schema, isZod4Schema, jsonSchemaToZod, loadApiKeyFromEnv, localBrowserLaunchOptionsSchema, modelToAgentProviderMap, pageTextSchema, providerEnvVarMap, toGeminiSchema, toJsonSchema, transformSchema, trimTrailingTextNode, validateZodSchema };
|