@browserbasehq/orca 3.0.0-preview.3 → 3.0.0-preview.4
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 +283 -325
- package/dist/index.js +28827 -19579
- package/package.json +33 -31
- package/LICENSE +0 -21
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { ZodType, z,
|
|
1
|
+
import { ZodType, z, ZodError, ZodTypeAny } from 'zod/v3';
|
|
2
2
|
import { ClientOptions as ClientOptions$2 } from '@anthropic-ai/sdk';
|
|
3
|
-
import {
|
|
3
|
+
import { LanguageModelV2 } from '@ai-sdk/provider';
|
|
4
4
|
import { ClientOptions as ClientOptions$1 } from 'openai';
|
|
5
|
-
import {
|
|
5
|
+
import { generateObject, generateText, streamText, streamObject, experimental_generateImage, embed, embedMany, experimental_transcribe, experimental_generateSpeech, ToolSet } from 'ai';
|
|
6
|
+
import { Protocol } from 'devtools-protocol';
|
|
7
|
+
import { Buffer as Buffer$1 } from 'buffer';
|
|
6
8
|
import { Page as Page$1 } from 'playwright-core';
|
|
7
9
|
export { Page as PlaywrightPage } from 'playwright-core';
|
|
8
|
-
import { Page as Page$2 } from 'puppeteer-core';
|
|
9
|
-
export { Page as PuppeteerPage } from 'puppeteer-core';
|
|
10
10
|
import { Page as Page$3 } from 'patchright-core';
|
|
11
11
|
export { Page as PatchrightPage } from 'patchright-core';
|
|
12
|
-
import {
|
|
13
|
-
|
|
12
|
+
import { Page as Page$2 } from 'puppeteer-core';
|
|
13
|
+
export { Page as PuppeteerPage } from 'puppeteer-core';
|
|
14
|
+
import { Client, ClientOptions as ClientOptions$3 } from '@modelcontextprotocol/sdk/client/index.js';
|
|
14
15
|
import Browserbase from '@browserbasehq/sdk';
|
|
15
16
|
import { ToolSet as ToolSet$1 } from 'ai/dist';
|
|
16
17
|
import { Schema } from '@google/genai';
|
|
@@ -31,7 +32,7 @@ interface LLMTool {
|
|
|
31
32
|
description: string;
|
|
32
33
|
parameters: Record<string, unknown>;
|
|
33
34
|
}
|
|
34
|
-
type AISDKProvider = (modelName: string) =>
|
|
35
|
+
type AISDKProvider = (modelName: string) => LanguageModelV2;
|
|
35
36
|
type AISDKCustomProvider = (options: {
|
|
36
37
|
apiKey: string;
|
|
37
38
|
}) => AISDKProvider;
|
|
@@ -104,7 +105,7 @@ interface ChatCompletionOptions {
|
|
|
104
105
|
};
|
|
105
106
|
tools?: LLMTool[];
|
|
106
107
|
tool_choice?: "auto" | "none" | "required";
|
|
107
|
-
|
|
108
|
+
maxOutputTokens?: number;
|
|
108
109
|
requestId?: string;
|
|
109
110
|
}
|
|
110
111
|
type LLMResponse = {
|
|
@@ -158,7 +159,7 @@ declare abstract class LLMClient {
|
|
|
158
159
|
embedMany: typeof embedMany;
|
|
159
160
|
transcribe: typeof experimental_transcribe;
|
|
160
161
|
generateSpeech: typeof experimental_generateSpeech;
|
|
161
|
-
getLanguageModel?():
|
|
162
|
+
getLanguageModel?(): LanguageModelV2;
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
/**
|
|
@@ -401,9 +402,9 @@ declare class Locator {
|
|
|
401
402
|
scrollTo(percent: number | string): Promise<void>;
|
|
402
403
|
/**
|
|
403
404
|
* Fill an input/textarea/contenteditable element.
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
405
|
+
* Mirrors Playwright semantics: the DOM helper either applies the native
|
|
406
|
+
* value setter (for special input types) or asks us to type text via the CDP
|
|
407
|
+
* Input domain after focusing/selecting.
|
|
407
408
|
*/
|
|
408
409
|
fill(value: string): Promise<void>;
|
|
409
410
|
/**
|
|
@@ -591,6 +592,7 @@ declare class Page {
|
|
|
591
592
|
private readonly pageId;
|
|
592
593
|
/** Cached current URL for synchronous page.url() */
|
|
593
594
|
private _currentUrl;
|
|
595
|
+
private readonly networkManager;
|
|
594
596
|
private constructor();
|
|
595
597
|
private cursorEnabled;
|
|
596
598
|
private ensureCursorScript;
|
|
@@ -629,6 +631,8 @@ declare class Page {
|
|
|
629
631
|
frameForId(frameId: string): Frame;
|
|
630
632
|
/** Expose a session by id (used by snapshot to resolve session id -> session) */
|
|
631
633
|
getSessionById(id: string): CDPSessionLike | undefined;
|
|
634
|
+
registerSessionForNetwork(session: CDPSessionLike): void;
|
|
635
|
+
unregisterSessionForNetwork(sessionId: string | undefined): void;
|
|
632
636
|
targetId(): string;
|
|
633
637
|
/** Seed the cached URL before navigation events converge. */
|
|
634
638
|
seedCurrentUrl(url: string | undefined | null): void;
|
|
@@ -794,12 +798,35 @@ declare class Page {
|
|
|
794
798
|
withMistakes?: boolean;
|
|
795
799
|
}): Promise<void>;
|
|
796
800
|
/**
|
|
797
|
-
* Press a single key (keyDown then keyUp).
|
|
798
|
-
* uses the text path on keyDown; for named keys, sets key/code/VK.
|
|
801
|
+
* Press a single key or key combination (keyDown then keyUp).
|
|
802
|
+
* For printable characters, uses the text path on keyDown; for named keys, sets key/code/VK.
|
|
803
|
+
* Supports key combinations with modifiers like "Cmd+A", "Ctrl+C", "Shift+Tab", etc.
|
|
799
804
|
*/
|
|
800
805
|
keyPress(key: string, options?: {
|
|
801
806
|
delay?: number;
|
|
802
807
|
}): Promise<void>;
|
|
808
|
+
private _pressedModifiers;
|
|
809
|
+
/** Press a key down without releasing it */
|
|
810
|
+
private keyDown;
|
|
811
|
+
/** Release a pressed key */
|
|
812
|
+
private keyUp;
|
|
813
|
+
/** Normalize modifier key names to match CDP expectations */
|
|
814
|
+
private normalizeModifierKey;
|
|
815
|
+
/**
|
|
816
|
+
* Get the map of named keys with their properties
|
|
817
|
+
*/
|
|
818
|
+
private getNamedKeys;
|
|
819
|
+
/**
|
|
820
|
+
* Minimal description for printable keys (letters/digits/space) to provide code and VK.
|
|
821
|
+
* Used when non-Shift modifiers are pressed to avoid sending text while keeping accelerator info.
|
|
822
|
+
*/
|
|
823
|
+
private describePrintableKey;
|
|
824
|
+
private isMacOS;
|
|
825
|
+
/**
|
|
826
|
+
* Return Chromium mac editing commands (without trailing ':') for a given code like 'KeyA'
|
|
827
|
+
* Only used on macOS to trigger system editing shortcuts (e.g., selectAll, copy, paste...).
|
|
828
|
+
*/
|
|
829
|
+
private macCommandsFor;
|
|
803
830
|
/**
|
|
804
831
|
* Create an isolated world for the **current** main frame and return its context id.
|
|
805
832
|
*/
|
|
@@ -810,7 +837,66 @@ declare class Page {
|
|
|
810
837
|
* - Event path listens at the session level and compares incoming `frameId`
|
|
811
838
|
* to `mainFrameId()` **at event time** to follow root swaps.
|
|
812
839
|
*/
|
|
813
|
-
|
|
840
|
+
waitForMainLoadState(state: LoadState, timeoutMs?: number): Promise<void>;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* Represents a path through a Zod schema from the root object down to a
|
|
845
|
+
* particular field. The `segments` array describes the chain of keys/indices.
|
|
846
|
+
*
|
|
847
|
+
* - **String** segments indicate object property names.
|
|
848
|
+
* - **Number** segments indicate array indices.
|
|
849
|
+
*
|
|
850
|
+
* For example, `["users", 0, "homepage"]` might describe reaching
|
|
851
|
+
* the `homepage` field in `schema.users[0].homepage`.
|
|
852
|
+
*/
|
|
853
|
+
interface ZodPathSegments {
|
|
854
|
+
/**
|
|
855
|
+
* The ordered list of keys/indices leading from the schema root
|
|
856
|
+
* to the targeted field.
|
|
857
|
+
*/
|
|
858
|
+
segments: Array<string | number>;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
type EvaluateOptions = {
|
|
862
|
+
/** The question to ask about the task state */
|
|
863
|
+
question: string;
|
|
864
|
+
/** The answer to the question */
|
|
865
|
+
answer?: string;
|
|
866
|
+
/** Whether to take a screenshot of the task state, or array of screenshots to evaluate */
|
|
867
|
+
screenshot?: boolean | Buffer[];
|
|
868
|
+
/** Custom system prompt for the evaluator */
|
|
869
|
+
systemPrompt?: string;
|
|
870
|
+
/** Delay in milliseconds before taking the screenshot @default 250 */
|
|
871
|
+
screenshotDelayMs?: number;
|
|
872
|
+
/** The agent's reasoning/thought process for completing the task */
|
|
873
|
+
agentReasoning?: string;
|
|
874
|
+
};
|
|
875
|
+
type BatchAskOptions = {
|
|
876
|
+
/** Array of questions with optional answers */
|
|
877
|
+
questions: Array<{
|
|
878
|
+
question: string;
|
|
879
|
+
answer?: string;
|
|
880
|
+
}>;
|
|
881
|
+
/** Whether to take a screenshot of the task state */
|
|
882
|
+
screenshot?: boolean;
|
|
883
|
+
/** Custom system prompt for the evaluator */
|
|
884
|
+
systemPrompt?: string;
|
|
885
|
+
/** Delay in milliseconds before taking the screenshot @default 1000 */
|
|
886
|
+
screenshotDelayMs?: number;
|
|
887
|
+
};
|
|
888
|
+
/**
|
|
889
|
+
* Result of an evaluation
|
|
890
|
+
*/
|
|
891
|
+
interface EvaluationResult {
|
|
892
|
+
/**
|
|
893
|
+
* The evaluation result ('YES', 'NO', or 'INVALID' if parsing failed or value was unexpected)
|
|
894
|
+
*/
|
|
895
|
+
evaluation: "YES" | "NO" | "INVALID";
|
|
896
|
+
/**
|
|
897
|
+
* The reasoning behind the evaluation
|
|
898
|
+
*/
|
|
899
|
+
reasoning: string;
|
|
814
900
|
}
|
|
815
901
|
|
|
816
902
|
interface AgentAction {
|
|
@@ -839,13 +925,14 @@ interface AgentResult {
|
|
|
839
925
|
interface AgentExecuteOptions {
|
|
840
926
|
instruction: string;
|
|
841
927
|
maxSteps?: number;
|
|
842
|
-
highlightCursor?: boolean;
|
|
843
928
|
page?: Page$1 | Page$2 | Page$3 | Page;
|
|
929
|
+
highlightCursor?: boolean;
|
|
844
930
|
}
|
|
845
931
|
type AgentType = "openai" | "anthropic" | "google";
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
932
|
+
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-haiku-4-5-20251001", "anthropic/claude-sonnet-4-20250514", "anthropic/claude-sonnet-4-5-20250929", "google/gemini-2.5-computer-use-preview-10-2025"];
|
|
933
|
+
type AvailableCuaModel = (typeof AVAILABLE_CUA_MODELS)[number];
|
|
934
|
+
interface AgentExecutionOptions<TOptions extends AgentExecuteOptions = AgentExecuteOptions> {
|
|
935
|
+
options: TOptions;
|
|
849
936
|
logger: (message: LogLine) => void;
|
|
850
937
|
retries?: number;
|
|
851
938
|
}
|
|
@@ -937,7 +1024,7 @@ type AgentProviderType = AgentType;
|
|
|
937
1024
|
type AgentModelConfig<TModelName extends string = string> = {
|
|
938
1025
|
modelName: TModelName;
|
|
939
1026
|
} & Record<string, unknown>;
|
|
940
|
-
type
|
|
1027
|
+
type AgentConfig = {
|
|
941
1028
|
/**
|
|
942
1029
|
* Custom system prompt to provide to the agent. Overrides the default system prompt.
|
|
943
1030
|
*/
|
|
@@ -950,12 +1037,10 @@ type SharedAgentConfigFields = {
|
|
|
950
1037
|
* Tools passed to the agent client
|
|
951
1038
|
*/
|
|
952
1039
|
tools?: ToolSet;
|
|
953
|
-
};
|
|
954
|
-
type StandardAgentConfig = SharedAgentConfigFields & {
|
|
955
1040
|
/**
|
|
956
1041
|
* Indicates CUA is disabled for this configuration
|
|
957
1042
|
*/
|
|
958
|
-
cua?:
|
|
1043
|
+
cua?: boolean;
|
|
959
1044
|
/**
|
|
960
1045
|
* The model to use for agent functionality
|
|
961
1046
|
*/
|
|
@@ -965,26 +1050,27 @@ type StandardAgentConfig = SharedAgentConfigFields & {
|
|
|
965
1050
|
* If not specified, inherits from the main model configuration.
|
|
966
1051
|
* Format: "provider/model" (e.g., "openai/gpt-4o-mini", "google/gemini-2.0-flash-exp")
|
|
967
1052
|
*/
|
|
968
|
-
executionModel?: string
|
|
1053
|
+
executionModel?: string | AgentModelConfig<string>;
|
|
969
1054
|
};
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1055
|
+
|
|
1056
|
+
declare class StagehandAPIError extends Error {
|
|
1057
|
+
constructor(message: string);
|
|
1058
|
+
}
|
|
1059
|
+
declare class StagehandAPIUnauthorizedError extends StagehandAPIError {
|
|
1060
|
+
constructor(message?: string);
|
|
1061
|
+
}
|
|
1062
|
+
declare class StagehandHttpError extends StagehandAPIError {
|
|
1063
|
+
constructor(message: string);
|
|
1064
|
+
}
|
|
1065
|
+
declare class StagehandServerError extends StagehandAPIError {
|
|
1066
|
+
constructor(message: string);
|
|
1067
|
+
}
|
|
1068
|
+
declare class StagehandResponseBodyError extends StagehandAPIError {
|
|
1069
|
+
constructor();
|
|
1070
|
+
}
|
|
1071
|
+
declare class StagehandResponseParseError extends StagehandAPIError {
|
|
1072
|
+
constructor(message: string);
|
|
1073
|
+
}
|
|
988
1074
|
|
|
989
1075
|
interface ActOptions {
|
|
990
1076
|
model?: ModelConfiguration;
|
|
@@ -1044,75 +1130,6 @@ declare enum V3FunctionName {
|
|
|
1044
1130
|
AGENT = "AGENT"
|
|
1045
1131
|
}
|
|
1046
1132
|
|
|
1047
|
-
interface CachedActEntry {
|
|
1048
|
-
version: 1;
|
|
1049
|
-
instruction: string;
|
|
1050
|
-
url: string;
|
|
1051
|
-
variables: Record<string, string>;
|
|
1052
|
-
actions: Action[];
|
|
1053
|
-
actionDescription?: string;
|
|
1054
|
-
message?: string;
|
|
1055
|
-
}
|
|
1056
|
-
type AgentReplayStep = AgentReplayActStep | AgentReplayFillFormStep | AgentReplayGotoStep | AgentReplayScrollStep | AgentReplayWaitStep | AgentReplayNavBackStep | {
|
|
1057
|
-
type: string;
|
|
1058
|
-
[key: string]: unknown;
|
|
1059
|
-
};
|
|
1060
|
-
interface AgentReplayActStep {
|
|
1061
|
-
type: "act";
|
|
1062
|
-
instruction: string;
|
|
1063
|
-
actions?: Action[];
|
|
1064
|
-
actionDescription?: string;
|
|
1065
|
-
message?: string;
|
|
1066
|
-
timeout?: number;
|
|
1067
|
-
}
|
|
1068
|
-
interface AgentReplayFillFormStep {
|
|
1069
|
-
type: "fillForm";
|
|
1070
|
-
fields?: Array<{
|
|
1071
|
-
action: string;
|
|
1072
|
-
value: string;
|
|
1073
|
-
}>;
|
|
1074
|
-
observeResults?: Action[];
|
|
1075
|
-
actions?: Action[];
|
|
1076
|
-
}
|
|
1077
|
-
interface AgentReplayGotoStep {
|
|
1078
|
-
type: "goto";
|
|
1079
|
-
url: string;
|
|
1080
|
-
waitUntil?: LoadState;
|
|
1081
|
-
}
|
|
1082
|
-
interface AgentReplayScrollStep {
|
|
1083
|
-
type: "scroll";
|
|
1084
|
-
deltaX?: number;
|
|
1085
|
-
deltaY?: number;
|
|
1086
|
-
anchor?: {
|
|
1087
|
-
x: number;
|
|
1088
|
-
y: number;
|
|
1089
|
-
};
|
|
1090
|
-
}
|
|
1091
|
-
interface AgentReplayWaitStep {
|
|
1092
|
-
type: "wait";
|
|
1093
|
-
timeMs: number;
|
|
1094
|
-
}
|
|
1095
|
-
interface AgentReplayNavBackStep {
|
|
1096
|
-
type: "navback";
|
|
1097
|
-
waitUntil?: LoadState;
|
|
1098
|
-
}
|
|
1099
|
-
interface SanitizedAgentExecuteOptions {
|
|
1100
|
-
maxSteps?: number;
|
|
1101
|
-
autoScreenshot?: boolean;
|
|
1102
|
-
waitBetweenActions?: number;
|
|
1103
|
-
context?: string;
|
|
1104
|
-
}
|
|
1105
|
-
interface CachedAgentEntry {
|
|
1106
|
-
version: 1;
|
|
1107
|
-
instruction: string;
|
|
1108
|
-
startUrl: string;
|
|
1109
|
-
options: SanitizedAgentExecuteOptions;
|
|
1110
|
-
configSignature: string;
|
|
1111
|
-
steps: AgentReplayStep[];
|
|
1112
|
-
result: AgentResult;
|
|
1113
|
-
timestamp: string;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
1133
|
interface V3Metrics {
|
|
1117
1134
|
actPromptTokens: number;
|
|
1118
1135
|
actCompletionTokens: number;
|
|
@@ -1187,13 +1204,115 @@ interface V3Options {
|
|
|
1187
1204
|
disablePino?: boolean;
|
|
1188
1205
|
/** Optional external logger hook for integrating with host apps. */
|
|
1189
1206
|
logger?: (line: LogLine) => void;
|
|
1190
|
-
/** Show a visual cursor overlay that follows our mouse events. */
|
|
1191
|
-
includeCursor?: boolean;
|
|
1192
1207
|
/** Directory used to persist cached actions for act(). */
|
|
1193
1208
|
cacheDir?: string;
|
|
1194
1209
|
domSettleTimeout?: number;
|
|
1195
1210
|
}
|
|
1196
1211
|
|
|
1212
|
+
declare class StagehandError extends Error {
|
|
1213
|
+
constructor(message: string);
|
|
1214
|
+
}
|
|
1215
|
+
declare class StagehandDefaultError extends StagehandError {
|
|
1216
|
+
constructor(error?: unknown);
|
|
1217
|
+
}
|
|
1218
|
+
declare class StagehandEnvironmentError extends StagehandError {
|
|
1219
|
+
constructor(currentEnvironment: string, requiredEnvironment: string, feature: string);
|
|
1220
|
+
}
|
|
1221
|
+
declare class MissingEnvironmentVariableError extends StagehandError {
|
|
1222
|
+
constructor(missingEnvironmentVariable: string, feature: string);
|
|
1223
|
+
}
|
|
1224
|
+
declare class UnsupportedModelError extends StagehandError {
|
|
1225
|
+
constructor(supportedModels: string[], feature?: string);
|
|
1226
|
+
}
|
|
1227
|
+
declare class UnsupportedModelProviderError extends StagehandError {
|
|
1228
|
+
constructor(supportedProviders: string[], feature?: string);
|
|
1229
|
+
}
|
|
1230
|
+
declare class UnsupportedAISDKModelProviderError extends StagehandError {
|
|
1231
|
+
constructor(provider: string, supportedProviders: string[]);
|
|
1232
|
+
}
|
|
1233
|
+
declare class InvalidAISDKModelFormatError extends StagehandError {
|
|
1234
|
+
constructor(modelName: string);
|
|
1235
|
+
}
|
|
1236
|
+
declare class StagehandNotInitializedError extends StagehandError {
|
|
1237
|
+
constructor(prop: string);
|
|
1238
|
+
}
|
|
1239
|
+
declare class BrowserbaseSessionNotFoundError extends StagehandError {
|
|
1240
|
+
constructor();
|
|
1241
|
+
}
|
|
1242
|
+
declare class CaptchaTimeoutError extends StagehandError {
|
|
1243
|
+
constructor();
|
|
1244
|
+
}
|
|
1245
|
+
declare class MissingLLMConfigurationError extends StagehandError {
|
|
1246
|
+
constructor();
|
|
1247
|
+
}
|
|
1248
|
+
declare class HandlerNotInitializedError extends StagehandError {
|
|
1249
|
+
constructor(handlerType: string);
|
|
1250
|
+
}
|
|
1251
|
+
declare class StagehandInvalidArgumentError extends StagehandError {
|
|
1252
|
+
constructor(message: string);
|
|
1253
|
+
}
|
|
1254
|
+
declare class StagehandElementNotFoundError extends StagehandError {
|
|
1255
|
+
constructor(xpaths: string[]);
|
|
1256
|
+
}
|
|
1257
|
+
declare class AgentScreenshotProviderError extends StagehandError {
|
|
1258
|
+
constructor(message: string);
|
|
1259
|
+
}
|
|
1260
|
+
declare class StagehandMissingArgumentError extends StagehandError {
|
|
1261
|
+
constructor(message: string);
|
|
1262
|
+
}
|
|
1263
|
+
declare class CreateChatCompletionResponseError extends StagehandError {
|
|
1264
|
+
constructor(message: string);
|
|
1265
|
+
}
|
|
1266
|
+
declare class StagehandEvalError extends StagehandError {
|
|
1267
|
+
constructor(message: string);
|
|
1268
|
+
}
|
|
1269
|
+
declare class StagehandDomProcessError extends StagehandError {
|
|
1270
|
+
constructor(message: string);
|
|
1271
|
+
}
|
|
1272
|
+
declare class StagehandClickError extends StagehandError {
|
|
1273
|
+
constructor(message: string, selector: string);
|
|
1274
|
+
}
|
|
1275
|
+
declare class LLMResponseError extends StagehandError {
|
|
1276
|
+
constructor(primitive: string, message: string);
|
|
1277
|
+
}
|
|
1278
|
+
declare class StagehandIframeError extends StagehandError {
|
|
1279
|
+
constructor(frameUrl: string, message: string);
|
|
1280
|
+
}
|
|
1281
|
+
declare class ContentFrameNotFoundError extends StagehandError {
|
|
1282
|
+
constructor(selector: string);
|
|
1283
|
+
}
|
|
1284
|
+
declare class XPathResolutionError extends StagehandError {
|
|
1285
|
+
constructor(xpath: string);
|
|
1286
|
+
}
|
|
1287
|
+
declare class ExperimentalApiConflictError extends StagehandError {
|
|
1288
|
+
constructor();
|
|
1289
|
+
}
|
|
1290
|
+
declare class ExperimentalNotConfiguredError extends StagehandError {
|
|
1291
|
+
constructor(featureName: string);
|
|
1292
|
+
}
|
|
1293
|
+
declare class ZodSchemaValidationError extends Error {
|
|
1294
|
+
readonly received: unknown;
|
|
1295
|
+
readonly issues: ReturnType<ZodError["format"]>;
|
|
1296
|
+
constructor(received: unknown, issues: ReturnType<ZodError["format"]>);
|
|
1297
|
+
}
|
|
1298
|
+
declare class StagehandInitError extends StagehandError {
|
|
1299
|
+
constructor(message: string);
|
|
1300
|
+
}
|
|
1301
|
+
declare class MCPConnectionError extends StagehandError {
|
|
1302
|
+
readonly serverUrl: string;
|
|
1303
|
+
readonly originalError: unknown;
|
|
1304
|
+
constructor(serverUrl: string, originalError: unknown);
|
|
1305
|
+
}
|
|
1306
|
+
declare class StagehandShadowRootMissingError extends StagehandError {
|
|
1307
|
+
constructor(detail?: string);
|
|
1308
|
+
}
|
|
1309
|
+
declare class StagehandShadowSegmentEmptyError extends StagehandError {
|
|
1310
|
+
constructor();
|
|
1311
|
+
}
|
|
1312
|
+
declare class StagehandShadowSegmentNotFoundError extends StagehandError {
|
|
1313
|
+
constructor(segment: string, hint?: string);
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1197
1316
|
/**
|
|
1198
1317
|
* V3Context
|
|
1199
1318
|
*
|
|
@@ -1207,7 +1326,6 @@ interface V3Options {
|
|
|
1207
1326
|
*/
|
|
1208
1327
|
declare class V3Context {
|
|
1209
1328
|
readonly conn: CdpConnection;
|
|
1210
|
-
private readonly includeCursor;
|
|
1211
1329
|
private readonly env;
|
|
1212
1330
|
private constructor();
|
|
1213
1331
|
private readonly _piercerInstalled;
|
|
@@ -1227,7 +1345,6 @@ declare class V3Context {
|
|
|
1227
1345
|
* Create a Context for a given CDP websocket URL and bootstrap target wiring.
|
|
1228
1346
|
*/
|
|
1229
1347
|
static create(wsUrl: string, opts?: {
|
|
1230
|
-
includeCursor?: boolean;
|
|
1231
1348
|
env?: "LOCAL" | "BROWSERBASE";
|
|
1232
1349
|
}): Promise<V3Context>;
|
|
1233
1350
|
/**
|
|
@@ -1315,6 +1432,50 @@ declare class V3Context {
|
|
|
1315
1432
|
awaitActivePage(timeoutMs?: number): Promise<Page>;
|
|
1316
1433
|
}
|
|
1317
1434
|
|
|
1435
|
+
type AgentReplayStep = AgentReplayActStep | AgentReplayFillFormStep | AgentReplayGotoStep | AgentReplayScrollStep | AgentReplayWaitStep | AgentReplayNavBackStep | {
|
|
1436
|
+
type: string;
|
|
1437
|
+
[key: string]: unknown;
|
|
1438
|
+
};
|
|
1439
|
+
interface AgentReplayActStep {
|
|
1440
|
+
type: "act";
|
|
1441
|
+
instruction: string;
|
|
1442
|
+
actions?: Action[];
|
|
1443
|
+
actionDescription?: string;
|
|
1444
|
+
message?: string;
|
|
1445
|
+
timeout?: number;
|
|
1446
|
+
}
|
|
1447
|
+
interface AgentReplayFillFormStep {
|
|
1448
|
+
type: "fillForm";
|
|
1449
|
+
fields?: Array<{
|
|
1450
|
+
action: string;
|
|
1451
|
+
value: string;
|
|
1452
|
+
}>;
|
|
1453
|
+
observeResults?: Action[];
|
|
1454
|
+
actions?: Action[];
|
|
1455
|
+
}
|
|
1456
|
+
interface AgentReplayGotoStep {
|
|
1457
|
+
type: "goto";
|
|
1458
|
+
url: string;
|
|
1459
|
+
waitUntil?: LoadState;
|
|
1460
|
+
}
|
|
1461
|
+
interface AgentReplayScrollStep {
|
|
1462
|
+
type: "scroll";
|
|
1463
|
+
deltaX?: number;
|
|
1464
|
+
deltaY?: number;
|
|
1465
|
+
anchor?: {
|
|
1466
|
+
x: number;
|
|
1467
|
+
y: number;
|
|
1468
|
+
};
|
|
1469
|
+
}
|
|
1470
|
+
interface AgentReplayWaitStep {
|
|
1471
|
+
type: "wait";
|
|
1472
|
+
timeMs: number;
|
|
1473
|
+
}
|
|
1474
|
+
interface AgentReplayNavBackStep {
|
|
1475
|
+
type: "navback";
|
|
1476
|
+
waitUntil?: LoadState;
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1318
1479
|
/**
|
|
1319
1480
|
* V3
|
|
1320
1481
|
*
|
|
@@ -1354,15 +1515,15 @@ declare class V3 {
|
|
|
1354
1515
|
private readonly instanceId;
|
|
1355
1516
|
private static _processGuardsInstalled;
|
|
1356
1517
|
private static _instances;
|
|
1357
|
-
private
|
|
1358
|
-
private
|
|
1518
|
+
private cacheStorage;
|
|
1519
|
+
private actCache;
|
|
1520
|
+
private agentCache;
|
|
1359
1521
|
v3Metrics: V3Metrics;
|
|
1360
1522
|
/**
|
|
1361
1523
|
* Async property for metrics so callers can `await v3.metrics`.
|
|
1362
1524
|
* Returning a Promise future-proofs async aggregation/storage.
|
|
1363
1525
|
*/
|
|
1364
1526
|
get metrics(): Promise<V3Metrics>;
|
|
1365
|
-
private cloneForCache;
|
|
1366
1527
|
private resolveLlmClient;
|
|
1367
1528
|
private beginAgentReplayRecording;
|
|
1368
1529
|
private endAgentReplayRecording;
|
|
@@ -1437,30 +1598,9 @@ declare class V3 {
|
|
|
1437
1598
|
private isPlaywrightPage;
|
|
1438
1599
|
private isPatchrightPage;
|
|
1439
1600
|
private isPuppeteerPage;
|
|
1601
|
+
/** Resolve an external page reference or fall back to the active V3 page. */
|
|
1602
|
+
private resolvePage;
|
|
1440
1603
|
private normalizeToV3Page;
|
|
1441
|
-
private buildActCacheKey;
|
|
1442
|
-
private safeGetPageUrl;
|
|
1443
|
-
private readActCacheEntry;
|
|
1444
|
-
private writeActCacheEntry;
|
|
1445
|
-
private sanitizeAgentExecuteOptions;
|
|
1446
|
-
private createLlmClientOverride;
|
|
1447
|
-
private inferProviderFromModelName;
|
|
1448
|
-
private extractAgentModel;
|
|
1449
|
-
private serializeAgentModelForCache;
|
|
1450
|
-
private buildAgentCacheSignature;
|
|
1451
|
-
private buildAgentCacheKey;
|
|
1452
|
-
private readAgentCacheEntry;
|
|
1453
|
-
private writeAgentCacheEntry;
|
|
1454
|
-
private replayAgentCacheEntry;
|
|
1455
|
-
private executeAgentReplayStep;
|
|
1456
|
-
private replayAgentActStep;
|
|
1457
|
-
private replayAgentFillFormStep;
|
|
1458
|
-
private replayAgentGotoStep;
|
|
1459
|
-
private replayAgentScrollStep;
|
|
1460
|
-
private replayAgentWaitStep;
|
|
1461
|
-
private replayAgentNavBackStep;
|
|
1462
|
-
private replayCachedActions;
|
|
1463
|
-
private runWithActTimeout;
|
|
1464
1604
|
/**
|
|
1465
1605
|
* Create a v3 agent instance (AISDK tool-based) with execute().
|
|
1466
1606
|
* Mirrors the v2 Stagehand.agent() tool mode (no CUA provider here).
|
|
@@ -1470,129 +1610,6 @@ declare class V3 {
|
|
|
1470
1610
|
};
|
|
1471
1611
|
}
|
|
1472
1612
|
|
|
1473
|
-
declare class StagehandAPIError extends Error {
|
|
1474
|
-
constructor(message: string);
|
|
1475
|
-
}
|
|
1476
|
-
declare class StagehandAPIUnauthorizedError extends StagehandAPIError {
|
|
1477
|
-
constructor(message?: string);
|
|
1478
|
-
}
|
|
1479
|
-
declare class StagehandHttpError extends StagehandAPIError {
|
|
1480
|
-
constructor(message: string);
|
|
1481
|
-
}
|
|
1482
|
-
declare class StagehandServerError extends StagehandAPIError {
|
|
1483
|
-
constructor(message: string);
|
|
1484
|
-
}
|
|
1485
|
-
declare class StagehandResponseBodyError extends StagehandAPIError {
|
|
1486
|
-
constructor();
|
|
1487
|
-
}
|
|
1488
|
-
declare class StagehandResponseParseError extends StagehandAPIError {
|
|
1489
|
-
constructor(message: string);
|
|
1490
|
-
}
|
|
1491
|
-
|
|
1492
|
-
declare class StagehandError extends Error {
|
|
1493
|
-
constructor(message: string);
|
|
1494
|
-
}
|
|
1495
|
-
declare class StagehandDefaultError extends StagehandError {
|
|
1496
|
-
constructor(error?: unknown);
|
|
1497
|
-
}
|
|
1498
|
-
declare class StagehandEnvironmentError extends StagehandError {
|
|
1499
|
-
constructor(currentEnvironment: string, requiredEnvironment: string, feature: string);
|
|
1500
|
-
}
|
|
1501
|
-
declare class MissingEnvironmentVariableError extends StagehandError {
|
|
1502
|
-
constructor(missingEnvironmentVariable: string, feature: string);
|
|
1503
|
-
}
|
|
1504
|
-
declare class UnsupportedModelError extends StagehandError {
|
|
1505
|
-
constructor(supportedModels: string[], feature?: string);
|
|
1506
|
-
}
|
|
1507
|
-
declare class UnsupportedModelProviderError extends StagehandError {
|
|
1508
|
-
constructor(supportedProviders: string[], feature?: string);
|
|
1509
|
-
}
|
|
1510
|
-
declare class UnsupportedAISDKModelProviderError extends StagehandError {
|
|
1511
|
-
constructor(provider: string, supportedProviders: string[]);
|
|
1512
|
-
}
|
|
1513
|
-
declare class InvalidAISDKModelFormatError extends StagehandError {
|
|
1514
|
-
constructor(modelName: string);
|
|
1515
|
-
}
|
|
1516
|
-
declare class StagehandNotInitializedError extends StagehandError {
|
|
1517
|
-
constructor(prop: string);
|
|
1518
|
-
}
|
|
1519
|
-
declare class BrowserbaseSessionNotFoundError extends StagehandError {
|
|
1520
|
-
constructor();
|
|
1521
|
-
}
|
|
1522
|
-
declare class CaptchaTimeoutError extends StagehandError {
|
|
1523
|
-
constructor();
|
|
1524
|
-
}
|
|
1525
|
-
declare class MissingLLMConfigurationError extends StagehandError {
|
|
1526
|
-
constructor();
|
|
1527
|
-
}
|
|
1528
|
-
declare class HandlerNotInitializedError extends StagehandError {
|
|
1529
|
-
constructor(handlerType: string);
|
|
1530
|
-
}
|
|
1531
|
-
declare class StagehandInvalidArgumentError extends StagehandError {
|
|
1532
|
-
constructor(message: string);
|
|
1533
|
-
}
|
|
1534
|
-
declare class StagehandElementNotFoundError extends StagehandError {
|
|
1535
|
-
constructor(xpaths: string[]);
|
|
1536
|
-
}
|
|
1537
|
-
declare class AgentScreenshotProviderError extends StagehandError {
|
|
1538
|
-
constructor(message: string);
|
|
1539
|
-
}
|
|
1540
|
-
declare class StagehandMissingArgumentError extends StagehandError {
|
|
1541
|
-
constructor(message: string);
|
|
1542
|
-
}
|
|
1543
|
-
declare class CreateChatCompletionResponseError extends StagehandError {
|
|
1544
|
-
constructor(message: string);
|
|
1545
|
-
}
|
|
1546
|
-
declare class StagehandEvalError extends StagehandError {
|
|
1547
|
-
constructor(message: string);
|
|
1548
|
-
}
|
|
1549
|
-
declare class StagehandDomProcessError extends StagehandError {
|
|
1550
|
-
constructor(message: string);
|
|
1551
|
-
}
|
|
1552
|
-
declare class StagehandClickError extends StagehandError {
|
|
1553
|
-
constructor(message: string, selector: string);
|
|
1554
|
-
}
|
|
1555
|
-
declare class LLMResponseError extends StagehandError {
|
|
1556
|
-
constructor(primitive: string, message: string);
|
|
1557
|
-
}
|
|
1558
|
-
declare class StagehandIframeError extends StagehandError {
|
|
1559
|
-
constructor(frameUrl: string, message: string);
|
|
1560
|
-
}
|
|
1561
|
-
declare class ContentFrameNotFoundError extends StagehandError {
|
|
1562
|
-
constructor(selector: string);
|
|
1563
|
-
}
|
|
1564
|
-
declare class XPathResolutionError extends StagehandError {
|
|
1565
|
-
constructor(xpath: string);
|
|
1566
|
-
}
|
|
1567
|
-
declare class ExperimentalApiConflictError extends StagehandError {
|
|
1568
|
-
constructor();
|
|
1569
|
-
}
|
|
1570
|
-
declare class ExperimentalNotConfiguredError extends StagehandError {
|
|
1571
|
-
constructor(featureName: string);
|
|
1572
|
-
}
|
|
1573
|
-
declare class ZodSchemaValidationError extends Error {
|
|
1574
|
-
readonly received: unknown;
|
|
1575
|
-
readonly issues: ReturnType<ZodError["format"]>;
|
|
1576
|
-
constructor(received: unknown, issues: ReturnType<ZodError["format"]>);
|
|
1577
|
-
}
|
|
1578
|
-
declare class StagehandInitError extends StagehandError {
|
|
1579
|
-
constructor(message: string);
|
|
1580
|
-
}
|
|
1581
|
-
declare class MCPConnectionError extends StagehandError {
|
|
1582
|
-
readonly serverUrl: string;
|
|
1583
|
-
readonly originalError: unknown;
|
|
1584
|
-
constructor(serverUrl: string, originalError: unknown);
|
|
1585
|
-
}
|
|
1586
|
-
declare class StagehandShadowRootMissingError extends StagehandError {
|
|
1587
|
-
constructor(detail?: string);
|
|
1588
|
-
}
|
|
1589
|
-
declare class StagehandShadowSegmentEmptyError extends StagehandError {
|
|
1590
|
-
constructor();
|
|
1591
|
-
}
|
|
1592
|
-
declare class StagehandShadowSegmentNotFoundError extends StagehandError {
|
|
1593
|
-
constructor(segment: string, hint?: string);
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
1613
|
/**
|
|
1597
1614
|
* Abstract base class for agent clients
|
|
1598
1615
|
* This provides a common interface for all agent implementations
|
|
@@ -1627,24 +1644,6 @@ declare class AgentProvider {
|
|
|
1627
1644
|
static getAgentProvider(modelName: string): AgentProviderType;
|
|
1628
1645
|
}
|
|
1629
1646
|
|
|
1630
|
-
/**
|
|
1631
|
-
* Represents a path through a Zod schema from the root object down to a
|
|
1632
|
-
* particular field. The `segments` array describes the chain of keys/indices.
|
|
1633
|
-
*
|
|
1634
|
-
* - **String** segments indicate object property names.
|
|
1635
|
-
* - **Number** segments indicate array indices.
|
|
1636
|
-
*
|
|
1637
|
-
* For example, `["users", 0, "homepage"]` might describe reaching
|
|
1638
|
-
* the `homepage` field in `schema.users[0].homepage`.
|
|
1639
|
-
*/
|
|
1640
|
-
interface ZodPathSegments {
|
|
1641
|
-
/**
|
|
1642
|
-
* The ordered list of keys/indices leading from the schema root
|
|
1643
|
-
* to the targeted field.
|
|
1644
|
-
*/
|
|
1645
|
-
segments: Array<string | number>;
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
1647
|
declare function validateZodSchema(schema: z.ZodTypeAny, data: unknown): boolean;
|
|
1649
1648
|
/**
|
|
1650
1649
|
* Detects if the code is running in the Bun runtime environment.
|
|
@@ -1717,47 +1716,6 @@ interface StdioServerConfig {
|
|
|
1717
1716
|
}
|
|
1718
1717
|
declare const connectToMCPServer: (serverConfig: string | URL | StdioServerConfig | ConnectToMCPServerOptions) => Promise<Client>;
|
|
1719
1718
|
|
|
1720
|
-
type EvaluateOptions = {
|
|
1721
|
-
/** The question to ask about the task state */
|
|
1722
|
-
question: string;
|
|
1723
|
-
/** The answer to the question */
|
|
1724
|
-
answer?: string;
|
|
1725
|
-
/** Whether to take a screenshot of the task state, or array of screenshots to evaluate */
|
|
1726
|
-
screenshot?: boolean | Buffer[];
|
|
1727
|
-
/** Custom system prompt for the evaluator */
|
|
1728
|
-
systemPrompt?: string;
|
|
1729
|
-
/** Delay in milliseconds before taking the screenshot @default 250 */
|
|
1730
|
-
screenshotDelayMs?: number;
|
|
1731
|
-
/** The agent's reasoning/thought process for completing the task */
|
|
1732
|
-
agentReasoning?: string;
|
|
1733
|
-
};
|
|
1734
|
-
type BatchAskOptions = {
|
|
1735
|
-
/** Array of questions with optional answers */
|
|
1736
|
-
questions: Array<{
|
|
1737
|
-
question: string;
|
|
1738
|
-
answer?: string;
|
|
1739
|
-
}>;
|
|
1740
|
-
/** Whether to take a screenshot of the task state */
|
|
1741
|
-
screenshot?: boolean;
|
|
1742
|
-
/** Custom system prompt for the evaluator */
|
|
1743
|
-
systemPrompt?: string;
|
|
1744
|
-
/** Delay in milliseconds before taking the screenshot @default 1000 */
|
|
1745
|
-
screenshotDelayMs?: number;
|
|
1746
|
-
};
|
|
1747
|
-
/**
|
|
1748
|
-
* Result of an evaluation
|
|
1749
|
-
*/
|
|
1750
|
-
interface EvaluationResult {
|
|
1751
|
-
/**
|
|
1752
|
-
* The evaluation result ('YES', 'NO', or 'INVALID' if parsing failed or value was unexpected)
|
|
1753
|
-
*/
|
|
1754
|
-
evaluation: "YES" | "NO" | "INVALID";
|
|
1755
|
-
/**
|
|
1756
|
-
* The reasoning behind the evaluation
|
|
1757
|
-
*/
|
|
1758
|
-
reasoning: string;
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
1719
|
/**
|
|
1762
1720
|
* V3Evaluator mirrors Evaluator but operates on a V3 instance instead of Stagehand.
|
|
1763
1721
|
* It uses the V3 page/screenshot APIs and constructs an LLM client to run
|
|
@@ -1776,4 +1734,4 @@ declare class V3Evaluator {
|
|
|
1776
1734
|
private _evaluateWithMultipleScreenshots;
|
|
1777
1735
|
}
|
|
1778
1736
|
|
|
1779
|
-
export { type AISDKCustomProvider, type AISDKProvider, type ActOptions, type ActResult, type Action, type ActionExecutionResult, type AgentAction, type AgentConfig, type AgentExecuteOptions, type AgentExecutionOptions, type AgentHandlerOptions, type AgentInstance, type AgentModelConfig, AgentProvider, type AgentProviderType, type
|
|
1737
|
+
export { type AISDKCustomProvider, type AISDKProvider, AVAILABLE_CUA_MODELS, type ActOptions, type ActResult, type Action, type ActionExecutionResult, type AgentAction, type AgentConfig, type AgentExecuteOptions, type AgentExecutionOptions, type AgentHandlerOptions, type AgentInstance, type AgentModelConfig, AgentProvider, type AgentProviderType, type AgentResult, AgentScreenshotProviderError, type AgentType, AnnotatedScreenshotText, type AnthropicContentBlock, type AnthropicJsonSchemaObject, type AnthropicMessage, type AnthropicTextBlock, type AnthropicToolResult, type AnyPage, type AvailableCuaModel, type AvailableModel, BrowserbaseSessionNotFoundError, CaptchaTimeoutError, type ChatCompletionOptions, type ChatMessage, type ChatMessageContent, type ChatMessageImageContent, type ChatMessageTextContent, type ClientOptions, type ComputerCallItem, ContentFrameNotFoundError, type CreateChatCompletionOptions, CreateChatCompletionResponseError, ExperimentalApiConflictError, ExperimentalNotConfiguredError, type ExtractOptions, type ExtractResult, type FunctionCallItem, HandlerNotInitializedError, type HistoryEntry, InvalidAISDKModelFormatError, type JsonSchema, type JsonSchemaProperty, LLMClient, type LLMResponse, LLMResponseError, type LLMTool, LOG_LEVEL_NAMES, type LoadState, type LocalBrowserLaunchOptions, type LogLevel, type LogLine, type Logger, MCPConnectionError, MissingEnvironmentVariableError, MissingLLMConfigurationError, type ModelConfiguration, type ModelProvider, type ObserveOptions, type ResponseInputItem, type ResponseItem, V3 as Stagehand, StagehandAPIError, StagehandAPIUnauthorizedError, StagehandClickError, StagehandDefaultError, StagehandDomProcessError, StagehandElementNotFoundError, StagehandEnvironmentError, StagehandError, StagehandEvalError, StagehandHttpError, StagehandIframeError, StagehandInitError, StagehandInvalidArgumentError, StagehandMissingArgumentError, StagehandNotInitializedError, StagehandResponseBodyError, StagehandResponseParseError, StagehandServerError, StagehandShadowRootMissingError, StagehandShadowSegmentEmptyError, StagehandShadowSegmentNotFoundError, type ToolUseItem, UnsupportedAISDKModelProviderError, UnsupportedModelError, UnsupportedModelProviderError, V3, type V3Env, V3Evaluator, V3FunctionName, type V3Metrics, type V3Options, XPathResolutionError, ZodSchemaValidationError, connectToMCPServer, defaultExtractSchema, getZodType, injectUrls, isRunningInBun, jsonSchemaToZod, loadApiKeyFromEnv, modelToAgentProviderMap, pageTextSchema, providerEnvVarMap, toGeminiSchema, transformSchema, trimTrailingTextNode, validateZodSchema };
|