/** * Agent service for browser-use TypeScript * * Main agent orchestrating browser automation using LLM guidance. * This is a simplified initial implementation focusing on core functionality. */ import { EventEmitter } from 'events'; import { AgentHistoryList, AgentHistoryListHelper, AgentOutput, AgentSettings, AgentState, AgentStepInfo } from './views'; import { MessageManager, type SensitiveData } from './messageManager/index'; import { BaseChatModel } from '../llm/base'; import { BrowserSession } from '../browser/session'; import { ScreenshotService } from '../screenshots'; import { FileSystem } from '../filesystem'; import { TokenCost } from '../tokens'; export type Context = any; export type AgentStructuredOutput = any; /** * Agent hook function type */ export type AgentHookFunc = Agent> = (agent: T) => Promise; /** * Main Agent class for browser automation */ export declare class Agent extends EventEmitter { readonly sessionId: string; readonly taskId: string; task: string; llm: BaseChatModel; settings: AgentSettings; state: AgentState; browserSession?: BrowserSession; messageManager: MessageManager; screenshotService?: ScreenshotService; fileSystem?: FileSystem; tokenCost: TokenCost; context?: TContext; sensitiveData?: SensitiveData; private history; private stepStartTime; private sessionStartTime; private taskStartTime; constructor(options: { task: string; llm: BaseChatModel; settings?: Partial; state?: AgentState; browserSession?: BrowserSession; context?: TContext; sensitiveData?: SensitiveData; agentDirectory?: string; }); /** * Get instance-specific logger with task ID and session info */ get logger(): import("winston").Logger; /** * Create the system message for the agent */ private createSystemMessage; /** * Execute the task with maximum number of steps */ run(maxSteps?: number, onStepStart?: AgentHookFunc, onStepEnd?: AgentHookFunc): Promise; /** * Execute one step of the task */ step(stepInfo?: AgentStepInfo): Promise; /** * Prepare the context for the step */ private prepareContext; /** * Get the next action from the LLM */ private getNextAction; /** * Execute the actions from the model output */ private executeActions; /** * Post-process after action execution */ private postProcess; /** * Handle step errors */ private handleStepError; /** * Finalize the step */ private finalizeStep; /** * Check if the agent is done */ isDone(): boolean; /** * Check if the agent was successful */ isSuccessful(): boolean | null; /** * Pause the agent */ pause(): void; /** * Resume the agent */ resume(): void; /** * Stop the agent */ stop(): void; /** * Get the current history list */ getHistory(): Promise; /** * Add a new task (updates the current task) */ addNewTask(newTask: string): void; } /** * Log the model's response (utility function) */ export declare function logResponse(response: AgentOutput, logger: any): void; //# sourceMappingURL=service.d.ts.map