@grasplabs/grasp
Version:
TypeScript SDK for browser automation and secure command execution in highly available and scalable cloud browser environments
79 lines • 2.39 kB
TypeScript
import { SandboxService } from './sandbox.service';
import { IBrowserConfig, ISandboxConfig } from '../types';
/**
* CDP connection information
*/
export interface ICDPConnection {
id: string;
/** CDP WebSocket URL */
wsUrl: string;
/** CDP HTTP endpoint */
httpUrl: string;
/** CDP port */
port: number;
}
/**
* Browser service for managing Chromium browser with CDP access
* Uses Grasp sandbox to run browser and expose CDP endpoint
*/
export declare class BrowserService {
private sandboxService;
private config;
private logger;
private cdpConnection;
private browserProcess;
/**
* Gets or creates a default logger instance
* @returns Logger instance
*/
private getDefaultLogger;
constructor(sandboxConfig: ISandboxConfig, browserConfig?: Partial<IBrowserConfig>);
/**
* Initialize the Grasp sandbox
* @returns Promise that resolves when sandbox is ready
*/
initialize(type: 'chromium' | 'chrome-stable'): Promise<void>;
connect(sandboxId: string): Promise<ICDPConnection>;
/**
* Launch Chromium browser with CDP server
* @returns Promise with CDP connection information
* @throws {Error} If browser launch fails
*/
launchBrowser(): Promise<ICDPConnection>;
/**
* Set up event listeners for browser process
*/
private setupBrowserProcessListeners;
/**
* Wait for CDP server to be ready
* @returns Promise that resolves when CDP is available
*/
private waitForCDPReady;
/**
* Get current CDP connection information
* @returns CDP connection info or null if not connected
*/
getCDPConnection(): ICDPConnection | null;
/**
* Check if browser is running
* @returns True if browser process is active
*/
isBrowserRunning(): boolean;
/**
* Stop the browser and cleanup resources
* @returns Promise that resolves when cleanup is complete
*/
stopBrowser(): Promise<void>;
/**
* Cleanup all resources including Grasp sandbox
* @returns Promise that resolves when cleanup is complete
*/
cleanup(): Promise<void>;
get id(): string | undefined;
/**
* Get the underlying Grasp service instance
* @returns Grasp service instance
*/
getSandbox(): SandboxService;
}
//# sourceMappingURL=browser.service.d.ts.map