/** * analyze-page.ts * * Implements the pwpilot_analyze_page MCP tool. * * This tool runs after the browser has been launched and a URL has been loaded. * It waits for the page to reach a stable network state, then uses DOMAnalyzer * to extract all interactive elements (forms, navigation links, tables, popups, * buttons, inputs) from the live DOM — entirely locally with zero AI token usage. * * The resulting PageAnalysis is returned to the caller and also stored in the * MCP server's in-memory state so that the subsequent pwpilot_generate_test * call can use it without re-analyzing. * * Role in the overall flow: * pwpilot_launch_browser → pwpilot_analyze_page → pwpilot_generate_test */ import { BrowserManager } from '../../browser/browser-manager'; import { DOMAnalyzer } from '../../browser/dom-analyzer'; import { PageObserver } from '../../browser/page-observer'; import { PageAnalysis } from '../../types'; /** * The output returned by the analyze_page tool to the MCP server. */ export interface AnalyzePageOutput { /** Full structured analysis of the page, including all categorized elements. */ pageAnalysis: PageAnalysis; /** Compact numeric summary of what was found — shown to the user. */ summary: { url: string; title: string; totalElements: number; forms: number; navigation: number; tables: number; popups: number; }; } /** * Analyze the currently open browser page and return a structured page summary. * * Waits for network activity to settle first to ensure dynamic content is loaded * before element extraction begins. * * @param browserManager - Provides access to the active Playwright page. * @param domAnalyzer - Extracts and categorizes DOM elements from the page. * @param pageObserver - Waits for the page to reach a stable network state. * @returns An AnalyzePageOutput containing the full PageAnalysis and a compact summary. * @throws Error if the browser has not been launched yet (browserManager.getPage() throws). */ export declare function analyzePage(browserManager: BrowserManager, domAnalyzer: DOMAnalyzer, pageObserver: PageObserver): Promise; //# sourceMappingURL=analyze-page.d.ts.map