export type AgentBrowserState = | 'closed' | 'opening' | 'attaching' | 'attached' | 'suspended_devtools' | 'detached_fault' | 'crashed' | 'closing'; export interface AgentBrowserBounds { x: number; y: number; width: number; height: number; } export interface AgentBrowserPayloadRef { kind: 'payload'; handle: string; byteLength: number; contentType: 'application/json' | 'text/plain' | 'application/octet-stream'; expiresAt: string; } export interface AgentBrowserSnapshot { browserId: string | null; projectId: string | null; projectPath: string | null; state: AgentBrowserState; generation: number; url: string; title: string; visible: boolean; bounds: AgentBrowserBounds | null; canGoBack: boolean; canGoForward: boolean; eventCursor: number; error?: { code: AgentBrowserErrorCode; message: string; }; } export interface AgentBrowserCdpEvent { sequence: number; generation: number; timestamp: number; method: string; params?: unknown; payload?: AgentBrowserPayloadRef; sessionRef?: string; } export interface AgentBrowserCdpEventPage { events: AgentBrowserCdpEvent[]; nextCursor: number; hasMore: boolean; gap?: { reason: 'evicted' | 'debugger-detached' | 'view-recreated'; oldestAvailable: number; }; } export type AgentBrowserCdpResult = | { kind: 'inline'; value: unknown } | AgentBrowserPayloadRef; export interface AgentBrowserPayloadChunk { handle: string; offset: number; nextOffset: number; byteLength: number; contentType: AgentBrowserPayloadRef['contentType']; data: string; encoding: 'utf8' | 'base64'; done: boolean; } export type AgentBrowserErrorCode = | 'PROJECT_NOT_ACTIVE' | 'PROJECT_MISMATCH' | 'BROWSER_NOT_OPEN' | 'VIEWPORT_NOT_READY' | 'DEBUGGER_BUSY' | 'ATTACH_FAILED' | 'DEVTOOLS_CONFLICT' | 'CDP_METHOD_BLOCKED' | 'TARGET_DENIED' | 'CDP_TIMEOUT' | 'CDP_PROTOCOL_ERROR' | 'CURSOR_EXPIRED' | 'PAYLOAD_NOT_FOUND' | 'PAYLOAD_TOO_LARGE' | 'TARGET_GONE' | 'RENDERER_CRASHED' | 'INVALID_URL' | 'INVALID_REQUEST' | 'CLOSED'; export interface AgentBrowserFaultShape { code: AgentBrowserErrorCode; message: string; retryable: boolean; generation?: number; outcome?: 'unknown'; }