@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.
Files changed (74) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +43 -6
  3. package/dist/lib/StagehandContext.d.ts +25 -0
  4. package/dist/lib/StagehandPage.d.ts +103 -0
  5. package/dist/lib/a11y/utils.d.ts +144 -0
  6. package/dist/lib/agent/AgentClient.d.ts +20 -0
  7. package/dist/lib/agent/AgentProvider.d.ts +19 -0
  8. package/dist/lib/agent/AnthropicCUAClient.d.ts +56 -0
  9. package/dist/lib/agent/GoogleCUAClient.d.ts +63 -0
  10. package/dist/lib/agent/OpenAICUAClient.d.ts +65 -0
  11. package/dist/lib/agent/StagehandAgent.d.ts +15 -0
  12. package/dist/lib/agent/tools/act.d.ts +59 -0
  13. package/dist/lib/agent/tools/ariaTree.d.ts +11 -0
  14. package/dist/lib/agent/tools/close.d.ts +22 -0
  15. package/dist/lib/agent/tools/extract.d.ts +38 -0
  16. package/dist/lib/agent/tools/fillform.d.ts +37 -0
  17. package/dist/lib/agent/tools/goto.d.ts +29 -0
  18. package/dist/lib/agent/tools/index.d.ts +257 -0
  19. package/dist/lib/agent/tools/navback.d.ts +17 -0
  20. package/dist/lib/agent/tools/screenshot.d.ts +13 -0
  21. package/dist/lib/agent/tools/scroll.d.ts +23 -0
  22. package/dist/lib/agent/tools/wait.d.ts +18 -0
  23. package/dist/lib/agent/utils/cuaKeyMapping.d.ts +10 -0
  24. package/dist/lib/agent/utils/imageCompression.d.ts +53 -0
  25. package/dist/lib/agent/utils/messageProcessing.d.ts +13 -0
  26. package/dist/lib/browserbaseDefaults.d.ts +9 -0
  27. package/dist/lib/cache/ActionCache.d.ts +62 -0
  28. package/dist/lib/cache/BaseCache.d.ts +66 -0
  29. package/dist/lib/cache/LLMCache.d.ts +22 -0
  30. package/dist/lib/cache.d.ts +29 -0
  31. package/dist/lib/dom/elementCheckUtils.d.ts +2 -0
  32. package/dist/lib/dom/genDomScripts.d.ts +1 -0
  33. package/dist/lib/dom/index.d.ts +2 -0
  34. package/dist/lib/dom/process.d.ts +17 -0
  35. package/dist/lib/dom/utils.d.ts +7 -0
  36. package/dist/lib/dom/xpathUtils.d.ts +14 -0
  37. package/dist/lib/handlers/actHandler.d.ts +33 -0
  38. package/dist/lib/handlers/cuaAgentHandler.d.ts +58 -0
  39. package/dist/lib/handlers/extractHandler.d.ts +54 -0
  40. package/dist/lib/handlers/handlerUtils/actHandlerUtils.d.ts +21 -0
  41. package/dist/lib/handlers/observeHandler.d.ts +40 -0
  42. package/dist/lib/handlers/stagehandAgentHandler.d.ts +27 -0
  43. package/dist/lib/index.d.ts +94 -0
  44. package/dist/lib/llm/AnthropicClient.d.ts +21 -0
  45. package/dist/lib/llm/CerebrasClient.d.ts +22 -0
  46. package/dist/lib/llm/GoogleClient.d.ts +24 -0
  47. package/dist/lib/llm/GroqClient.d.ts +22 -0
  48. package/dist/lib/llm/LLMClient.d.ts +99 -0
  49. package/dist/lib/llm/LLMProvider.d.ts +13 -0
  50. package/dist/lib/llm/OpenAIClient.d.ts +20 -0
  51. package/dist/lib/llm/aisdk.d.ts +20 -0
  52. package/dist/lib/mcp/connection.d.ts +11 -0
  53. package/dist/lib/mcp/utils.d.ts +3 -0
  54. package/dist/lib/v3/tests/downloads.spec.d.ts +1 -0
  55. package/dist/lib/v3/tests/v3.bb.config.d.ts +4 -0
  56. package/dist/lib/v3/v3.d.ts +2 -0
  57. package/dist/lib/version.d.ts +1 -1
  58. package/dist/stagehand.config.d.ts +3 -0
  59. package/dist/types/act.d.ts +50 -0
  60. package/dist/types/agent.d.ts +143 -0
  61. package/dist/types/api.d.ts +40 -0
  62. package/dist/types/browser.d.ts +10 -0
  63. package/dist/types/context.d.ts +117 -0
  64. package/dist/types/evals.d.ts +94 -0
  65. package/dist/types/evaluator.d.ts +40 -0
  66. package/dist/types/llm.d.ts +11 -0
  67. package/dist/types/log.d.ts +23 -0
  68. package/dist/types/model.d.ts +17 -0
  69. package/dist/types/page.d.ts +38 -0
  70. package/dist/types/playwright.d.ts +12 -0
  71. package/dist/types/stagehand.d.ts +330 -0
  72. package/dist/types/stagehandApiErrors.d.ts +18 -0
  73. package/dist/types/stagehandErrors.d.ts +104 -0
  74. package/package.json +1 -1
