@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,99 @@
|
|
|
1
|
+
import { LLMTool } from "@/types/llm";
|
|
2
|
+
import { embed, embedMany, experimental_generateImage, experimental_generateSpeech, experimental_transcribe, generateObject, generateText, LanguageModel, streamObject, streamText } from "ai";
|
|
3
|
+
import { ZodType } from "zod/v3";
|
|
4
|
+
import { LogLine } from "../../types/log";
|
|
5
|
+
import { AvailableModel, ClientOptions } from "../../types/model";
|
|
6
|
+
export interface ChatMessage {
|
|
7
|
+
role: "system" | "user" | "assistant";
|
|
8
|
+
content: ChatMessageContent;
|
|
9
|
+
}
|
|
10
|
+
export type ChatMessageContent = string | (ChatMessageImageContent | ChatMessageTextContent)[];
|
|
11
|
+
export interface ChatMessageImageContent {
|
|
12
|
+
type: string;
|
|
13
|
+
image_url?: {
|
|
14
|
+
url: string;
|
|
15
|
+
};
|
|
16
|
+
text?: string;
|
|
17
|
+
source?: {
|
|
18
|
+
type: string;
|
|
19
|
+
media_type: string;
|
|
20
|
+
data: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface ChatMessageTextContent {
|
|
24
|
+
type: string;
|
|
25
|
+
text: string;
|
|
26
|
+
}
|
|
27
|
+
export 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.";
|
|
28
|
+
export interface ChatCompletionOptions {
|
|
29
|
+
messages: ChatMessage[];
|
|
30
|
+
temperature?: number;
|
|
31
|
+
top_p?: number;
|
|
32
|
+
frequency_penalty?: number;
|
|
33
|
+
presence_penalty?: number;
|
|
34
|
+
image?: {
|
|
35
|
+
buffer: Buffer;
|
|
36
|
+
description?: string;
|
|
37
|
+
};
|
|
38
|
+
response_model?: {
|
|
39
|
+
name: string;
|
|
40
|
+
schema: ZodType;
|
|
41
|
+
};
|
|
42
|
+
tools?: LLMTool[];
|
|
43
|
+
tool_choice?: "auto" | "none" | "required";
|
|
44
|
+
maxTokens?: number;
|
|
45
|
+
requestId?: string;
|
|
46
|
+
}
|
|
47
|
+
export type LLMResponse = {
|
|
48
|
+
id: string;
|
|
49
|
+
object: string;
|
|
50
|
+
created: number;
|
|
51
|
+
model: string;
|
|
52
|
+
choices: {
|
|
53
|
+
index: number;
|
|
54
|
+
message: {
|
|
55
|
+
role: string;
|
|
56
|
+
content: string | null;
|
|
57
|
+
tool_calls: {
|
|
58
|
+
id: string;
|
|
59
|
+
type: string;
|
|
60
|
+
function: {
|
|
61
|
+
name: string;
|
|
62
|
+
arguments: string;
|
|
63
|
+
};
|
|
64
|
+
}[];
|
|
65
|
+
};
|
|
66
|
+
finish_reason: string;
|
|
67
|
+
}[];
|
|
68
|
+
usage: {
|
|
69
|
+
prompt_tokens: number;
|
|
70
|
+
completion_tokens: number;
|
|
71
|
+
total_tokens: number;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export interface CreateChatCompletionOptions {
|
|
75
|
+
options: ChatCompletionOptions;
|
|
76
|
+
logger: (message: LogLine) => void;
|
|
77
|
+
retries?: number;
|
|
78
|
+
}
|
|
79
|
+
export declare abstract class LLMClient {
|
|
80
|
+
type: "openai" | "anthropic" | "cerebras" | "groq" | (string & {});
|
|
81
|
+
modelName: AvailableModel | (string & {});
|
|
82
|
+
hasVision: boolean;
|
|
83
|
+
clientOptions: ClientOptions;
|
|
84
|
+
userProvidedInstructions?: string;
|
|
85
|
+
constructor(modelName: AvailableModel, userProvidedInstructions?: string);
|
|
86
|
+
abstract createChatCompletion<T = LLMResponse & {
|
|
87
|
+
usage?: LLMResponse["usage"];
|
|
88
|
+
}>(options: CreateChatCompletionOptions): Promise<T>;
|
|
89
|
+
generateObject: typeof generateObject;
|
|
90
|
+
generateText: typeof generateText;
|
|
91
|
+
streamText: typeof streamText;
|
|
92
|
+
streamObject: typeof streamObject;
|
|
93
|
+
generateImage: typeof experimental_generateImage;
|
|
94
|
+
embed: typeof embed;
|
|
95
|
+
embedMany: typeof embedMany;
|
|
96
|
+
transcribe: typeof experimental_transcribe;
|
|
97
|
+
generateSpeech: typeof experimental_generateSpeech;
|
|
98
|
+
getLanguageModel?(): LanguageModel;
|
|
99
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LogLine } from "../../types/log";
|
|
2
|
+
import { AvailableModel, ClientOptions, ModelProvider } from "../../types/model";
|
|
3
|
+
import { LLMClient } from "./LLMClient";
|
|
4
|
+
export declare function getAISDKLanguageModel(subProvider: string, subModelName: string, apiKey?: string, baseURL?: string): import("ai/dist").LanguageModelV1;
|
|
5
|
+
export declare class LLMProvider {
|
|
6
|
+
private logger;
|
|
7
|
+
private enableCaching;
|
|
8
|
+
private cache;
|
|
9
|
+
constructor(logger: (message: LogLine) => void, enableCaching: boolean);
|
|
10
|
+
cleanRequestCache(requestId: string): void;
|
|
11
|
+
getClient(modelName: AvailableModel, clientOptions?: ClientOptions): LLMClient;
|
|
12
|
+
static getModelProvider(modelName: AvailableModel): ModelProvider;
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ClientOptions } from "openai";
|
|
2
|
+
import { LogLine } from "../../types/log";
|
|
3
|
+
import { AvailableModel } from "../../types/model";
|
|
4
|
+
import { LLMCache } from "../cache/LLMCache";
|
|
5
|
+
import { CreateChatCompletionOptions, LLMClient, LLMResponse } from "./LLMClient";
|
|
6
|
+
export declare class OpenAIClient extends LLMClient {
|
|
7
|
+
type: "openai";
|
|
8
|
+
private client;
|
|
9
|
+
private cache;
|
|
10
|
+
private enableCaching;
|
|
11
|
+
clientOptions: ClientOptions;
|
|
12
|
+
constructor({ enableCaching, cache, modelName, clientOptions, }: {
|
|
13
|
+
logger: (message: LogLine) => void;
|
|
14
|
+
enableCaching?: boolean;
|
|
15
|
+
cache?: LLMCache;
|
|
16
|
+
modelName: AvailableModel;
|
|
17
|
+
clientOptions?: ClientOptions;
|
|
18
|
+
});
|
|
19
|
+
createChatCompletion<T = LLMResponse>({ options: optionsInitial, logger, retries, }: CreateChatCompletionOptions): Promise<T>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LanguageModel } from "ai";
|
|
2
|
+
import { ChatCompletion } from "openai/resources";
|
|
3
|
+
import { LogLine } from "../../types/log";
|
|
4
|
+
import { LLMCache } from "../cache/LLMCache";
|
|
5
|
+
import { CreateChatCompletionOptions, LLMClient } from "./LLMClient";
|
|
6
|
+
export declare class AISdkClient extends LLMClient {
|
|
7
|
+
type: "aisdk";
|
|
8
|
+
private model;
|
|
9
|
+
private logger?;
|
|
10
|
+
private cache;
|
|
11
|
+
private enableCaching;
|
|
12
|
+
constructor({ model, logger, enableCaching, cache, }: {
|
|
13
|
+
model: LanguageModel;
|
|
14
|
+
logger?: (message: LogLine) => void;
|
|
15
|
+
enableCaching?: boolean;
|
|
16
|
+
cache?: LLMCache;
|
|
17
|
+
});
|
|
18
|
+
getLanguageModel(): LanguageModel;
|
|
19
|
+
createChatCompletion<T = ChatCompletion>({ options, }: CreateChatCompletionOptions): Promise<T>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Client, ClientOptions } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
+
export interface ConnectToMCPServerOptions {
|
|
3
|
+
serverUrl: string | URL;
|
|
4
|
+
clientOptions?: ClientOptions;
|
|
5
|
+
}
|
|
6
|
+
export interface StdioServerConfig {
|
|
7
|
+
command: string;
|
|
8
|
+
args?: string[];
|
|
9
|
+
env?: Record<string, string>;
|
|
10
|
+
}
|
|
11
|
+
export declare const connectToMCPServer: (serverConfig: string | URL | StdioServerConfig | ConnectToMCPServerOptions) => Promise<Client>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/lib/v3/v3.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export declare class V3 {
|
|
|
36
36
|
private llmProvider;
|
|
37
37
|
private readonly domSettleTimeoutMs?;
|
|
38
38
|
private _isClosing;
|
|
39
|
+
browserbaseSessionId?: string;
|
|
39
40
|
private _onCdpClosed;
|
|
40
41
|
readonly experimental: boolean;
|
|
41
42
|
readonly logInferenceToFile: boolean;
|
|
@@ -78,6 +79,7 @@ export declare class V3 {
|
|
|
78
79
|
init(): Promise<void>;
|
|
79
80
|
/** Apply post-connect local browser options that require CDP. */
|
|
80
81
|
private _applyPostConnectLocalOptions;
|
|
82
|
+
private _ensureBrowserbaseDownloadsEnabled;
|
|
81
83
|
/**
|
|
82
84
|
* Run an "act" instruction through the ActHandler.
|
|
83
85
|
*
|
package/dist/lib/version.d.ts
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { LLMClient } from "../lib/llm/LLMClient";
|
|
2
|
+
import { Locator } from "playwright";
|
|
3
|
+
import { Logger } from "@/types/log";
|
|
4
|
+
import { StagehandPage } from "@/lib/StagehandPage";
|
|
5
|
+
export interface ActCommandParams {
|
|
6
|
+
action: string;
|
|
7
|
+
steps?: string;
|
|
8
|
+
domElements: string;
|
|
9
|
+
llmClient: LLMClient;
|
|
10
|
+
retries?: number;
|
|
11
|
+
logger: (message: {
|
|
12
|
+
category?: string;
|
|
13
|
+
message: string;
|
|
14
|
+
}) => void;
|
|
15
|
+
requestId: string;
|
|
16
|
+
variables?: Record<string, string>;
|
|
17
|
+
userProvidedInstructions?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ActCommandResult {
|
|
20
|
+
method: string;
|
|
21
|
+
element: number;
|
|
22
|
+
args: unknown[];
|
|
23
|
+
completed: boolean;
|
|
24
|
+
step: string;
|
|
25
|
+
why?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare enum SupportedPlaywrightAction {
|
|
28
|
+
CLICK = "click",
|
|
29
|
+
FILL = "fill",
|
|
30
|
+
TYPE = "type",
|
|
31
|
+
PRESS = "press",
|
|
32
|
+
SCROLL = "scrollTo",
|
|
33
|
+
NEXT_CHUNK = "nextChunk",
|
|
34
|
+
PREV_CHUNK = "prevChunk",
|
|
35
|
+
SELECT_OPTION_FROM_DROPDOWN = "selectOptionFromDropdown"
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A context object to hold all parameters that might be needed by
|
|
39
|
+
* any of the methods in the `methodHandlerMap`
|
|
40
|
+
*/
|
|
41
|
+
export interface MethodHandlerContext {
|
|
42
|
+
method: string;
|
|
43
|
+
locator: Locator;
|
|
44
|
+
xpath: string;
|
|
45
|
+
args: unknown[];
|
|
46
|
+
logger: Logger;
|
|
47
|
+
stagehandPage: StagehandPage;
|
|
48
|
+
initialUrl: string;
|
|
49
|
+
domSettleTimeoutMs?: number;
|
|
50
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { LogLine } from "./log";
|
|
2
|
+
import { ObserveResult } from "./stagehand";
|
|
3
|
+
export interface ActToolResult {
|
|
4
|
+
success: boolean;
|
|
5
|
+
action?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
isIframe?: boolean;
|
|
8
|
+
playwrightArguments?: ObserveResult | null;
|
|
9
|
+
}
|
|
10
|
+
export interface AgentAction {
|
|
11
|
+
type: string;
|
|
12
|
+
reasoning?: string;
|
|
13
|
+
taskCompleted?: boolean;
|
|
14
|
+
action?: string;
|
|
15
|
+
timeMs?: number;
|
|
16
|
+
pageText?: string;
|
|
17
|
+
pageUrl?: string;
|
|
18
|
+
instruction?: string;
|
|
19
|
+
playwrightArguments?: ObserveResult | null;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
export interface AgentResult {
|
|
23
|
+
success: boolean;
|
|
24
|
+
message: string;
|
|
25
|
+
actions: AgentAction[];
|
|
26
|
+
completed: boolean;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
usage?: {
|
|
29
|
+
input_tokens: number;
|
|
30
|
+
output_tokens: number;
|
|
31
|
+
inference_time_ms: number;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface AgentOptions {
|
|
35
|
+
maxSteps?: number;
|
|
36
|
+
autoScreenshot?: boolean;
|
|
37
|
+
waitBetweenActions?: number;
|
|
38
|
+
context?: string;
|
|
39
|
+
highlightCursor?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface AgentExecuteOptions extends AgentOptions {
|
|
42
|
+
instruction: string;
|
|
43
|
+
}
|
|
44
|
+
export type AgentProviderType = "openai" | "anthropic" | "google";
|
|
45
|
+
export interface AgentClientOptions {
|
|
46
|
+
apiKey: string;
|
|
47
|
+
organization?: string;
|
|
48
|
+
baseURL?: string;
|
|
49
|
+
defaultMaxSteps?: number;
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
}
|
|
52
|
+
export type AgentType = "openai" | "anthropic" | "google";
|
|
53
|
+
export interface AgentExecutionOptions {
|
|
54
|
+
options: AgentExecuteOptions;
|
|
55
|
+
logger: (message: LogLine) => void;
|
|
56
|
+
retries?: number;
|
|
57
|
+
}
|
|
58
|
+
export interface AgentHandlerOptions {
|
|
59
|
+
modelName: string;
|
|
60
|
+
clientOptions?: Record<string, unknown>;
|
|
61
|
+
userProvidedInstructions?: string;
|
|
62
|
+
agentType: AgentType;
|
|
63
|
+
experimental?: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface ActionExecutionResult {
|
|
66
|
+
success: boolean;
|
|
67
|
+
error?: string;
|
|
68
|
+
data?: unknown;
|
|
69
|
+
}
|
|
70
|
+
export interface ToolUseItem extends ResponseItem {
|
|
71
|
+
type: "tool_use";
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
input: Record<string, unknown>;
|
|
75
|
+
}
|
|
76
|
+
export interface AnthropicMessage {
|
|
77
|
+
role: string;
|
|
78
|
+
content: string | Array<AnthropicContentBlock>;
|
|
79
|
+
}
|
|
80
|
+
export interface AnthropicContentBlock {
|
|
81
|
+
type: string;
|
|
82
|
+
[key: string]: unknown;
|
|
83
|
+
}
|
|
84
|
+
export interface AnthropicTextBlock extends AnthropicContentBlock {
|
|
85
|
+
type: "text";
|
|
86
|
+
text: string;
|
|
87
|
+
}
|
|
88
|
+
export interface AnthropicToolResult {
|
|
89
|
+
type: "tool_result";
|
|
90
|
+
tool_use_id: string;
|
|
91
|
+
content: string | Array<AnthropicContentBlock>;
|
|
92
|
+
}
|
|
93
|
+
export interface ResponseItem {
|
|
94
|
+
type: string;
|
|
95
|
+
id: string;
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
}
|
|
98
|
+
export interface ComputerCallItem extends ResponseItem {
|
|
99
|
+
type: "computer_call";
|
|
100
|
+
call_id: string;
|
|
101
|
+
action: {
|
|
102
|
+
type: string;
|
|
103
|
+
[key: string]: unknown;
|
|
104
|
+
};
|
|
105
|
+
pending_safety_checks?: Array<{
|
|
106
|
+
id: string;
|
|
107
|
+
code: string;
|
|
108
|
+
message: string;
|
|
109
|
+
}>;
|
|
110
|
+
}
|
|
111
|
+
export interface FunctionCallItem extends ResponseItem {
|
|
112
|
+
type: "function_call";
|
|
113
|
+
call_id: string;
|
|
114
|
+
name: string;
|
|
115
|
+
arguments: string;
|
|
116
|
+
}
|
|
117
|
+
export type ResponseInputItem = {
|
|
118
|
+
role: string;
|
|
119
|
+
content: string;
|
|
120
|
+
} | {
|
|
121
|
+
type: "computer_call_output";
|
|
122
|
+
call_id: string;
|
|
123
|
+
output: {
|
|
124
|
+
type: "input_image";
|
|
125
|
+
image_url: string;
|
|
126
|
+
current_url?: string;
|
|
127
|
+
error?: string;
|
|
128
|
+
[key: string]: unknown;
|
|
129
|
+
} | string;
|
|
130
|
+
acknowledged_safety_checks?: Array<{
|
|
131
|
+
id: string;
|
|
132
|
+
code: string;
|
|
133
|
+
message: string;
|
|
134
|
+
}>;
|
|
135
|
+
} | {
|
|
136
|
+
type: "function_call_output";
|
|
137
|
+
call_id: string;
|
|
138
|
+
output: string;
|
|
139
|
+
};
|
|
140
|
+
export interface AgentInstance {
|
|
141
|
+
execute: (instructionOrOptions: string | AgentExecuteOptions) => Promise<AgentResult>;
|
|
142
|
+
setScreenshotCollector?: (collector: unknown) => void;
|
|
143
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Browserbase from "@browserbasehq/sdk";
|
|
2
|
+
import { LogLine } from "./log";
|
|
3
|
+
export interface StagehandAPIConstructorParams {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
projectId: string;
|
|
6
|
+
logger: (message: LogLine) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface ExecuteActionParams {
|
|
9
|
+
method: "act" | "extract" | "observe" | "navigate" | "end" | "agentExecute";
|
|
10
|
+
args?: unknown;
|
|
11
|
+
params?: unknown;
|
|
12
|
+
}
|
|
13
|
+
export interface StartSessionParams {
|
|
14
|
+
modelName: string;
|
|
15
|
+
modelApiKey: string;
|
|
16
|
+
domSettleTimeoutMs: number;
|
|
17
|
+
verbose: number;
|
|
18
|
+
debugDom: boolean;
|
|
19
|
+
systemPrompt?: string;
|
|
20
|
+
browserbaseSessionCreateParams?: Omit<Browserbase.Sessions.SessionCreateParams, "projectId"> & {
|
|
21
|
+
projectId?: string;
|
|
22
|
+
};
|
|
23
|
+
selfHeal?: boolean;
|
|
24
|
+
waitForCaptchaSolves?: boolean;
|
|
25
|
+
actionTimeoutMs?: number;
|
|
26
|
+
browserbaseSessionID?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface StartSessionResult {
|
|
29
|
+
sessionId: string;
|
|
30
|
+
available?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface SuccessResponse<T> {
|
|
33
|
+
success: true;
|
|
34
|
+
data: T;
|
|
35
|
+
}
|
|
36
|
+
export interface ErrorResponse {
|
|
37
|
+
success: false;
|
|
38
|
+
message: string;
|
|
39
|
+
}
|
|
40
|
+
export type ApiResponse<T> = SuccessResponse<T> | ErrorResponse;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { BrowserContext as PlaywrightContext, Frame } from "playwright";
|
|
2
|
+
import { Page } from "../types/page";
|
|
3
|
+
export interface AXNode {
|
|
4
|
+
role?: {
|
|
5
|
+
value: string;
|
|
6
|
+
};
|
|
7
|
+
name?: {
|
|
8
|
+
value: string;
|
|
9
|
+
};
|
|
10
|
+
description?: {
|
|
11
|
+
value: string;
|
|
12
|
+
};
|
|
13
|
+
value?: {
|
|
14
|
+
value: string;
|
|
15
|
+
};
|
|
16
|
+
nodeId: string;
|
|
17
|
+
backendDOMNodeId?: number;
|
|
18
|
+
parentId?: string;
|
|
19
|
+
childIds?: string[];
|
|
20
|
+
properties?: {
|
|
21
|
+
name: string;
|
|
22
|
+
value: {
|
|
23
|
+
type: string;
|
|
24
|
+
value?: string;
|
|
25
|
+
};
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
export type AccessibilityNode = {
|
|
29
|
+
role: string;
|
|
30
|
+
name?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
value?: string;
|
|
33
|
+
children?: AccessibilityNode[];
|
|
34
|
+
childIds?: string[];
|
|
35
|
+
parentId?: string;
|
|
36
|
+
nodeId?: string;
|
|
37
|
+
backendDOMNodeId?: number;
|
|
38
|
+
properties?: {
|
|
39
|
+
name: string;
|
|
40
|
+
value: {
|
|
41
|
+
type: string;
|
|
42
|
+
value?: string;
|
|
43
|
+
};
|
|
44
|
+
}[];
|
|
45
|
+
};
|
|
46
|
+
export interface TreeResult {
|
|
47
|
+
tree: AccessibilityNode[];
|
|
48
|
+
simplified: string;
|
|
49
|
+
iframes?: AccessibilityNode[];
|
|
50
|
+
idToUrl: Record<EncodedId, string>;
|
|
51
|
+
xpathMap: Record<EncodedId, string>;
|
|
52
|
+
}
|
|
53
|
+
export type DOMNode = {
|
|
54
|
+
backendNodeId?: number;
|
|
55
|
+
nodeName?: string;
|
|
56
|
+
children?: DOMNode[];
|
|
57
|
+
shadowRoots?: DOMNode[];
|
|
58
|
+
contentDocument?: DOMNode;
|
|
59
|
+
nodeType: number;
|
|
60
|
+
frameId?: string;
|
|
61
|
+
};
|
|
62
|
+
export type BackendIdMaps = {
|
|
63
|
+
tagNameMap: Record<number, string>;
|
|
64
|
+
xpathMap: Record<number, string>;
|
|
65
|
+
iframeXPath?: string;
|
|
66
|
+
};
|
|
67
|
+
export interface EnhancedContext extends Omit<PlaywrightContext, "newPage" | "pages"> {
|
|
68
|
+
newPage(): Promise<Page>;
|
|
69
|
+
pages(): Page[];
|
|
70
|
+
}
|
|
71
|
+
export type FrameId = string;
|
|
72
|
+
export type LoaderId = string;
|
|
73
|
+
export interface CdpFrame {
|
|
74
|
+
id: FrameId;
|
|
75
|
+
parentId?: FrameId;
|
|
76
|
+
loaderId: LoaderId;
|
|
77
|
+
name?: string;
|
|
78
|
+
url: string;
|
|
79
|
+
urlFragment?: string;
|
|
80
|
+
domainAndRegistry?: string;
|
|
81
|
+
securityOrigin: string;
|
|
82
|
+
securityOriginDetails?: Record<string, unknown>;
|
|
83
|
+
mimeType: string;
|
|
84
|
+
unreachableUrl?: string;
|
|
85
|
+
adFrameStatus?: string;
|
|
86
|
+
secureContextType?: string;
|
|
87
|
+
crossOriginIsolatedContextType?: string;
|
|
88
|
+
gatedAPIFeatures?: string[];
|
|
89
|
+
}
|
|
90
|
+
export interface CdpFrameTree {
|
|
91
|
+
frame: CdpFrame;
|
|
92
|
+
childFrames?: CdpFrameTree[];
|
|
93
|
+
}
|
|
94
|
+
export interface FrameOwnerResult {
|
|
95
|
+
backendNodeId?: number;
|
|
96
|
+
}
|
|
97
|
+
export interface CombinedA11yResult {
|
|
98
|
+
combinedTree: string;
|
|
99
|
+
combinedXpathMap: Record<EncodedId, string>;
|
|
100
|
+
combinedUrlMap: Record<EncodedId, string>;
|
|
101
|
+
}
|
|
102
|
+
export interface FrameSnapshot {
|
|
103
|
+
frame: Frame;
|
|
104
|
+
tree: string;
|
|
105
|
+
xpathMap: Record<EncodedId, string>;
|
|
106
|
+
urlMap: Record<EncodedId, string>;
|
|
107
|
+
frameXpath: string;
|
|
108
|
+
backendNodeId: number | null;
|
|
109
|
+
parentFrame?: Frame;
|
|
110
|
+
/** CDP frame identifier for this snapshot; used to generate stable EncodedIds. */
|
|
111
|
+
frameId?: string;
|
|
112
|
+
}
|
|
113
|
+
export type EncodedId = `${number}-${number}`;
|
|
114
|
+
export interface RichNode extends AccessibilityNode {
|
|
115
|
+
encodedId?: EncodedId;
|
|
116
|
+
}
|
|
117
|
+
export declare const ID_PATTERN: RegExp;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { z } from "zod/v3";
|
|
2
|
+
import type { AvailableModel } from "../types/model";
|
|
3
|
+
import type { LogLine } from "../types/log";
|
|
4
|
+
import type { AgentInstance } from "../types/agent";
|
|
5
|
+
import type { EvalCase } from "braintrust";
|
|
6
|
+
import { Stagehand } from "@/dist";
|
|
7
|
+
import { ConstructorParams } from "@/dist";
|
|
8
|
+
import { EvalLogger } from "@/evals/logger";
|
|
9
|
+
export type StagehandInitResult = {
|
|
10
|
+
stagehand: Stagehand;
|
|
11
|
+
logger: EvalLogger;
|
|
12
|
+
debugUrl: string;
|
|
13
|
+
sessionUrl: string;
|
|
14
|
+
stagehandConfig: ConstructorParams;
|
|
15
|
+
modelName: AvailableModel;
|
|
16
|
+
agent: AgentInstance;
|
|
17
|
+
};
|
|
18
|
+
export declare enum ErrorType {
|
|
19
|
+
TIMEOUT = "timeout",
|
|
20
|
+
NETWORK = "network",
|
|
21
|
+
AGENT_FAILURE = "agent_failure",
|
|
22
|
+
EVALUATION_ERROR = "evaluation_error",
|
|
23
|
+
SETUP_ERROR = "setup_error",
|
|
24
|
+
PARSING_ERROR = "parsing_error",
|
|
25
|
+
ANTIBOT = "bot_detected",
|
|
26
|
+
UNKNOWN = "unknown"
|
|
27
|
+
}
|
|
28
|
+
export interface EvalOutput {
|
|
29
|
+
_success: boolean;
|
|
30
|
+
logs: LogLine[];
|
|
31
|
+
debugUrl: string;
|
|
32
|
+
sessionUrl: string;
|
|
33
|
+
error?: unknown;
|
|
34
|
+
error_type?: ErrorType;
|
|
35
|
+
error_message?: string;
|
|
36
|
+
error_stack?: string;
|
|
37
|
+
execution_time?: number;
|
|
38
|
+
agent_steps?: number;
|
|
39
|
+
final_answer?: string;
|
|
40
|
+
reasoning?: string;
|
|
41
|
+
observations?: string | unknown;
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
export type EvalFunction = (taskInput: StagehandInitResult & {
|
|
45
|
+
input: EvalInput;
|
|
46
|
+
}) => Promise<EvalOutput>;
|
|
47
|
+
export declare const EvalCategorySchema: z.ZodEnum<["observe", "act", "combination", "extract", "experimental", "targeted_extract", "regression", "regression_llm_providers", "llm_clients", "agent", "external_agent_benchmarks"]>;
|
|
48
|
+
export type EvalCategory = z.infer<typeof EvalCategorySchema>;
|
|
49
|
+
export interface EvalInput {
|
|
50
|
+
name: string;
|
|
51
|
+
modelName: AvailableModel;
|
|
52
|
+
params?: Record<string, unknown>;
|
|
53
|
+
}
|
|
54
|
+
export interface TestcaseMetadata {
|
|
55
|
+
model: AvailableModel;
|
|
56
|
+
test: string;
|
|
57
|
+
category?: string;
|
|
58
|
+
dataset?: string;
|
|
59
|
+
dataset_id?: string;
|
|
60
|
+
dataset_level?: string | number;
|
|
61
|
+
dataset_category?: string;
|
|
62
|
+
[key: string]: unknown;
|
|
63
|
+
}
|
|
64
|
+
export interface Testcase extends EvalCase<EvalInput, unknown, TestcaseMetadata> {
|
|
65
|
+
input: EvalInput;
|
|
66
|
+
name: string;
|
|
67
|
+
tags: string[];
|
|
68
|
+
metadata: TestcaseMetadata;
|
|
69
|
+
expected: unknown;
|
|
70
|
+
}
|
|
71
|
+
export interface SummaryResult {
|
|
72
|
+
input: EvalInput;
|
|
73
|
+
output: {
|
|
74
|
+
_success: boolean;
|
|
75
|
+
};
|
|
76
|
+
name: string;
|
|
77
|
+
score: number;
|
|
78
|
+
}
|
|
79
|
+
export interface EvalArgs<TInput, TOutput, TExpected> {
|
|
80
|
+
input: TInput;
|
|
81
|
+
output: TOutput;
|
|
82
|
+
expected: TExpected;
|
|
83
|
+
metadata?: {
|
|
84
|
+
model: AvailableModel;
|
|
85
|
+
test: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export interface EvalResult {
|
|
89
|
+
name: string;
|
|
90
|
+
score: number;
|
|
91
|
+
}
|
|
92
|
+
export type LogLineEval = LogLine & {
|
|
93
|
+
parsedAuxiliary?: string | object;
|
|
94
|
+
};
|