import type { CdpProtocolClient } from "../core/cdp/protocol.js"; import { RefTable } from "./refs.js"; import { type SnapshotDiff, type SnapshotOptions, type SnapshotResult } from "./snapshot.js"; import { type ActionStep } from "./actions.js"; import { type ExtractOptions, type ExtractResult, type ScreenshotOptions, type ScreenshotResult } from "./read.js"; import { type DialogPolicy, type ObservationSnapshot } from "./observe.js"; import { type WaitCondition, type WaitResult } from "./wait.js"; import { type SessionPolicyOptions, type SessionState } from "./policy.js"; export interface TabHandle { tabId: string; targetId: string; cdpSessionId: string; url: string; refs: RefTable; lastSnapshot?: string; lastScreenshotHash?: string; } export interface AgentSessionOptions { /** Isolate each tab in its own browser context. Default true. */ isolateTabs?: boolean; navigationTimeoutMs?: number; /** Per-CDP-command ceiling. A stalled upstream must never wedge a session. */ commandTimeoutMs?: number; /** How javascript dialogs are answered so a prompt can never freeze the page. */ dialogPolicy?: DialogPolicy; observationLimit?: number; /** Capture the page's own console.* calls. Off by default: it needs * `Runtime.enable`, which bot detectors look for. */ pageConsole?: boolean; policy?: SessionPolicyOptions; } export interface ActOptions { tabId?: string; stopOnError?: boolean; settleMs?: number; actionabilityTimeoutMs?: number; snapshot?: SnapshotOptions; } export interface ActResult { ok: boolean; stepsRun: number; failedStep?: { index: number; step: ActionStep; error: string; }; changed: SnapshotDiff; url: string; session: SessionState; warning?: string; } export interface NavigateResult { tabId: string; url: string; title: string; snapshot: SnapshotResult; session: SessionState; warning?: string; } /** One agent session bound to a browser-level CDP connection. Owns its tabs and * their element reference tables; nothing is shared between sessions. */ export declare class AgentSession { private readonly cdp; private readonly opts; private readonly tabs; private activeTabId; private nextTabNumber; private closed; private readonly observations; private readonly policy; private expiredReason; private listenersAttached; constructor(cdp: CdpProtocolClient, opts?: AgentSessionOptions); get state(): SessionState; get expired(): "idle" | "hard-cap" | null; get tabIds(): string[]; get activeTab(): TabHandle | null; openTab(url?: string): Promise; navigate(url: string, tabId?: string): Promise; /** Runs steps in order against one tab, waits for the page to settle, and * returns only what changed. Stops at the first failing step by default. */ act(steps: ActionStep[], opts?: ActOptions): Promise; snapshot(opts?: SnapshotOptions, tabId?: string): Promise; /** Page content as text, markdown or a link list. */ extract(opts?: ExtractOptions, tabId?: string): Promise; /** JPEG screenshot. With `skipIfUnchanged` an identical image is reported, not resent. */ screenshot(opts?: ScreenshotOptions, tabId?: string): Promise; waitFor(condition: WaitCondition, tabId?: string): Promise; /** Runs an expression in the page and returns its value. */ evaluate(expression: string, tabId?: string): Promise; /** Console output, failed requests, downloads, dialogs and popup tabs seen so far. */ observed(afterMs?: number): ObservationSnapshot; setDialogPolicy(policy: DialogPolicy): void; closeTab(tabId: string): Promise; selectTab(tabId: string): TabHandle; /** Closes this session's tabs. Never closes the upstream browser: it may be * shared with other sessions and other clients. */ close(): Promise; private requireTab; private sendKeepalive; private expire; private attachObservers; private sender; private settle; private send; private assertOpen; private waitForLoad; private currentUrl; private currentTitle; } //# sourceMappingURL=session.d.ts.map