@@ -0,0 +1,66 @@
1
+ import { LogLine } from "../../types/log";
2
+ export interface CacheEntry {
3
+ timestamp: number;
4
+ data: unknown;
5
+ requestId: string;
6
+ }
7
+ export interface CacheStore {
8
+ [key: string]: CacheEntry;
9
+ }
10
+ export declare class BaseCache<T extends CacheEntry> {
11
+ private readonly CACHE_MAX_AGE_MS;
12
+ private readonly CLEANUP_PROBABILITY;
13
+ protected cacheDir: string;
14
+ protected cacheFile: string;
15
+ protected lockFile: string;
16
+ protected logger: (message: LogLine) => void;
17
+ private readonly LOCK_TIMEOUT_MS;
18
+ protected lockAcquired: boolean;
19
+ protected lockAcquireFailures: number;
20
+ protected requestIdToUsedHashes: {
21
+ [key: string]: string[];
22
+ };
23
+ constructor(logger: (message: LogLine) => void, cacheDir?: string, cacheFile?: string);
24
+ private setupProcessHandlers;
25
+ protected ensureCacheDirectory(): void;
26
+ protected createHash(data: unknown): string;
27
+ protected sleep(ms: number): Promise<void>;
28
+ acquireLock(): Promise<boolean>;
29
+ releaseLock(): void;
30
+ /**
31
+ * Cleans up stale cache entries that exceed the maximum age.
32
+ */
33
+ cleanupStaleEntries(): Promise<void>;
34
+ protected readCache(): CacheStore;
35
+ protected writeCache(cache: CacheStore): void;
36
+ /**
37
+ * Retrieves data from the cache based on the provided options.
38
+ * @param hashObj - The options used to generate the cache key.
39
+ * @param requestId - The identifier for the current request.
40
+ * @returns The cached data if available, otherwise null.
41
+ */
42
+ get(hashObj: Record<string, unknown> | string, requestId: string): Promise<T["data"] | null>;
43
+ /**
44
+ * Stores data in the cache based on the provided options and requestId.
45
+ * @param hashObj - The options used to generate the cache key.
46
+ * @param data - The data to be cached.
47
+ * @param requestId - The identifier for the cache entry.
48
+ */
49
+ set(hashObj: Record<string, unknown>, data: T["data"], requestId: string): Promise<void>;
50
+ delete(hashObj: Record<string, unknown>): Promise<void>;
51
+ /**
52
+ * Tracks the usage of a hash with a specific requestId.
53
+ * @param requestId - The identifier for the current request.
54
+ * @param hash - The cache key hash.
55
+ */
56
+ protected trackRequestIdUsage(requestId: string, hash: string): void;
57
+ /**
58
+ * Deletes all cache entries associated with a specific requestId.
59
+ * @param requestId - The identifier for the request whose cache entries should be deleted.
60
+ */
61
+ deleteCacheForRequestId(requestId: string): Promise<void>;
62
+ /**
63
+ * Resets the entire cache by clearing the cache file.
64
+ */
65
+ resetCache(): void;
66
+ }
@@ -0,0 +1,22 @@
1
+ import { BaseCache, CacheEntry } from "./BaseCache";
2
+ export declare class LLMCache extends BaseCache<CacheEntry> {
3
+ constructor(logger: (message: {
4
+ category?: string;
5
+ message: string;
6
+ level?: number;
7
+ }) => void, cacheDir?: string, cacheFile?: string);
8
+ /**
9
+ * Overrides the get method to track used hashes by requestId.
10
+ * @param options - The options used to generate the cache key.
11
+ * @param requestId - The identifier for the current request.
12
+ * @returns The cached data if available, otherwise null.
13
+ */
14
+ get<T>(options: Record<string, unknown>, requestId: string): Promise<T | null>;
15
+ /**
16
+ * Overrides the set method to include cache cleanup logic.
17
+ * @param options - The options used to generate the cache key.
18
+ * @param data - The data to be cached.
19
+ * @param requestId - The identifier for the current request.
20
+ */
21
+ set(options: Record<string, unknown>, data: unknown, requestId: string): Promise<void>;
22
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * A file system cache to skip inference when repeating steps
3
+ * It also acts as the source of truth for identifying previously seen actions and observations
4
+ */
5
+ declare class Cache {
6
+ disabled: boolean;
7
+ constructor({ disabled }?: {
8
+ disabled?: boolean;
9
+ });
10
+ readObservations(): any;
11
+ readActions(): any;
12
+ writeObservations({ key, value, }: {
13
+ key: string;
14
+ value: {
15
+ id: string;
16
+ result: string;
17
+ };
18
+ }): void;
19
+ writeActions({ key, value, }: {
20
+ key: string;
21
+ value: {
22
+ id: string;
23
+ result: string;
24
+ };
25
+ }): void;
26
+ evictCache(): void;
27
+ private initCache;
28
+ }
29
+ export default Cache;
@@ -0,0 +1,2 @@
1
+ export declare function isElementNode(node: Node): node is Element;
2
+ export declare function isTextNode(node: Node): node is Text;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./process";
2
+ export * from "./utils";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Finds and returns a list of scrollable elements on the page,
3
+ * ordered from the element with the largest scrollHeight to the smallest.
4
+ *
5
+ * @param topN Optional maximum number of scrollable elements to return.
6
+ * If not provided, all found scrollable elements are returned.
7
+ * @returns An array of HTMLElements sorted by descending scrollHeight.
8
+ */
9
+ export declare function getScrollableElements(topN?: number): HTMLElement[];
10
+ /**
11
+ * Calls getScrollableElements, then for each element calls generateXPaths,
12
+ * and returns the first XPath for each.
13
+ *
14
+ * @param topN (optional) integer limit on how many scrollable elements to process
15
+ * @returns string[] list of XPaths (1 for each scrollable element)
16
+ */
17
+ export declare function getScrollableElementXpaths(topN?: number): Promise<string[]>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Tests if the element actually responds to .scrollTo(...)
3
+ * and that scrollTop changes as expected.
4
+ */
5
+ export declare function canElementScroll(elem: HTMLElement): boolean;
6
+ export declare function getNodeFromXpath(xpath: string): Node;
7
+ export declare function waitForElementScrollEnd(element: HTMLElement, idleMs?: number): Promise<void>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Escapes a string for use in an XPath expression.
3
+ * Handles special characters, including single and double quotes.
4
+ * @param value - The string to escape.
5
+ * @returns The escaped string safe for XPath.
6
+ */
7
+ export declare function escapeXPathString(value: string): string;
8
+ /**
9
+ * Generates both a complicated XPath and a standard XPath for a given DOM element.
10
+ * @param element - The target DOM element.
11
+ * @param documentOverride - Optional document override.
12
+ * @returns An object containing both XPaths.
13
+ */
14
+ export declare function generateXPathsForElement(element: ChildNode): Promise<string[]>;
@@ -0,0 +1,33 @@
1
+ import { LogLine } from "../../types/log";
2
+ import { LLMClient } from "../llm/LLMClient";
3
+ import { StagehandPage } from "../StagehandPage";
4
+ import { ActResult, ObserveResult, ActOptions } from "@/types/stagehand";
5
+ import { StagehandObserveHandler } from "@/lib/handlers/observeHandler";
6
+ /**
7
+ * NOTE: Vision support has been removed from this version of Stagehand.
8
+ * If useVision or verifierUseVision is set to true, a warning is logged and
9
+ * the flow continues as if vision = false.
10
+ */
11
+ export declare class StagehandActHandler {
12
+ private readonly stagehandPage;
13
+ private readonly logger;
14
+ private readonly selfHeal;
15
+ private readonly experimental;
16
+ constructor({ logger, stagehandPage, selfHeal, experimental, }: {
17
+ logger: (logLine: LogLine) => void;
18
+ stagehandPage: StagehandPage;
19
+ selfHeal: boolean;
20
+ experimental: boolean;
21
+ });
22
+ /**
23
+ * Perform an immediate Playwright action based on an ObserveResult object
24
+ * that was returned from `page.observe(...)`.
25
+ */
26
+ actFromObserveResult(observe: ObserveResult, domSettleTimeoutMs?: number): Promise<ActResult>;
27
+ /**
28
+ * Perform an act based on an instruction.
29
+ * This method will observe the page and then perform the act on the first element returned.
30
+ */
31
+ observeAct(actionOrOptions: ActOptions, observeHandler: StagehandObserveHandler, llmClient: LLMClient, requestId: string): Promise<ActResult>;
32
+ private _performPlaywrightMethod;
33
+ }
@@ -0,0 +1,58 @@
1
+ import { AgentExecuteOptions, AgentHandlerOptions, AgentResult } from "@/types/agent";
2
+ import { ToolSet } from "ai/dist";
3
+ import { LogLine } from "../../types/log";
4
+ import { StagehandPage } from "../StagehandPage";
5
+ import { AgentClient } from "../agent/AgentClient";
6
+ import { StagehandAgent } from "../agent/StagehandAgent";
7
+ import { Stagehand } from "../index";
8
+ export declare class CuaAgentHandler {
9
+ private stagehand;
10
+ private stagehandPage;
11
+ private agent;
12
+ private provider;
13
+ private logger;
14
+ private agentClient;
15
+ private options;
16
+ private screenshotCollector?;
17
+ private highlightCursor;
18
+ constructor(stagehand: Stagehand, stagehandPage: StagehandPage, logger: (message: LogLine) => void, options: AgentHandlerOptions, tools?: ToolSet);
19
+ private setupAgentClient;
20
+ /**
21
+ * Execute a task with the agent
22
+ */
23
+ execute(optionsOrInstruction: AgentExecuteOptions | string): Promise<AgentResult>;
24
+ /**
25
+ * Execute a single action on the page
26
+ */
27
+ private executeAction;
28
+ private updateClientViewport;
29
+ private updateClientUrl;
30
+ getAgent(): StagehandAgent;
31
+ getClient(): AgentClient;
32
+ captureAndSendScreenshot(): Promise<unknown>;
33
+ /**
34
+ * Inject a cursor element into the page for visual feedback
35
+ */
36
+ private injectCursor;
37
+ /**
38
+ * Update the cursor position on the page
39
+ */
40
+ private updateCursorPosition;
41
+ /**
42
+ * Animate a click at the given position
43
+ */
44
+ private animateClick;
45
+ private get page();
46
+ /**
47
+ * Set the screenshot collector for this agent handler
48
+ */
49
+ setScreenshotCollector(collector: any): void;
50
+ /**
51
+ * Get the screenshot collector
52
+ */
53
+ getScreenshotCollector(): any;
54
+ /**
55
+ * Set the tools for this agent handler
56
+ */
57
+ setTools(tools: ToolSet): void;
58
+ }
@@ -0,0 +1,54 @@
1
+ import { z } from "zod/v3";
2
+ import { ZodPathSegments } from "../../types/stagehand";
3
+ import { LLMClient } from "../llm/LLMClient";
4
+ import { StagehandPage } from "../StagehandPage";
5
+ import { Stagehand } from "../index";
6
+ export declare class StagehandExtractHandler {
7
+ private readonly stagehand;
8
+ private readonly stagehandPage;
9
+ private readonly logger;
10
+ private readonly userProvidedInstructions?;
11
+ private readonly experimental;
12
+ constructor({ stagehand, logger, stagehandPage, userProvidedInstructions, experimental, }: {
13
+ stagehand: Stagehand;
14
+ logger: (message: {
15
+ category?: string;
16
+ message: string;
17
+ level?: number;
18
+ auxiliary?: {
19
+ [key: string]: {
20
+ value: string;
21
+ type: string;
22
+ };
23
+ };
24
+ }) => void;
25
+ stagehandPage: StagehandPage;
26
+ userProvidedInstructions?: string;
27
+ experimental: boolean;
28
+ });
29
+ extract<T extends z.AnyZodObject>({ instruction, schema, content, llmClient, requestId, domSettleTimeoutMs, useTextExtract, selector, iframes, }?: {
30
+ instruction?: string;
31
+ schema?: T;
32
+ content?: z.infer<T>;
33
+ chunksSeen?: Array<number>;
34
+ llmClient?: LLMClient;
35
+ requestId?: string;
36
+ domSettleTimeoutMs?: number;
37
+ useTextExtract?: boolean;
38
+ selector?: string;
39
+ iframes?: boolean;
40
+ }): Promise<z.infer<T>>;
41
+ private extractPageText;
42
+ private domExtract;
43
+ }
44
+ /**
45
+ * Scans the provided Zod schema for any `z.string().url()` fields and
46
+ * replaces them with `z.number()`.
47
+ *
48
+ * @param schema - The Zod object schema to transform.
49
+ * @returns A tuple containing:
50
+ * 1. The transformed schema (or the original schema if no changes were needed).
51
+ * 2. An array of {@link ZodPathSegments} objects representing all the replaced URL fields,
52
+ * with each path segment showing where in the schema the replacement occurred.
53
+ */
54
+ export declare function transformUrlStringsToNumericIds<T extends z.ZodObject<z.ZodRawShape>>(schema: T): [T, ZodPathSegments[]];
@@ -0,0 +1,21 @@
1
+ import { Page, Locator, FrameLocator } from "playwright";
2
+ import { MethodHandlerContext } from "@/types/act";
3
+ export declare function deepLocatorWithShadow(root: Page | FrameLocator, xpath: string): Promise<Locator>;
4
+ export declare function deepLocator(root: Page | FrameLocator, xpath: string): Locator;
5
+ /**
6
+ * A mapping of playwright methods that may be chosen by the LLM to their
7
+ * implementation.
8
+ */
9
+ export declare const methodHandlerMap: Record<string, (ctx: MethodHandlerContext) => Promise<void>>;
10
+ export declare function scrollToNextChunk(ctx: MethodHandlerContext): Promise<void>;
11
+ export declare function scrollToPreviousChunk(ctx: MethodHandlerContext): Promise<void>;
12
+ export declare function scrollElementIntoView(ctx: MethodHandlerContext): Promise<void>;
13
+ export declare function scrollElementToPercentage(ctx: MethodHandlerContext): Promise<void>;
14
+ export declare function fillOrType(ctx: MethodHandlerContext): Promise<void>;
15
+ export declare function pressKey(ctx: MethodHandlerContext): Promise<void>;
16
+ export declare function selectOption(ctx: MethodHandlerContext): Promise<void>;
17
+ export declare function clickElement(ctx: MethodHandlerContext): Promise<void>;
18
+ /**
19
+ * Fallback method: if method is not in our map but *is* a valid Playwright locator method.
20
+ */
21
+ export declare function fallbackLocatorMethod(ctx: MethodHandlerContext): Promise<void>;
@@ -0,0 +1,40 @@
1
+ import { LogLine } from "../../types/log";
2
+ import { Stagehand } from "../index";
3
+ import { LLMClient } from "../llm/LLMClient";
4
+ import { StagehandPage } from "../StagehandPage";
5
+ export declare class StagehandObserveHandler {
6
+ private readonly stagehand;
7
+ private readonly logger;
8
+ private readonly stagehandPage;
9
+ private readonly experimental;
10
+ private readonly userProvidedInstructions?;
11
+ constructor({ stagehand, logger, stagehandPage, userProvidedInstructions, experimental, }: {
12
+ stagehand: Stagehand;
13
+ logger: (logLine: LogLine) => void;
14
+ stagehandPage: StagehandPage;
15
+ userProvidedInstructions?: string;
16
+ experimental: boolean;
17
+ });
18
+ observe({ instruction, llmClient, requestId, returnAction, onlyVisible, drawOverlay, fromAct, iframes, }: {
19
+ instruction: string;
20
+ llmClient: LLMClient;
21
+ requestId: string;
22
+ domSettleTimeoutMs?: number;
23
+ returnAction?: boolean;
24
+ /**
25
+ * @deprecated The `onlyVisible` parameter has no effect in this version of Stagehand and will be removed in later versions.
26
+ */
27
+ onlyVisible?: boolean;
28
+ drawOverlay?: boolean;
29
+ fromAct?: boolean;
30
+ iframes?: boolean;
31
+ }): Promise<({
32
+ selector: string;
33
+ description: string;
34
+ } | {
35
+ selector: string;
36
+ method: string;
37
+ arguments: string[];
38
+ description: string;
39
+ })[]>;
40
+ }
@@ -0,0 +1,27 @@
1
+ import { AgentExecuteOptions, AgentResult } from "@/types/agent";
2
+ import { LogLine } from "@/types/log";
3
+ import { LLMClient } from "../llm/LLMClient";
4
+ import { ToolSet } from "ai";
5
+ import { Stagehand } from "../index";
6
+ export declare class StagehandAgentHandler {
7
+ private stagehand;
8
+ private logger;
9
+ private llmClient;
10
+ private executionModel?;
11
+ private systemInstructions?;
12
+ private tools?;
13
+ private screenshotCollector?;
14
+ constructor(stagehand: Stagehand, logger: (message: LogLine) => void, llmClient: LLMClient, executionModel?: string, systemInstructions?: string, tools?: ToolSet);
15
+ execute(instructionOrOptions: string | AgentExecuteOptions): Promise<AgentResult>;
16
+ private buildSystemPrompt;
17
+ private createTools;
18
+ /**
19
+ * Set the screenshot collector for this agent handler
20
+ */
21
+ setScreenshotCollector(collector: any): void;
22
+ /**
23
+ * Get the screenshot collector
24
+ */
25
+ getScreenshotCollector(): any;
26
+ setTools(tools: ToolSet): void;
27
+ }
@@ -0,0 +1,94 @@
1
+ import { GotoOptions } from "@/types/playwright";
2
+ import { z } from "zod/v3";
3
+ import { AgentExecuteOptions, AgentResult } from "../types/agent";
4
+ import { EnhancedContext } from "../types/context";
5
+ import { LogLine } from "../types/log";
6
+ import { ClientOptions } from "../types/model";
7
+ import { Page } from "../types/page";
8
+ import { ActOptions, AgentConfig, ConstructorParams, ExtractOptions, HistoryEntry, InitResult, ObserveOptions, StagehandFunctionName, StagehandMetrics } from "../types/stagehand";
9
+ import { StagehandPage } from "./StagehandPage";
10
+ import { StagehandAPI } from "./api";
11
+ import { LLMClient } from "./llm/LLMClient";
12
+ import { LLMProvider } from "./llm/LLMProvider";
13
+ import { connectToMCPServer } from "./mcp/connection";
14
+ export declare class Stagehand {
15
+ private stagehandPage;
16
+ private stagehandContext;
17
+ browserbaseSessionID?: string;
18
+ readonly domSettleTimeoutMs: number;
19
+ readonly debugDom: boolean;
20
+ readonly headless: boolean;
21
+ verbose: 0 | 1 | 2;
22
+ llmProvider: LLMProvider;
23
+ enableCaching: boolean;
24
+ protected apiKey: string | undefined;
25
+ private projectId;
26
+ private externalLogger?;
27
+ private browserbaseSessionCreateParams?;
28
+ variables: {
29
+ [key: string]: unknown;
30
+ };
31
+ private contextPath?;
32
+ llmClient: LLMClient;
33
+ readonly userProvidedInstructions?: string;
34
+ private usingAPI;
35
+ private modelName;
36
+ apiClient: StagehandAPI | undefined;
37
+ readonly waitForCaptchaSolves: boolean;
38
+ private localBrowserLaunchOptions?;
39
+ readonly selfHeal: boolean;
40
+ private cleanupCalled;
41
+ readonly actTimeoutMs: number;
42
+ readonly logInferenceToFile?: boolean;
43
+ private stagehandLogger;
44
+ private disablePino;
45
+ protected modelClientOptions: ClientOptions;
46
+ private _env;
47
+ private _browser;
48
+ private _isClosed;
49
+ private _history;
50
+ readonly experimental: boolean;
51
+ private _livePageProxy?;
52
+ private createLivePageProxy;
53
+ get history(): ReadonlyArray<HistoryEntry>;
54
+ protected setActivePage(page: StagehandPage): void;
55
+ get page(): Page;
56
+ stagehandMetrics: StagehandMetrics;
57
+ get metrics(): StagehandMetrics;
58
+ get isClosed(): boolean;
59
+ updateMetrics(functionName: StagehandFunctionName, promptTokens: number, completionTokens: number, inferenceTimeMs: number): void;
60
+ private updateTotalMetrics;
61
+ constructor({ env, apiKey, projectId, verbose, llmProvider, llmClient, logger, browserbaseSessionCreateParams, domSettleTimeoutMs, enableCaching, browserbaseSessionID, modelName, modelClientOptions, systemPrompt, useAPI, localBrowserLaunchOptions, waitForCaptchaSolves, logInferenceToFile, selfHeal, disablePino, experimental, }?: ConstructorParams);
62
+ private registerSignalHandlers;
63
+ get logger(): (logLine: LogLine) => void;
64
+ get env(): "LOCAL" | "BROWSERBASE";
65
+ get downloadsPath(): string;
66
+ get context(): EnhancedContext;
67
+ init(): Promise<InitResult>;
68
+ log(logObj: LogLine): void;
69
+ close(): Promise<void>;
70
+ addToHistory(method: HistoryEntry["method"], parameters: ActOptions | ExtractOptions<z.AnyZodObject> | ObserveOptions | {
71
+ url: string;
72
+ options: GotoOptions;
73
+ } | string, result?: unknown): void;
74
+ /**
75
+ * Create an agent instance that can be executed with different instructions
76
+ * @returns An agent instance with execute() method
77
+ */
78
+ agent(options?: AgentConfig): {
79
+ execute: (instructionOrOptions: string | AgentExecuteOptions) => Promise<AgentResult>;
80
+ setScreenshotCollector?: (collector: unknown) => void;
81
+ };
82
+ }
83
+ export * from "../types/agent";
84
+ export * from "../types/browser";
85
+ export * from "../types/log";
86
+ export * from "../types/model";
87
+ export * from "../types/page";
88
+ export * from "../types/playwright";
89
+ export * from "../types/stagehand";
90
+ export * from "../types/stagehandApiErrors";
91
+ export * from "../types/stagehandErrors";
92
+ export * from "./llm/LLMClient";
93
+ export * from "./llm/aisdk";
94
+ export { connectToMCPServer };
@@ -0,0 +1,21 @@
1
+ import { ClientOptions } from "@anthropic-ai/sdk";
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 AnthropicClient extends LLMClient {
7
+ type: "anthropic";
8
+ private client;
9
+ private cache;
10
+ private enableCaching;
11
+ clientOptions: ClientOptions;
12
+ constructor({ enableCaching, cache, modelName, clientOptions, userProvidedInstructions, }: {
13
+ logger: (message: LogLine) => void;
14
+ enableCaching?: boolean;
15
+ cache?: LLMCache;
16
+ modelName: AvailableModel;
17
+ clientOptions?: ClientOptions;
18
+ userProvidedInstructions?: string;
19
+ });
20
+ createChatCompletion<T = LLMResponse>({ options, retries, logger, }: CreateChatCompletionOptions): Promise<T>;
21
+ }
@@ -0,0 +1,22 @@
1
+ import type { 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 CerebrasClient extends LLMClient {
7
+ type: "cerebras";
8
+ private client;
9
+ private cache;
10
+ private enableCaching;
11
+ clientOptions: ClientOptions;
12
+ hasVision: boolean;
13
+ constructor({ enableCaching, cache, modelName, clientOptions, userProvidedInstructions, }: {
14
+ logger: (message: LogLine) => void;
15
+ enableCaching?: boolean;
16
+ cache?: LLMCache;
17
+ modelName: AvailableModel;
18
+ clientOptions?: ClientOptions;
19
+ userProvidedInstructions?: string;
20
+ });
21
+ createChatCompletion<T = LLMResponse>({ options, retries, logger, }: CreateChatCompletionOptions): Promise<T>;
22
+ }
@@ -0,0 +1,24 @@
1
+ import { LogLine } from "../../types/log";
2
+ import { AvailableModel, ClientOptions } from "../../types/model";
3
+ import { LLMCache } from "../cache/LLMCache";
4
+ import { CreateChatCompletionOptions, LLMClient, LLMResponse } from "./LLMClient";
5
+ export declare class GoogleClient extends LLMClient {
6
+ type: "google";
7
+ private client;
8
+ private cache;
9
+ private enableCaching;
10
+ clientOptions: ClientOptions;
11
+ hasVision: boolean;
12
+ private logger;
13
+ constructor({ logger, // Added logger based on other clients
14
+ enableCaching, cache, modelName, clientOptions, }: {
15
+ logger: (message: LogLine) => void;
16
+ enableCaching?: boolean;
17
+ cache?: LLMCache;
18
+ modelName: AvailableModel;
19
+ clientOptions?: ClientOptions;
20
+ });
21
+ private formatMessages;
22
+ private formatTools;
23
+ createChatCompletion<T = LLMResponse>({ options, logger, retries, }: CreateChatCompletionOptions): Promise<T>;
24
+ }
@@ -0,0 +1,22 @@
1
+ import type { 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 GroqClient extends LLMClient {
7
+ type: "groq";
8
+ private client;
9
+ private cache;
10
+ private enableCaching;
11
+ clientOptions: ClientOptions;
12
+ hasVision: boolean;
13
+ constructor({ enableCaching, cache, modelName, clientOptions, userProvidedInstructions, }: {
14
+ logger: (message: LogLine) => void;
15
+ enableCaching?: boolean;
16
+ cache?: LLMCache;
17
+ modelName: AvailableModel;
18
+ clientOptions?: ClientOptions;
19
+ userProvidedInstructions?: string;
20
+ });
21
+ createChatCompletion<T = LLMResponse>({ options, retries, logger, }: CreateChatCompletionOptions): Promise<T>;
22
+ }