UNPKG

browser-use-typescript

Version:

A TypeScript-based browser automation framework

192 lines (191 loc) 6.27 kB
import { BaseChatModel } from "@langchain/core/language_models/chat_models"; import { BrowserStateHistory } from "../browser/playwrightBrowser/type"; import { ActionModel } from "../controller/registry/types"; import { DOMHistoryElement } from "../domHIstory/historyTypes"; import { SelectorMap } from "../domTypes/domClass"; import { MessageManagerState } from "./message_manager/types"; type ToolCallingMethod = 'function_calling' | 'json_mode' | 'raw' | 'auto'; declare class AgentSettings { use_vision: boolean; use_vision_for_planner: boolean; save_conversation_path: string | undefined; save_conversation_path_encoding: string | undefined; max_failures: number; retry_delay: number; max_input_tokens: number; validate_output: boolean; message_context: string | undefined; generate_gif: boolean | string; available_file_paths: string[] | undefined; override_system_message: string | undefined; extend_system_message: string | undefined; include_attributes: string[]; max_actions_per_step: number; tool_calling_method: ToolCallingMethod | undefined; page_extraction_llm: BaseChatModel | undefined; planner_llm: BaseChatModel | undefined; planner_interval: number; constructor(params: any); } declare class AgentState { agent_id: string; n_steps: number; consecutive_failures: number; last_result?: ActionResult[] | null; history: AgentHistoryList; last_plan: string | null; paused: boolean; stopped: boolean; message_manager_state: MessageManagerState; } declare class AgentStepInfo { step_number: number; max_steps: number; constructor(step_number: number, max_steps: number); is_last_step(): boolean; } declare class ActionResult { isDone: boolean; success: boolean | null; extractedContent: string | null; error?: string | null; includeInMemory?: boolean; constructor(params: Partial<ActionResult>); toJSON(): any; } declare class StepMetadata { step_start_time: number; step_end_time: number; input_tokens: number; step_number: number; constructor(step_start_time: number, step_end_time: number, input_tokens: number, step_number: number); get duration_seconds(): number; toJSON(): { step_start_time: number; step_end_time: number; input_tokens: number; step_number: number; }; } declare class AgentBrain { evaluation_previous_goal: string; memory: string; next_goal: string; constructor(fields: { evaluation_previous_goal: string; memory: string; next_goal: string; }); } declare class AgentOutput { action: ActionModel[]; current_state: AgentBrain; constructor(fields: { action?: ActionModel[]; current_state?: AgentBrain; }); /** * Generate a complete JSON schema for the AgentOutput * This matches the structure created by Pydantic's model_json_schema() in Python */ toJson(): { $defs: Record<string, any>; properties: { current_state: { $ref: string; }; action: { type: string; items: { $ref: string; }; minItems: number; title: string; description: string; }; }; required: string[]; title: string; type: string; description: string; } | { $defs?: undefined; properties?: undefined; required?: undefined; title?: undefined; type?: undefined; description?: undefined; }; } declare class AgentHistory { model_output: AgentOutput | null; result: ActionResult[]; state: BrowserStateHistory; metadata: StepMetadata | null; constructor(model_output: (AgentOutput | null) | undefined, result: ActionResult[] | undefined, state: BrowserStateHistory, metadata?: StepMetadata | null); static getInteractedElement(model_output: AgentOutput, selector_map: SelectorMap): Promise<(DOMHistoryElement | null)[]>; toJSON(): { model_output: Record<string, any> | null; result: any[]; state: any; metadata: { step_start_time: number; step_end_time: number; input_tokens: number; step_number: number; } | null; }; } declare class AgentHistoryList { history: AgentHistory[]; constructor(history?: AgentHistory[]); totalDurationSeconds(): number; totalInputTokens(): number; inputTokenUsage(): number[]; toString(): string; saveToFile(filepath: string): void; toJSON(): { history: { model_output: Record<string, any> | null; result: any[]; state: any; metadata: { step_start_time: number; step_end_time: number; input_tokens: number; step_number: number; } | null; }[]; }; static loadFromFile(filepath: string): AgentHistoryList; lastAction(): any; errors(): (string | null)[]; finalResult(): string | null; isDone(): boolean; isSuccessful(): boolean | null; hasErrors(): boolean; urls(): (string | null)[]; screenshots(): (string | null)[]; actionNames(): string[]; modelThoughts(): AgentBrain[]; modelOutputs(): AgentOutput[]; modelActions(): any[]; actionResults(): ActionResult[]; extractedContent(): string[]; modelActionsFiltered(include?: string[]): any[]; numberOfSteps(): number; } declare class ValidationError extends Error { constructor(message: string); } declare class RateLimitError extends Error { constructor(message: string); } declare class AgentError { static VALIDATION_ERROR: string; static RATE_LIMIT_ERROR: string; static NO_VALID_ACTION: string; static formatError(error: Error, includeTrace?: boolean): string; } export { AgentSettings, AgentState, AgentStepInfo, ActionResult, StepMetadata, AgentBrain, AgentOutput, AgentHistory, AgentHistoryList, AgentError, ValidationError, RateLimitError, MessageManagerState, }; export type { ToolCallingMethod };