@ejazullah/smart-browser-automation
Version:
A smart AI-driven browser automation library and REST API server using MCP (Model Context Protocol) and LangChain for multi-step task execution. Includes both programmatic library usage and HTTP API server for remote automation.
123 lines (109 loc) • 2.83 kB
TypeScript
/**
* Configuration interface for SmartBrowserAutomation
*/
export interface SmartBrowserAutomationConfig {
maxSteps?: number;
temperature?: number;
transportType?: 'streamable' | 'sse';
}
/**
* LLM Configuration interface
*/
export interface LLMConfig {
apiKey: string;
model: string;
baseURL: string;
}
/**
* Task execution options
*/
export interface TaskExecutionOptions {
verbose?: boolean;
systemPrompt?: string;
onProgress?: (update: ProgressUpdate) => void;
}
/**
* Progress update interface
*/
export interface ProgressUpdate {
type: 'fetching_tools' | 'tools_fetched' | 'task_execution_started' | 'step_started' | 'llm_thinking' | 'tool_call' | 'tool_result' | 'tool_error' | 'step_completed' | 'task_completed' | 'max_steps_reached';
step?: number;
message: string;
toolCount?: number;
task?: string;
maxSteps?: number;
toolName?: string;
toolArgs?: any;
success?: boolean;
error?: string;
response?: string;
}
/**
* Tool execution result
*/
export interface ToolResult {
step: number;
tool?: string;
arguments?: any;
result: any;
isError?: boolean;
type?: 'completion';
response?: string;
}
/**
* Task execution result
*/
export interface TaskExecutionResult {
success: boolean;
steps: number;
results: ToolResult[];
completed: boolean;
}
/**
* Smart Browser Automation class for AI-driven multi-step browser tasks
*/
export declare class SmartBrowserAutomation {
config: SmartBrowserAutomationConfig;
mcpClient: any;
llm: any;
transport: any;
constructor(config?: SmartBrowserAutomationConfig);
/**
* Initialize the automation system
* @param llmConfig - LLM configuration (Hugging Face, Ollama, etc.)
* @param mcpEndpoint - MCP server endpoint
* @param driverUrl - WebDriver URL (optional for SSE transport)
*/
initialize(llmConfig: LLMConfig, mcpEndpoint: string, driverUrl?: string): Promise<void>;
/**
* Fetch available tools from MCP server
*/
fetchTools(): Promise<any>;
/**
* Execute a single tool directly without LLM
* @param toolName - Name of the tool to execute
* @param toolArgs - Arguments for the tool
* @param options - Additional options
*/
callTool(toolName: string, toolArgs?: any, options?: { verbose?: boolean }): Promise<{
success: boolean;
toolName: string;
arguments: any;
result?: any;
error?: string;
}>;
/**
* Convert JSON Schema to Zod schema
*/
jsonSchemaToZod(jsonSchema: any): any;
/**
* Execute a smart browser automation task
* @param taskDescription - The task to execute
* @param options - Additional options
*/
executeTask(taskDescription: string, options?: TaskExecutionOptions): Promise<TaskExecutionResult>;
/**
* Close the automation system
*/
close(): Promise<void>;
}