donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
61 lines • 2.8 kB
TypeScript
import type { BrowserContext } from 'playwright';
import type { WebTarget } from '../models/FocusedTarget';
import type { InteractableElement } from '../models/InteractableElement';
import type { FlowsPersistence } from '../persistence/flows/FlowsPersistence';
import type { InteractionVisualizer } from './InteractionVisualizer';
import { PageInspector } from './PageInspector';
import type { PlatformPromptInfo, TargetInitCallbacks, TargetInspectorBase } from './TargetInspector';
/**
* Web implementation of {@link TargetInspectorBase}.
*
* Wraps the existing {@link PageInspector} (which operates on Playwright
* {@link Page} objects) behind the target-agnostic interface. Holds a
* reference to the mutable {@link WebTarget} so the same inspector instance
* tracks page/tab switches automatically.
*
* Also owns the {@link BrowserContext} and {@link InteractionVisualizer}
* so that all web-specific lifecycle (initialization, cursor, session
* persistence) is encapsulated here rather than in the flow engine.
*
* The underlying {@link pageInspector} is exposed publicly so that
* web-specific code (e.g. {@link ReplayableInteraction}) can still call
* Page-specific helpers like `getHtmlSnippet`.
*/
export declare class WebTargetInspector implements TargetInspectorBase {
private readonly _target;
private readonly _browserContext;
private readonly _interactionVisualizer;
readonly type: "web";
readonly pageInspector: PageInspector;
private static readonly PROMPT_INFO;
constructor(_target: WebTarget, _browserContext: BrowserContext, _interactionVisualizer: InteractionVisualizer);
get target(): WebTarget;
get connected(): boolean;
get interactableElementAttribute(): string;
private requirePage;
attributeInteractableElements(): Promise<void>;
getAttributedInteractableElements(): Promise<InteractableElement[]>;
annotateInteractableElements(): Promise<void>;
removeAnnotations(): Promise<void>;
takeCleanScreenshot(): Promise<Buffer>;
takeAnnotatedScreenshot(): Promise<Buffer>;
captureScreenshot(): Promise<Buffer>;
checkConnectedOrThrow(): void;
checkTargetAliveOrThrow(): void;
isTargetClosedError(error: unknown): boolean;
handleTargetClosed(): Promise<{
recovered: true;
} | {
recovered: false;
reason: string;
}>;
showInteractionCursor(): Promise<void>;
hideInteractionCursor(): Promise<void>;
getCurrentLocation(): string;
getPlatformPromptInfo(): PlatformPromptInfo;
getContextDescription(): string;
initialize(callbacks: TargetInitCallbacks): Promise<void>;
persistSessionState(persistence: FlowsPersistence, flowId: string): Promise<void>;
private handleNewPage;
}
//# sourceMappingURL=WebTargetInspector.d.ts.map