crawlee-stagehand.api
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 { AgentResult } 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 { ContextPipeline } from '@crawlee/browser';
import type { CrawlingContext } 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 type { LoadedContext } from '@crawlee/browser';
import { ModelConfiguration } from '@browserbasehq/stagehand';
import type { NonStreamingAgentInstance } from '@browserbasehq/stagehand';
import { ObserveOptions } from '@browserbasehq/stagehand';
import type { Page } from 'playwright';
import type { RemoteBrowserPool } from '@crawlee/browser-pool';
import type { RemoteBrowserPoolOptions } from '@crawlee/browser-pool';
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 }
export { AgentResult }
// @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 }
// @public
export function remoteStagehandBrowserPool(options: RemoteStagehandBrowserPoolOptions): RemoteBrowserPool<Page>;
// @public (undocumented)
export interface RemoteStagehandBrowserPoolOptions extends Pick<StagehandBrowserPoolOptions, 'launchContext' | 'stagehandOptions' | 'headless' | 'configuration'>, Omit<RemoteBrowserPoolOptions, 'browserPlugins'> {
}
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, LaunchOptions, StagehandCrawlingContext, ContextExtension, ExtendedContext, Routes, StatisticStateExtension> {
constructor(options?: StagehandCrawlerOptions<ContextExtension, ExtendedContext, Routes, StatisticStateExtension>);
// (undocumented)
protected buildContextPipeline(): ContextPipeline<CrawlingContext, StagehandCrawlingContext>;
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> {
launcher?: BrowserType;
launchOptions?: LaunchOptions & Parameters<BrowserType['launchPersistentContext']>[1];
proxyUrl?: string;
stagehandOptions?: StagehandOptions;
useChrome?: boolean;
useIncognitoPages?: boolean;
userDataDir?: string;
}
// @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>;
getStagehandForBrowser(browser: Browser): Stagehand | undefined;
protected isChromiumBasedBrowser(): boolean;
protected _launch(launchContext: LaunchContext<BrowserType>): Promise<Browser>;
// (undocumented)
readonly stagehandOptions: StagehandOptions;
}
// Not exported by the entry point; reachable only as a referenced type.
// @public
interface StagehandPluginOptions extends BrowserPluginOptions<LaunchOptions> {
stagehandOptions?: StagehandOptions;
}
// @public
export interface StagehandRequestHandler extends RequestHandler<LoadedContext<StagehandCrawlingContext>> {
}
declare namespace stagehandUtils {
export {
enhancePageWithStagehand
}
}
export * from "@crawlee/browser";
// (No @packageDocumentation comment for this package)