UNPKG

@ui-tars/operator-browser

Version:
91 lines 3.38 kB
import { Operator } from '@ui-tars/sdk/core'; import { BrowserType } from '@agent-infra/browser'; import type { ScreenshotOutput, ExecuteParams, ExecuteOutput } from '@ui-tars/sdk/core'; import { BrowserOperatorOptions, SearchEngine } from './types'; /** * BrowserOperator class that extends the base Operator * Provides functionality to control a browser instance for UI automation */ export declare class BrowserOperator extends Operator { private options; private browser; private currentPage; private logger; private uiHelper; private highlightClickableElements; private showActionInfo; private showWaterFlowEffect; private deviceScaleFactor?; /** * Creates a new BrowserOperator instance * @param options Configuration options for the browser operator */ constructor(options: BrowserOperatorOptions); /** * Gets the currently active browser page * @returns Promise resolving to the active Page object * @throws Error if no active page is found */ private getActivePage; setHighlightClickableElements(enable: boolean): void; /** * Sets whether to show the water flow effect during screenshots * @param enable Whether to enable the water flow effect */ setShowWaterFlow(enable: boolean): void; /** * Takes a screenshot of the current browser viewport * @returns Promise resolving to screenshot data */ screenshot(): Promise<ScreenshotOutput>; /** * Executes a specified action based on the parsed prediction * @param params Parameters containing action details * @returns Promise resolving to execution output */ execute(params: ExecuteParams): Promise<ExecuteOutput>; private handleClick; private handleDoubleClick; private handleRightClick; private handleType; private handleHotkey; private handlePress; private handleRelease; private handleScroll; private delay; private handleNavigate; private handleDrag; private handleNavigateBack; /** * A helper function to wait for possible navigation to complete. * @param page */ private waitForPossibleNavigation; private getDeviceScaleFactor; cleanup(): Promise<void>; } export declare class DefaultBrowserOperator extends BrowserOperator { private static instance; private static browser; private static browserPath; private static browserType; private static logger; private constructor(); /** * Check whether the local environment has a browser available * @returns {boolean} */ static hasBrowser(browser?: BrowserType): boolean; static getInstance(highlight?: boolean, showActionInfo?: boolean, showWaterFlow?: boolean, isCallUser?: boolean, searchEngine?: SearchEngine): Promise<DefaultBrowserOperator>; static destroyInstance(): Promise<void>; } export declare class RemoteBrowserOperator extends BrowserOperator { private static instance; private static browser; private static browserType; private static logger; private constructor(); static getInstance(wsEndpoint: string, highlight?: boolean, showActionInfo?: boolean, showWaterFlow?: boolean, isCallUser?: boolean): Promise<DefaultBrowserOperator>; static destroyInstance(): Promise<void>; } //# sourceMappingURL=browser-operator.d.ts.map