vibe-tools
Version:
CLI tools for AI agents
84 lines (83 loc) • 3.25 kB
TypeScript
import type { SharedBrowserCommandOptions } from './browserOptions';
import type { Page } from 'playwright';
/**
* Formats a console message with location and stack trace information.
*
* @param msg - The console message object from Playwright
* @returns A formatted string containing the message type, text, location, and stack trace (for errors)
*
* @example
* ```typescript
* page.on('console', async (msg) => {
* const formatted = await formatConsoleMessage(msg);
* console.log(formatted);
* });
* ```
*/
export declare function formatConsoleMessage(msg: any): Promise<string>;
/**
* Sets up console message logging for a Playwright page.
*
* @param page - The Playwright Page instance to monitor
* @param options - Browser command options containing console logging preferences
* @returns An array of captured console messages
* @throws {Error} If the page instance is not valid
*
* @example
* ```typescript
* const messages = await setupConsoleLogging(page, { console: true });
* ```
*/
export declare function setupConsoleLogging(page: Page, options: SharedBrowserCommandOptions): Promise<string[]>;
/**
* Sets up network request/response monitoring for a Playwright page.
*
* @param page - The Playwright Page instance to monitor
* @param options - Browser command options containing network monitoring preferences
* @returns An array of captured network messages
* @throws {Error} If the page instance is not valid or if route interception fails
*
* @example
* ```typescript
* const messages = await setupNetworkMonitoring(page, { network: true });
* ```
*/
export declare function setupNetworkMonitoring(page: Page, options: SharedBrowserCommandOptions): Promise<string[]>;
/**
* Takes a screenshot of the current page state.
*
* @param page - The Playwright Page instance to screenshot
* @param options - Browser command options containing screenshot preferences
* @throws {Error} If the page instance is not valid or if screenshot capture fails
*
* @example
* ```typescript
* await captureScreenshot(page, { screenshot: 'output.png' });
* ```
*/
export declare function captureScreenshot(page: Page, options: SharedBrowserCommandOptions): Promise<void>;
/**
* Formats console and network messages for output.
*
* @param consoleMessages - Array of captured console messages
* @param networkMessages - Array of captured network messages
* @param options - Browser command options containing output preferences
* @returns An array of formatted message strings ready for output
*
* @example
* ```typescript
* const messages = outputMessages(consoleMessages, networkMessages, { console: true, network: true });
* for (const msg of messages) {
* console.log(msg);
* }
* ```
*/
export declare function outputMessages(consoleMessages: string[], networkMessages: string[], options: SharedBrowserCommandOptions): string[];
/**
* Sets up video recording directory for Playwright
*/
export declare function setupVideoRecording(options: SharedBrowserCommandOptions): Promise<string | undefined>;
/**
* Gets the path of the recorded video and returns a message
*/
export declare function stopVideoRecording(page: Page, videoDir: string | null): Promise<string | undefined>;