/** * Wait Tool - a first-class wait primitive for sequences (bug-016) * * Four mutually exclusive forms: * wait({ selector }) - until an element matching the selector exists * wait({ selectorGone }) - until NO element matches the selector * wait({ expression }) - until a synchronous JS expression is truthy * wait({ ms }) - fixed sleep (last resort) * * All condition forms poll from the MCP side: the predicate is a SYNCHRONOUS * expression re-evaluated over CDP on an interval. This is deliberate - it is * NOT an in-page waitForFunction/waitForSelector: * * - It survives a navigation mid-wait. Each poll runs in whatever execution * context the page currently has; if the context is destroyed between * polls (navigation), the failed poll is swallowed and the next one runs * in the new document. This is exactly the "step after navigate races the * new page" case that motivated the tool. * - It does not depend on the page's event loop making progress or on any * in-page promise ever resolving, so it still behaves sanely when the page * is busy - and it fails fast instead of burning the timeout when the * debugger is paused (nothing can change while the event loop is stopped). */ import { z } from 'zod'; /** * Build a self-contained synchronous in-page expression that evaluates to * true when an element matching `selector` exists. Extended selectors * (:has-text etc.) are compiled to an inline text-match - no element marking, * so nothing is lost when the document is replaced between polls. */ export declare function buildPresencePredicate(selector: string): string | { error: string; }; export declare function createWaitTools(resolveConnectionFromReason: (connectionReason: string) => Promise<{ connection: { port: number; }; cdpManager: any; puppeteerManager: any; } | null>): { wait: { description: string; zodSchema: z.ZodObject<{ selector: z.ZodOptional; selectorGone: z.ZodOptional; expression: z.ZodOptional; ms: z.ZodOptional; timeoutMs: z.ZodOptional; pollIntervalMs: z.ZodOptional; connectionReason: z.ZodOptional; }, "strict", z.ZodTypeAny, { timeoutMs?: number | undefined; expression?: string | undefined; selector?: string | undefined; selectorGone?: string | undefined; ms?: number | undefined; connectionReason?: string | undefined; pollIntervalMs?: number | undefined; }, { timeoutMs?: number | undefined; expression?: string | undefined; selector?: string | undefined; selectorGone?: string | undefined; ms?: number | undefined; connectionReason?: string | undefined; pollIntervalMs?: number | undefined; }>; inputSchema: import("zod-to-json-schema").JsonSchema7Type & { $schema?: string | undefined; definitions?: { [key: string]: import("zod-to-json-schema").JsonSchema7Type; } | undefined; }; handler: (args: { timeoutMs?: number | undefined; expression?: string | undefined; selector?: string | undefined; selectorGone?: string | undefined; ms?: number | undefined; connectionReason?: string | undefined; pollIntervalMs?: number | undefined; }, abortSignal?: AbortSignal) => Promise; }; }; //# sourceMappingURL=wait-tools.d.ts.map