Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
Public API Report File for "@crawlee/stagehand"
Do not edit this file. It is a report generated by API Extractor.
import { Action } from '@browserbasehq/stagehand';
import { ActOptions } from '@browserbasehq/stagehand';
import { ActResult } from '@browserbasehq/stagehand';
import { AgentConfig } from '@browserbasehq/stagehand';
import type { Browser } from 'playwright';
import type { BrowserController } from '@crawlee/browser-pool';
import { BrowserCrawler } from '@crawlee/browser';
import { BrowserCrawlerOptions } from '@crawlee/browser';
import type { BrowserCrawlingContext } from '@crawlee/browser';
import type { BrowserHook } from '@crawlee/browser';
import type { BrowserLaunchContext } from '@crawlee/browser';
import { BrowserPlugin } from '@crawlee/browser-pool';
import type { BrowserPluginOptions } from '@crawlee/browser-pool';
import type { BrowserPool } from '@crawlee/browser-pool';
import type { BrowserPoolHooks } from '@crawlee/browser-pool';
import type { BrowserPoolOptions } from '@crawlee/browser-pool';
import type { BrowserType } from 'playwright';
import { Configuration } from '@crawlee/browser';
import type { Dictionary } from '@crawlee/types';
import { ExtractOptions } from '@browserbasehq/stagehand';
import type { GetUserDataFromRequest } from '@crawlee/browser';
import type { LaunchContext } from '@crawlee/browser-pool';
import type { LaunchOptions } from 'playwright';
import type { LLMClient } from '@browserbasehq/stagehand';
import { ModelConfiguration } from '@browserbasehq/stagehand';
import type { NonStreamingAgentInstance } from '@browserbasehq/stagehand';
import { ObserveOptions } from '@browserbasehq/stagehand';
import type { Page } from 'playwright';
import type { RequestHandler } from '@crawlee/browser';
import type { Response as Response_2 } from 'playwright';
import type { RouterHandler } from '@crawlee/browser';
import type { RouterRoutes } from '@crawlee/browser';
import type { RouteSchemas } from '@crawlee/browser';
import type { RoutesFromSchemas } from '@crawlee/browser';
import { Stagehand } from '@browserbasehq/stagehand';
import type { StreamingAgentInstance } from '@browserbasehq/stagehand';
import { z } from 'zod';
export { Action }
export { ActOptions }
export { ActResult }
export { AgentConfig }
// @public
export function createStagehandRouter<Context extends StagehandCrawlingContext = StagehandCrawlingContext, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<Context['request']>>>(routes?: RouterRoutes<Context, Routes>): RouterHandler<Context, Routes>;
// @public (undocumented)
export function createStagehandRouter<Context extends StagehandCrawlingContext = StagehandCrawlingContext, UserData extends Dictionary = GetUserDataFromRequest<Context['request']>>(routes?: RouterRoutes<Context, Record<string, UserData>>): RouterHandler<Context, Record<string, UserData>>;
// @public (undocumented)
export function createStagehandRouter<Context extends StagehandCrawlingContext = StagehandCrawlingContext, const Schemas extends RouteSchemas = RouteSchemas>(schemas: Schemas): RouterHandler<Context, RoutesFromSchemas<Schemas>>;
export { ExtractOptions }
export { ModelConfiguration }
export { ObserveOptions }
export { Stagehand }
// @public
export type StagehandBrowserPool = BrowserPool<{
browserPlugins: [StagehandPlugin];
}, [StagehandPlugin]>;
// @public
export function stagehandBrowserPool(options?: StagehandBrowserPoolOptions): StagehandBrowserPool;
// @public (undocumented)
export interface StagehandBrowserPoolOptions extends Omit<BrowserPoolOptions, 'browserPlugins'>, BrowserPoolHooks<ReturnType<StagehandPlugin['createController']>, ReturnType<StagehandPlugin['createLaunchContext']>, Page> {
configuration?: Configuration;
headless?: boolean;
launchContext?: StagehandLaunchContext;
stagehandOptions?: StagehandOptions;
}
// @public
export class StagehandCrawler<ContextExtension = Dictionary<never>, ExtendedContext extends StagehandCrawlingContext = StagehandCrawlingContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<StagehandCrawlingContext['request']>>, StatisticStateExtension extends object = {}> extends BrowserCrawler<StagehandPage, Response_2, StagehandCrawlingContext, ContextExtension, ExtendedContext, Routes, StatisticStateExtension> {
constructor(options?: StagehandCrawlerOptions<ContextExtension, ExtendedContext, Routes, StatisticStateExtension>);
protected navigationHandler(crawlingContext: StagehandCrawlingContext, gotoOptions: StagehandGotoOptions): Promise<Response_2 | null>;
}
// @public
export interface StagehandCrawlerOptions<ContextExtension = Dictionary<never>, ExtendedContext extends StagehandCrawlingContext = StagehandCrawlingContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<StagehandCrawlingContext['request']>>, StatisticStateExtension extends object = {}> extends BrowserCrawlerOptions<StagehandPage, Response_2, StagehandCrawlingContext, ContextExtension, ExtendedContext, Routes, StatisticStateExtension> {
headless?: boolean;
launchContext?: StagehandLaunchContext;
postNavigationHooks?: BrowserHook<StagehandCrawlingContext<GetUserDataFromRequest<ExtendedContext['request']>>, ContextExtension>[];
preNavigationHooks?: BrowserHook<StagehandCrawlingContext<GetUserDataFromRequest<ExtendedContext['request']>>, ContextExtension>[];
requestHandler?: RouterHandler<ExtendedContext, Routes> | RequestHandler<ExtendedContext>;
stagehandOptions?: StagehandOptions;
}
// @public (undocumented)
export interface StagehandCrawlingContext<UserData extends Dictionary = any> extends BrowserCrawlingContext<StagehandPage, Response_2, UserData, StagehandGotoOptions> {
page: StagehandPage;
stagehand: Stagehand;
}
// @public
export type StagehandGotoOptions = NonNullable<Parameters<Page['goto']>[1]>;
// @public
export type StagehandHook<UserData extends Dictionary = any> = BrowserHook<StagehandCrawlingContext<UserData>>;
// @public
export interface StagehandLaunchContext extends BrowserLaunchContext<LaunchOptions, BrowserType> {
launchOptions?: LaunchOptions & Parameters<BrowserType['launchPersistentContext']>[1];
proxyUrl?: string;
useChrome?: boolean;
}
// @public
export interface StagehandOptions {
apiKey?: string;
cacheDir?: string;
domSettleTimeout?: number;
env?: 'LOCAL' | 'BROWSERBASE';
llmClient?: LLMClient;
logInferenceToFile?: boolean;
model?: ModelConfiguration;
projectId?: string;
selfHeal?: boolean;
systemPrompt?: string;
verbose?: 0 | 1 | 2;
}
// @public
export interface StagehandPage extends Page {
act(instruction: string, options?: Omit<ActOptions, 'page'>): Promise<ActResult>;
agent(config: AgentConfig & {
stream: true;
}): StreamingAgentInstance;
// (undocumented)
agent(config?: AgentConfig & {
stream?: false;
}): NonStreamingAgentInstance;
extract<T>(instruction: string, schema: z.ZodType<T>, options?: Omit<ExtractOptions, 'page'>): Promise<T>;
observe(options?: Omit<ObserveOptions, 'page'>): Promise<Action[]>;
}
// Not exported by the entry point; reachable only as a referenced type.
// @public
class StagehandPlugin extends BrowserPlugin<BrowserType, LaunchOptions, Browser> {
constructor(library: BrowserType, options?: StagehandPluginOptions);
protected addProxyToLaunchOptions(launchContext: LaunchContext<BrowserType>): Promise<void>;
createController(): BrowserController<BrowserType, LaunchOptions, Browser>;
protected isChromiumBasedBrowser(): boolean;
protected _launch(launchContext: LaunchContext<BrowserType>): Promise<Browser>;
}
// Not exported by the entry point; reachable only as a referenced type.
// @public
interface StagehandPluginOptions extends BrowserPluginOptions<LaunchOptions> {
stagehandOptions?: StagehandOptions;
}
export * from "@crawlee/browser";
// (No @packageDocumentation comment for this package)