@browserbasehq/orca 3.0.0-preview.0 → 3.0.0-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +43 -6
- package/dist/lib/StagehandContext.d.ts +25 -0
- package/dist/lib/StagehandPage.d.ts +103 -0
- package/dist/lib/a11y/utils.d.ts +144 -0
- package/dist/lib/agent/AgentClient.d.ts +20 -0
- package/dist/lib/agent/AgentProvider.d.ts +19 -0
- package/dist/lib/agent/AnthropicCUAClient.d.ts +56 -0
- package/dist/lib/agent/GoogleCUAClient.d.ts +63 -0
- package/dist/lib/agent/OpenAICUAClient.d.ts +65 -0
- package/dist/lib/agent/StagehandAgent.d.ts +15 -0
- package/dist/lib/agent/tools/act.d.ts +59 -0
- package/dist/lib/agent/tools/ariaTree.d.ts +11 -0
- package/dist/lib/agent/tools/close.d.ts +22 -0
- package/dist/lib/agent/tools/extract.d.ts +38 -0
- package/dist/lib/agent/tools/fillform.d.ts +37 -0
- package/dist/lib/agent/tools/goto.d.ts +29 -0
- package/dist/lib/agent/tools/index.d.ts +257 -0
- package/dist/lib/agent/tools/navback.d.ts +17 -0
- package/dist/lib/agent/tools/screenshot.d.ts +13 -0
- package/dist/lib/agent/tools/scroll.d.ts +23 -0
- package/dist/lib/agent/tools/wait.d.ts +18 -0
- package/dist/lib/agent/utils/cuaKeyMapping.d.ts +10 -0
- package/dist/lib/agent/utils/imageCompression.d.ts +53 -0
- package/dist/lib/agent/utils/messageProcessing.d.ts +13 -0
- package/dist/lib/browserbaseDefaults.d.ts +9 -0
- package/dist/lib/cache/ActionCache.d.ts +62 -0
- package/dist/lib/cache/BaseCache.d.ts +66 -0
- package/dist/lib/cache/LLMCache.d.ts +22 -0
- package/dist/lib/cache.d.ts +29 -0
- package/dist/lib/dom/elementCheckUtils.d.ts +2 -0
- package/dist/lib/dom/genDomScripts.d.ts +1 -0
- package/dist/lib/dom/index.d.ts +2 -0
- package/dist/lib/dom/process.d.ts +17 -0
- package/dist/lib/dom/utils.d.ts +7 -0
- package/dist/lib/dom/xpathUtils.d.ts +14 -0
- package/dist/lib/handlers/actHandler.d.ts +33 -0
- package/dist/lib/handlers/cuaAgentHandler.d.ts +58 -0
- package/dist/lib/handlers/extractHandler.d.ts +54 -0
- package/dist/lib/handlers/handlerUtils/actHandlerUtils.d.ts +21 -0
- package/dist/lib/handlers/observeHandler.d.ts +40 -0
- package/dist/lib/handlers/stagehandAgentHandler.d.ts +27 -0
- package/dist/lib/index.d.ts +94 -0
- package/dist/lib/llm/AnthropicClient.d.ts +21 -0
- package/dist/lib/llm/CerebrasClient.d.ts +22 -0
- package/dist/lib/llm/GoogleClient.d.ts +24 -0
- package/dist/lib/llm/GroqClient.d.ts +22 -0
- package/dist/lib/llm/LLMClient.d.ts +99 -0
- package/dist/lib/llm/LLMProvider.d.ts +13 -0
- package/dist/lib/llm/OpenAIClient.d.ts +20 -0
- package/dist/lib/llm/aisdk.d.ts +20 -0
- package/dist/lib/mcp/connection.d.ts +11 -0
- package/dist/lib/mcp/utils.d.ts +3 -0
- package/dist/lib/v3/tests/downloads.spec.d.ts +1 -0
- package/dist/lib/v3/tests/v3.bb.config.d.ts +4 -0
- package/dist/lib/v3/v3.d.ts +2 -0
- package/dist/lib/version.d.ts +1 -1
- package/dist/stagehand.config.d.ts +3 -0
- package/dist/types/act.d.ts +50 -0
- package/dist/types/agent.d.ts +143 -0
- package/dist/types/api.d.ts +40 -0
- package/dist/types/browser.d.ts +10 -0
- package/dist/types/context.d.ts +117 -0
- package/dist/types/evals.d.ts +94 -0
- package/dist/types/evaluator.d.ts +40 -0
- package/dist/types/llm.d.ts +11 -0
- package/dist/types/log.d.ts +23 -0
- package/dist/types/model.d.ts +17 -0
- package/dist/types/page.d.ts +38 -0
- package/dist/types/playwright.d.ts +12 -0
- package/dist/types/stagehand.d.ts +330 -0
- package/dist/types/stagehandApiErrors.d.ts +18 -0
- package/dist/types/stagehandErrors.d.ts +104 -0
- package/package.json +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type EvaluateOptions = {
|
|
2
|
+
/** The question to ask about the task state */
|
|
3
|
+
question: string;
|
|
4
|
+
/** The answer to the question */
|
|
5
|
+
answer?: string;
|
|
6
|
+
/** Whether to take a screenshot of the task state, or array of screenshots to evaluate */
|
|
7
|
+
screenshot?: boolean | Buffer[];
|
|
8
|
+
/** Custom system prompt for the evaluator */
|
|
9
|
+
systemPrompt?: string;
|
|
10
|
+
/** Delay in milliseconds before taking the screenshot @default 250 */
|
|
11
|
+
screenshotDelayMs?: number;
|
|
12
|
+
/** The agent's reasoning/thought process for completing the task */
|
|
13
|
+
agentReasoning?: string;
|
|
14
|
+
};
|
|
15
|
+
export type BatchAskOptions = {
|
|
16
|
+
/** Array of questions with optional answers */
|
|
17
|
+
questions: Array<{
|
|
18
|
+
question: string;
|
|
19
|
+
answer?: string;
|
|
20
|
+
}>;
|
|
21
|
+
/** Whether to take a screenshot of the task state */
|
|
22
|
+
screenshot?: boolean;
|
|
23
|
+
/** Custom system prompt for the evaluator */
|
|
24
|
+
systemPrompt?: string;
|
|
25
|
+
/** Delay in milliseconds before taking the screenshot @default 1000 */
|
|
26
|
+
screenshotDelayMs?: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Result of an evaluation
|
|
30
|
+
*/
|
|
31
|
+
export interface EvaluationResult {
|
|
32
|
+
/**
|
|
33
|
+
* The evaluation result ('YES', 'NO', or 'INVALID' if parsing failed or value was unexpected)
|
|
34
|
+
*/
|
|
35
|
+
evaluation: "YES" | "NO" | "INVALID";
|
|
36
|
+
/**
|
|
37
|
+
* The reasoning behind the evaluation
|
|
38
|
+
*/
|
|
39
|
+
reasoning: string;
|
|
40
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LanguageModel } from "ai";
|
|
2
|
+
export interface LLMTool {
|
|
3
|
+
type: "function";
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
parameters: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export type AISDKProvider = (modelName: string) => LanguageModel;
|
|
9
|
+
export type AISDKCustomProvider = (options: {
|
|
10
|
+
apiKey: string;
|
|
11
|
+
}) => AISDKProvider;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type LogLevel = 0 | 1 | 2;
|
|
2
|
+
/**
|
|
3
|
+
* Mapping between numeric log levels and their names
|
|
4
|
+
*
|
|
5
|
+
* 0 - error/warn - Critical issues or important warnings
|
|
6
|
+
* 1 - info - Standard information messages
|
|
7
|
+
* 2 - debug - Detailed information for debugging
|
|
8
|
+
*/
|
|
9
|
+
export declare const LOG_LEVEL_NAMES: Record<LogLevel, string>;
|
|
10
|
+
export type LogLine = {
|
|
11
|
+
id?: string;
|
|
12
|
+
category?: string;
|
|
13
|
+
message: string;
|
|
14
|
+
level?: LogLevel;
|
|
15
|
+
timestamp?: string;
|
|
16
|
+
auxiliary?: {
|
|
17
|
+
[key: string]: {
|
|
18
|
+
value: string;
|
|
19
|
+
type: "object" | "string" | "html" | "integer" | "float" | "boolean";
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type Logger = (logLine: LogLine) => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ClientOptions as AnthropicClientOptions } from "@anthropic-ai/sdk";
|
|
2
|
+
import type { ClientOptions as OpenAIClientOptions } from "openai";
|
|
3
|
+
import { z } from "zod/v3";
|
|
4
|
+
export declare const AvailableModelSchema: z.ZodEnum<["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"]>;
|
|
5
|
+
export type AvailableModel = z.infer<typeof AvailableModelSchema> | string;
|
|
6
|
+
export type ModelProvider = "openai" | "anthropic" | "cerebras" | "groq" | "google" | "aisdk";
|
|
7
|
+
export type ClientOptions = OpenAIClientOptions | AnthropicClientOptions;
|
|
8
|
+
export interface AnthropicJsonSchemaObject {
|
|
9
|
+
definitions?: {
|
|
10
|
+
MySchema?: {
|
|
11
|
+
properties?: Record<string, unknown>;
|
|
12
|
+
required?: string[];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
properties?: Record<string, unknown>;
|
|
16
|
+
required?: string[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Browser as PlaywrightBrowser, BrowserContext as PlaywrightContext, Page as PlaywrightPage, PageScreenshotOptions } from "playwright";
|
|
2
|
+
import { z } from "zod/v3";
|
|
3
|
+
import type { ActOptions, ActResult, ExtractOptions, ExtractResult, ObserveOptions, ObserveResult } from "./stagehand";
|
|
4
|
+
export declare const defaultExtractSchema: z.ZodObject<{
|
|
5
|
+
extraction: z.ZodString;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
extraction?: string;
|
|
8
|
+
}, {
|
|
9
|
+
extraction?: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const pageTextSchema: z.ZodObject<{
|
|
12
|
+
page_text: z.ZodString;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
page_text?: string;
|
|
15
|
+
}, {
|
|
16
|
+
page_text?: string;
|
|
17
|
+
}>;
|
|
18
|
+
export interface StagehandScreenshotOptions extends PageScreenshotOptions {
|
|
19
|
+
/** Controls whether to use CDP for screenshots in Browserbase environment. Defaults to true. */
|
|
20
|
+
useCDP?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface Page extends Omit<PlaywrightPage, "on" | "screenshot"> {
|
|
23
|
+
act(action: string): Promise<ActResult>;
|
|
24
|
+
act(options: ActOptions): Promise<ActResult>;
|
|
25
|
+
act(observation: ObserveResult): Promise<ActResult>;
|
|
26
|
+
extract(instruction: string): Promise<ExtractResult<typeof defaultExtractSchema>>;
|
|
27
|
+
extract<T extends z.AnyZodObject>(options: ExtractOptions<T>): Promise<ExtractResult<T>>;
|
|
28
|
+
extract(): Promise<ExtractResult<typeof pageTextSchema>>;
|
|
29
|
+
observe(): Promise<ObserveResult[]>;
|
|
30
|
+
observe(instruction: string): Promise<ObserveResult[]>;
|
|
31
|
+
observe(options?: ObserveOptions): Promise<ObserveResult[]>;
|
|
32
|
+
screenshot(options?: StagehandScreenshotOptions): Promise<Buffer>;
|
|
33
|
+
on: {
|
|
34
|
+
(event: "popup", listener: (page: Page) => unknown): Page;
|
|
35
|
+
} & PlaywrightPage["on"];
|
|
36
|
+
}
|
|
37
|
+
export type BrowserContext = PlaywrightContext;
|
|
38
|
+
export type Browser = PlaywrightBrowser;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class PlaywrightCommandException extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
export declare class PlaywrightCommandMethodNotSupportedException extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
export interface GotoOptions {
|
|
8
|
+
timeout?: number;
|
|
9
|
+
waitUntil?: "load" | "domcontentloaded" | "networkidle" | "commit";
|
|
10
|
+
referer?: string;
|
|
11
|
+
frameId?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import Browserbase from "@browserbasehq/sdk";
|
|
2
|
+
import { Client } from "@modelcontextprotocol/sdk/dist/esm/client";
|
|
3
|
+
import { ToolSet } from "ai";
|
|
4
|
+
import { Cookie } from "playwright";
|
|
5
|
+
import { z } from "zod/v3";
|
|
6
|
+
import { LLMClient } from "../lib/llm/LLMClient";
|
|
7
|
+
import { LLMProvider } from "../lib/llm/LLMProvider";
|
|
8
|
+
import { AgentProviderType } from "./agent";
|
|
9
|
+
import { LogLine } from "./log";
|
|
10
|
+
import { AvailableModel, ClientOptions } from "./model";
|
|
11
|
+
export interface ConstructorParams {
|
|
12
|
+
/**
|
|
13
|
+
* The environment to use for Stagehand
|
|
14
|
+
*/
|
|
15
|
+
env: "LOCAL" | "BROWSERBASE";
|
|
16
|
+
/**
|
|
17
|
+
* Your Browserbase API key
|
|
18
|
+
*/
|
|
19
|
+
apiKey?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Your Browserbase project ID
|
|
22
|
+
*/
|
|
23
|
+
projectId?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The verbosity of the Stagehand logger
|
|
26
|
+
* 0 - No logs
|
|
27
|
+
* 1 - Only errors
|
|
28
|
+
* 2 - All logs
|
|
29
|
+
*/
|
|
30
|
+
verbose?: 0 | 1 | 2;
|
|
31
|
+
/**
|
|
32
|
+
* The LLM provider to use for Stagehand
|
|
33
|
+
* See
|
|
34
|
+
*/
|
|
35
|
+
llmProvider?: LLMProvider;
|
|
36
|
+
/**
|
|
37
|
+
* The logger to use for Stagehand
|
|
38
|
+
*/
|
|
39
|
+
logger?: (message: LogLine) => void | Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* The timeout to use for the DOM to settle
|
|
42
|
+
* @default 10000
|
|
43
|
+
*/
|
|
44
|
+
domSettleTimeoutMs?: number;
|
|
45
|
+
/**
|
|
46
|
+
* The parameters to use for creating a Browserbase session
|
|
47
|
+
* See https://docs.browserbase.com/reference/api/create-a-session
|
|
48
|
+
* Note: projectId is optional here as it will use the main projectId parameter if not provided
|
|
49
|
+
*/
|
|
50
|
+
browserbaseSessionCreateParams?: Omit<Browserbase.Sessions.SessionCreateParams, "projectId"> & {
|
|
51
|
+
projectId?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Enable caching of LLM responses
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
enableCaching?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The ID of a Browserbase session to resume
|
|
60
|
+
*/
|
|
61
|
+
browserbaseSessionID?: string;
|
|
62
|
+
/**
|
|
63
|
+
* The model to use for Stagehand
|
|
64
|
+
*/
|
|
65
|
+
modelName?: AvailableModel;
|
|
66
|
+
/**
|
|
67
|
+
* The LLM client to use for Stagehand
|
|
68
|
+
*/
|
|
69
|
+
llmClient?: LLMClient;
|
|
70
|
+
/**
|
|
71
|
+
* The parameters to use for the LLM client
|
|
72
|
+
* Useful for parameterizing LLM API Keys
|
|
73
|
+
*/
|
|
74
|
+
modelClientOptions?: ClientOptions;
|
|
75
|
+
/**
|
|
76
|
+
* Customize the Stagehand system prompt
|
|
77
|
+
*/
|
|
78
|
+
systemPrompt?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Offload Stagehand method calls to the Stagehand API.
|
|
81
|
+
* Must have a valid API key to use
|
|
82
|
+
*/
|
|
83
|
+
useAPI?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Wait for captchas to be solved after navigation when using Browserbase environment.
|
|
86
|
+
*
|
|
87
|
+
* @default false
|
|
88
|
+
*/
|
|
89
|
+
waitForCaptchaSolves?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* The parameters to use for launching a local browser
|
|
92
|
+
*/
|
|
93
|
+
localBrowserLaunchOptions?: LocalBrowserLaunchOptions;
|
|
94
|
+
/**
|
|
95
|
+
* Log the inference to a file
|
|
96
|
+
*/
|
|
97
|
+
logInferenceToFile?: boolean;
|
|
98
|
+
selfHeal?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Disable Pino (helpful for Next.js or test environments)
|
|
101
|
+
*/
|
|
102
|
+
disablePino?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Experimental Flag: Enables the latest experimental features
|
|
105
|
+
*/
|
|
106
|
+
experimental?: boolean;
|
|
107
|
+
}
|
|
108
|
+
export interface InitResult {
|
|
109
|
+
debugUrl: string;
|
|
110
|
+
sessionUrl: string;
|
|
111
|
+
sessionId: string;
|
|
112
|
+
}
|
|
113
|
+
export interface ActOptions {
|
|
114
|
+
action: string;
|
|
115
|
+
modelName?: AvailableModel;
|
|
116
|
+
modelClientOptions?: ClientOptions;
|
|
117
|
+
variables?: Record<string, string>;
|
|
118
|
+
domSettleTimeoutMs?: number;
|
|
119
|
+
timeoutMs?: number;
|
|
120
|
+
iframes?: boolean;
|
|
121
|
+
frameId?: string;
|
|
122
|
+
}
|
|
123
|
+
export interface ActResult {
|
|
124
|
+
success: boolean;
|
|
125
|
+
message: string;
|
|
126
|
+
action: string;
|
|
127
|
+
}
|
|
128
|
+
export interface ExtractOptions<T extends z.AnyZodObject> {
|
|
129
|
+
instruction?: string;
|
|
130
|
+
schema?: T;
|
|
131
|
+
modelName?: AvailableModel;
|
|
132
|
+
modelClientOptions?: ClientOptions;
|
|
133
|
+
domSettleTimeoutMs?: number;
|
|
134
|
+
/**
|
|
135
|
+
* @deprecated The `useTextExtract` parameter has no effect in this version of Stagehand and will be removed in later versions.
|
|
136
|
+
*/
|
|
137
|
+
useTextExtract?: boolean;
|
|
138
|
+
selector?: string;
|
|
139
|
+
iframes?: boolean;
|
|
140
|
+
frameId?: string;
|
|
141
|
+
}
|
|
142
|
+
export type ExtractResult<T extends z.AnyZodObject> = z.infer<T>;
|
|
143
|
+
export interface ObserveOptions {
|
|
144
|
+
instruction?: string;
|
|
145
|
+
modelName?: AvailableModel;
|
|
146
|
+
modelClientOptions?: ClientOptions;
|
|
147
|
+
domSettleTimeoutMs?: number;
|
|
148
|
+
returnAction?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* @deprecated The `onlyVisible` parameter has no effect in this version of Stagehand and will be removed in later versions.
|
|
151
|
+
*/
|
|
152
|
+
onlyVisible?: boolean;
|
|
153
|
+
drawOverlay?: boolean;
|
|
154
|
+
iframes?: boolean;
|
|
155
|
+
frameId?: string;
|
|
156
|
+
}
|
|
157
|
+
export interface ObserveResult {
|
|
158
|
+
selector: string;
|
|
159
|
+
description: string;
|
|
160
|
+
backendNodeId?: number;
|
|
161
|
+
method?: string;
|
|
162
|
+
arguments?: string[];
|
|
163
|
+
}
|
|
164
|
+
export interface LocalBrowserLaunchOptions {
|
|
165
|
+
args?: string[];
|
|
166
|
+
chromiumSandbox?: boolean;
|
|
167
|
+
devtools?: boolean;
|
|
168
|
+
env?: {
|
|
169
|
+
[key: string]: string | undefined;
|
|
170
|
+
};
|
|
171
|
+
executablePath?: string;
|
|
172
|
+
handleSIGHUP?: boolean;
|
|
173
|
+
handleSIGINT?: boolean;
|
|
174
|
+
handleSIGTERM?: boolean;
|
|
175
|
+
headless?: boolean;
|
|
176
|
+
ignoreDefaultArgs?: boolean | Array<string>;
|
|
177
|
+
proxy?: {
|
|
178
|
+
server: string;
|
|
179
|
+
bypass?: string;
|
|
180
|
+
username?: string;
|
|
181
|
+
password?: string;
|
|
182
|
+
};
|
|
183
|
+
tracesDir?: string;
|
|
184
|
+
userDataDir?: string;
|
|
185
|
+
preserveUserDataDir?: boolean;
|
|
186
|
+
acceptDownloads?: boolean;
|
|
187
|
+
downloadsPath?: string;
|
|
188
|
+
extraHTTPHeaders?: Record<string, string>;
|
|
189
|
+
geolocation?: {
|
|
190
|
+
latitude: number;
|
|
191
|
+
longitude: number;
|
|
192
|
+
accuracy?: number;
|
|
193
|
+
};
|
|
194
|
+
hasTouch?: boolean;
|
|
195
|
+
ignoreHTTPSErrors?: boolean;
|
|
196
|
+
locale?: string;
|
|
197
|
+
permissions?: Array<string>;
|
|
198
|
+
recordHar?: {
|
|
199
|
+
omitContent?: boolean;
|
|
200
|
+
content?: "omit" | "embed" | "attach";
|
|
201
|
+
path: string;
|
|
202
|
+
mode?: "full" | "minimal";
|
|
203
|
+
urlFilter?: string | RegExp;
|
|
204
|
+
};
|
|
205
|
+
recordVideo?: {
|
|
206
|
+
dir: string;
|
|
207
|
+
size?: {
|
|
208
|
+
width: number;
|
|
209
|
+
height: number;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
viewport?: {
|
|
213
|
+
width: number;
|
|
214
|
+
height: number;
|
|
215
|
+
};
|
|
216
|
+
deviceScaleFactor?: number;
|
|
217
|
+
timezoneId?: string;
|
|
218
|
+
bypassCSP?: boolean;
|
|
219
|
+
cookies?: Cookie[];
|
|
220
|
+
cdpUrl?: string;
|
|
221
|
+
}
|
|
222
|
+
export interface StagehandMetrics {
|
|
223
|
+
actPromptTokens: number;
|
|
224
|
+
actCompletionTokens: number;
|
|
225
|
+
actInferenceTimeMs: number;
|
|
226
|
+
extractPromptTokens: number;
|
|
227
|
+
extractCompletionTokens: number;
|
|
228
|
+
extractInferenceTimeMs: number;
|
|
229
|
+
observePromptTokens: number;
|
|
230
|
+
observeCompletionTokens: number;
|
|
231
|
+
observeInferenceTimeMs: number;
|
|
232
|
+
agentPromptTokens: number;
|
|
233
|
+
agentCompletionTokens: number;
|
|
234
|
+
agentInferenceTimeMs: number;
|
|
235
|
+
totalPromptTokens: number;
|
|
236
|
+
totalCompletionTokens: number;
|
|
237
|
+
totalInferenceTimeMs: number;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Options for executing a task with an agent
|
|
241
|
+
*/
|
|
242
|
+
export interface AgentExecuteParams {
|
|
243
|
+
/**
|
|
244
|
+
* The instruction to execute with the agent
|
|
245
|
+
*/
|
|
246
|
+
instruction: string;
|
|
247
|
+
/**
|
|
248
|
+
* Maximum number of steps the agent can take to complete the task
|
|
249
|
+
* @default 10
|
|
250
|
+
*/
|
|
251
|
+
maxSteps?: number;
|
|
252
|
+
/**
|
|
253
|
+
* Take a screenshot automatically before each agent step
|
|
254
|
+
* @default true
|
|
255
|
+
*/
|
|
256
|
+
autoScreenshot?: boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Wait time in milliseconds between agent actions
|
|
259
|
+
* @default 0
|
|
260
|
+
*/
|
|
261
|
+
waitBetweenActions?: number;
|
|
262
|
+
/**
|
|
263
|
+
* Additional context to provide to the agent
|
|
264
|
+
*/
|
|
265
|
+
context?: string;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Configuration for agent functionality
|
|
269
|
+
*/
|
|
270
|
+
export interface AgentConfig {
|
|
271
|
+
/**
|
|
272
|
+
* The provider to use for agent functionality
|
|
273
|
+
*/
|
|
274
|
+
provider?: AgentProviderType;
|
|
275
|
+
/**
|
|
276
|
+
* The model to use for agent functionality
|
|
277
|
+
*/
|
|
278
|
+
model?: string;
|
|
279
|
+
/**
|
|
280
|
+
* The model to use for tool execution (observe/act calls within agent tools).
|
|
281
|
+
* If not specified, inherits from the main model configuration.
|
|
282
|
+
* Format: "provider/model" (e.g., "openai/gpt-4o-mini", "google/gemini-2.0-flash-exp")
|
|
283
|
+
*/
|
|
284
|
+
executionModel?: string;
|
|
285
|
+
/**
|
|
286
|
+
* Custom instructions to provide to the agent
|
|
287
|
+
*/
|
|
288
|
+
instructions?: string;
|
|
289
|
+
/**
|
|
290
|
+
* Additional options to pass to the agent client
|
|
291
|
+
*/
|
|
292
|
+
options?: Record<string, unknown>;
|
|
293
|
+
/**
|
|
294
|
+
* MCP integrations - Array of Client objects
|
|
295
|
+
*/
|
|
296
|
+
integrations?: (Client | string)[];
|
|
297
|
+
/**
|
|
298
|
+
* Tools passed to the agent client
|
|
299
|
+
*/
|
|
300
|
+
tools?: ToolSet;
|
|
301
|
+
}
|
|
302
|
+
export declare enum StagehandFunctionName {
|
|
303
|
+
ACT = "ACT",
|
|
304
|
+
EXTRACT = "EXTRACT",
|
|
305
|
+
OBSERVE = "OBSERVE",
|
|
306
|
+
AGENT = "AGENT"
|
|
307
|
+
}
|
|
308
|
+
export interface HistoryEntry {
|
|
309
|
+
method: "act" | "extract" | "observe" | "navigate";
|
|
310
|
+
parameters: unknown;
|
|
311
|
+
result: unknown;
|
|
312
|
+
timestamp: string;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Represents a path through a Zod schema from the root object down to a
|
|
316
|
+
* particular field. The `segments` array describes the chain of keys/indices.
|
|
317
|
+
*
|
|
318
|
+
* - **String** segments indicate object property names.
|
|
319
|
+
* - **Number** segments indicate array indices.
|
|
320
|
+
*
|
|
321
|
+
* For example, `["users", 0, "homepage"]` might describe reaching
|
|
322
|
+
* the `homepage` field in `schema.users[0].homepage`.
|
|
323
|
+
*/
|
|
324
|
+
export interface ZodPathSegments {
|
|
325
|
+
/**
|
|
326
|
+
* The ordered list of keys/indices leading from the schema root
|
|
327
|
+
* to the targeted field.
|
|
328
|
+
*/
|
|
329
|
+
segments: Array<string | number>;
|
|
330
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class StagehandAPIError extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
export declare class StagehandAPIUnauthorizedError extends StagehandAPIError {
|
|
5
|
+
constructor(message?: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class StagehandHttpError extends StagehandAPIError {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class StagehandServerError extends StagehandAPIError {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class StagehandResponseBodyError extends StagehandAPIError {
|
|
14
|
+
constructor();
|
|
15
|
+
}
|
|
16
|
+
export declare class StagehandResponseParseError extends StagehandAPIError {
|
|
17
|
+
constructor(message: string);
|
|
18
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ZodError } from "zod/v3";
|
|
2
|
+
export declare class StagehandError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class StagehandDefaultError extends StagehandError {
|
|
6
|
+
constructor(error?: unknown);
|
|
7
|
+
}
|
|
8
|
+
export declare class StagehandEnvironmentError extends StagehandError {
|
|
9
|
+
constructor(currentEnvironment: string, requiredEnvironment: string, feature: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class MissingEnvironmentVariableError extends StagehandError {
|
|
12
|
+
constructor(missingEnvironmentVariable: string, feature: string);
|
|
13
|
+
}
|
|
14
|
+
export declare class UnsupportedModelError extends StagehandError {
|
|
15
|
+
constructor(supportedModels: string[], feature?: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class UnsupportedModelProviderError extends StagehandError {
|
|
18
|
+
constructor(supportedProviders: string[], feature?: string);
|
|
19
|
+
}
|
|
20
|
+
export declare class UnsupportedAISDKModelProviderError extends StagehandError {
|
|
21
|
+
constructor(provider: string, supportedProviders: string[]);
|
|
22
|
+
}
|
|
23
|
+
export declare class InvalidAISDKModelFormatError extends StagehandError {
|
|
24
|
+
constructor(modelName: string);
|
|
25
|
+
}
|
|
26
|
+
export declare class StagehandNotInitializedError extends StagehandError {
|
|
27
|
+
constructor(prop: string);
|
|
28
|
+
}
|
|
29
|
+
export declare class BrowserbaseSessionNotFoundError extends StagehandError {
|
|
30
|
+
constructor();
|
|
31
|
+
}
|
|
32
|
+
export declare class CaptchaTimeoutError extends StagehandError {
|
|
33
|
+
constructor();
|
|
34
|
+
}
|
|
35
|
+
export declare class MissingLLMConfigurationError extends StagehandError {
|
|
36
|
+
constructor();
|
|
37
|
+
}
|
|
38
|
+
export declare class HandlerNotInitializedError extends StagehandError {
|
|
39
|
+
constructor(handlerType: string);
|
|
40
|
+
}
|
|
41
|
+
export declare class StagehandInvalidArgumentError extends StagehandError {
|
|
42
|
+
constructor(message: string);
|
|
43
|
+
}
|
|
44
|
+
export declare class StagehandElementNotFoundError extends StagehandError {
|
|
45
|
+
constructor(xpaths: string[]);
|
|
46
|
+
}
|
|
47
|
+
export declare class AgentScreenshotProviderError extends StagehandError {
|
|
48
|
+
constructor(message: string);
|
|
49
|
+
}
|
|
50
|
+
export declare class StagehandMissingArgumentError extends StagehandError {
|
|
51
|
+
constructor(message: string);
|
|
52
|
+
}
|
|
53
|
+
export declare class CreateChatCompletionResponseError extends StagehandError {
|
|
54
|
+
constructor(message: string);
|
|
55
|
+
}
|
|
56
|
+
export declare class StagehandEvalError extends StagehandError {
|
|
57
|
+
constructor(message: string);
|
|
58
|
+
}
|
|
59
|
+
export declare class StagehandDomProcessError extends StagehandError {
|
|
60
|
+
constructor(message: string);
|
|
61
|
+
}
|
|
62
|
+
export declare class StagehandClickError extends StagehandError {
|
|
63
|
+
constructor(message: string, selector: string);
|
|
64
|
+
}
|
|
65
|
+
export declare class LLMResponseError extends StagehandError {
|
|
66
|
+
constructor(primitive: string, message: string);
|
|
67
|
+
}
|
|
68
|
+
export declare class StagehandIframeError extends StagehandError {
|
|
69
|
+
constructor(frameUrl: string, message: string);
|
|
70
|
+
}
|
|
71
|
+
export declare class ContentFrameNotFoundError extends StagehandError {
|
|
72
|
+
constructor(selector: string);
|
|
73
|
+
}
|
|
74
|
+
export declare class XPathResolutionError extends StagehandError {
|
|
75
|
+
constructor(xpath: string);
|
|
76
|
+
}
|
|
77
|
+
export declare class ExperimentalApiConflictError extends StagehandError {
|
|
78
|
+
constructor();
|
|
79
|
+
}
|
|
80
|
+
export declare class ExperimentalNotConfiguredError extends StagehandError {
|
|
81
|
+
constructor(featureName: string);
|
|
82
|
+
}
|
|
83
|
+
export declare class ZodSchemaValidationError extends Error {
|
|
84
|
+
readonly received: unknown;
|
|
85
|
+
readonly issues: ReturnType<ZodError["format"]>;
|
|
86
|
+
constructor(received: unknown, issues: ReturnType<ZodError["format"]>);
|
|
87
|
+
}
|
|
88
|
+
export declare class StagehandInitError extends StagehandError {
|
|
89
|
+
constructor(message: string);
|
|
90
|
+
}
|
|
91
|
+
export declare class MCPConnectionError extends StagehandError {
|
|
92
|
+
readonly serverUrl: string;
|
|
93
|
+
readonly originalError: unknown;
|
|
94
|
+
constructor(serverUrl: string, originalError: unknown);
|
|
95
|
+
}
|
|
96
|
+
export declare class StagehandShadowRootMissingError extends StagehandError {
|
|
97
|
+
constructor(detail?: string);
|
|
98
|
+
}
|
|
99
|
+
export declare class StagehandShadowSegmentEmptyError extends StagehandError {
|
|
100
|
+
constructor();
|
|
101
|
+
}
|
|
102
|
+
export declare class StagehandShadowSegmentNotFoundError extends StagehandError {
|
|
103
|
+
constructor(segment: string, hint?: string);
|
|
104
|
+
}
|
package/package.json
CHANGED