import type { BrowserSetAnnotationViewportBridgeArgs } from '../../shared/browser-annotation-viewport-bridge' import type { BrowserClientPageMetadataParams, BrowserClientPageMetadataPublishOutcome } from '../../shared/browser-client-page-metadata-protocol' import type { BrowserWebAuthnAccountRequest, BrowserWebAuthnAccountResponse } from '../../shared/browser-webauthn-account' import type { BrowserSetGrabModeArgs, BrowserSetGrabModeResult, BrowserAwaitGrabSelectionArgs, BrowserGrabResult, BrowserCancelGrabArgs, BrowserCaptureSelectionScreenshotArgs, BrowserCaptureSelectionScreenshotResult, BrowserExtractHoverArgs, BrowserExtractHoverResult } from '../../shared/browser-grab-types' import type { BrowserContextMenuDismissedEvent, BrowserContextMenuRequestedEvent, BrowserDownloadFinishedEvent, BrowserDownloadProgressEvent, BrowserDownloadRequestedEvent, BrowserPermissionDeniedEvent, BrowserPopupEvent } from '../../shared/browser-guest-events' import type { BrowserCertificateFailure, BrowserCertificateProceedResult, BrowserCookieImportResult, BrowserLoadError, BrowserSessionProfile, BrowserSessionProfileCreateOptions, BrowserSessionProfileScope, BrowserSessionProfileSource, BrowserViewportOverride, BrowserViewportScrollState } from '../../shared/browser-workspace-types' import type { BrowserClientPageRendererOutcome, BrowserClientPageRendererRequest } from '../../shared/browser-client-page-renderer-protocol' export type BrowserApi = { /** Absent wherever this client hosts no guests of its own, which is how the web client reads. */ readClientHostId?: () => string | null onClientPageRendererRequest?: ( callback: ( request: BrowserClientPageRendererRequest ) => BrowserClientPageRendererOutcome | Promise ) => () => void registerGuest: (args: { browserPageId: string workspaceId: string worktreeId: string sessionProfileId?: string | null webContentsId: number }) => Promise isGuestRegistered: (args: { browserPageId: string; webContentsId: number }) => Promise repairGuestRegistration: (args: { browserPageId: string workspaceId: string worktreeId: string sessionProfileId?: string | null webContentsId: number }) => Promise unregisterGuest: (args: { browserPageId: string }) => Promise onWebAuthnAccountRequest: ( callback: (request: BrowserWebAuthnAccountRequest) => void ) => () => void onWebAuthnAccountRequestClosed: (callback: (event: { requestId: string }) => void) => () => void respondWebAuthnAccount: (response: BrowserWebAuthnAccountResponse) => Promise openDevTools: (args: { browserPageId: string }) => Promise setViewportOverride: (args: { browserPageId: string override: BrowserViewportOverride | null }) => Promise reportViewportScrollState?: (args: { browserPageId: string state: BrowserViewportScrollState }) => void setAnnotationViewportBridge: (args: BrowserSetAnnotationViewportBridgeArgs) => Promise /** Publishes a client-hosted page's url/title to its runtime over that runtime's host lease. */ publishClientPageMetadata: (args: { environmentId: string params: BrowserClientPageMetadataParams }) => Promise onGuestLoadFailed: ( callback: (args: { browserPageId: string; loadError: BrowserLoadError }) => void ) => () => void onCertificateFailureChanged: ( callback: (event: { browserPageId: string; failure: BrowserCertificateFailure | null }) => void ) => () => void proceedCertificate: (args: { browserPageId: string challengeId: string }) => Promise onPermissionDenied: (callback: (event: BrowserPermissionDeniedEvent) => void) => () => void onPopup: (callback: (event: BrowserPopupEvent) => void) => () => void onDownloadRequested: (callback: (event: BrowserDownloadRequestedEvent) => void) => () => void onDownloadProgress: (callback: (event: BrowserDownloadProgressEvent) => void) => () => void onDownloadFinished: (callback: (event: BrowserDownloadFinishedEvent) => void) => () => void onContextMenuRequested: ( callback: (event: BrowserContextMenuRequestedEvent) => void ) => () => void onContextMenuDismissed: ( callback: (event: BrowserContextMenuDismissedEvent) => void ) => () => void onNavigationUpdate: ( callback: (event: { browserPageId: string; url: string; title: string }) => void ) => () => void onActivateView: ( callback: (data: { worktreeId?: string; browserPageId?: string }) => void ) => () => void onPaneFocus: ( callback: (data: { worktreeId: string | null; browserPageId: string }) => void ) => () => void onOpenLinkInOrcaTab: ( callback: (event: { browserPageId: string; url: string; activate?: boolean }) => void ) => () => void cancelDownload: (args: { downloadId: string }) => Promise setGrabMode: (args: BrowserSetGrabModeArgs) => Promise awaitGrabSelection: (args: BrowserAwaitGrabSelectionArgs) => Promise cancelGrab: (args: BrowserCancelGrabArgs) => Promise captureSelectionScreenshot: ( args: BrowserCaptureSelectionScreenshotArgs ) => Promise extractHoverPayload: (args: BrowserExtractHoverArgs) => Promise onGrabModeToggle: (callback: (browserPageId: string) => void) => () => void onGrabActionShortcut: ( callback: (args: { browserPageId: string; key: 'c' | 's' }) => void ) => () => void sessionListProfiles: () => Promise /** Resolves once the SSH workspace's partition is bound and proxy-verified; the webview must wait for it. */ prepareSshWorkspacePartition: (args: { targetId: string browserProfileId?: string skipProbe?: boolean }) => Promise<{ partition: string }> sessionCreateProfile: ( args: { scope: BrowserSessionProfileScope label: string } & BrowserSessionProfileCreateOptions ) => Promise sessionDeleteProfile: (args: { profileId: string }) => Promise sessionImportCookies: (args: { profileId: string }) => Promise sessionResolvePartition: (args: { profileId: string | null }) => Promise sessionDetectBrowsers: () => Promise /** Null when the environment's pages are not client-hosted on this desktop. */ sessionDetectBrowsersForClientHost: (args: { environmentId: string }) => Promise sessionImportFromBrowser: (args: { profileId: string browserFamily: string browserProfile?: string }) => Promise /** Null when the environment's pages are not client-hosted on this desktop. */ sessionImportFromBrowserForClientHost: (args: { environmentId: string profileId: string browserFamily: string browserProfile?: string }) => Promise /** Import-source badges for one environment's client-hosted jars, keyed by profile id. */ sessionClientRouteImportSources: (args: { environmentId: string }) => Promise> sessionClearDefaultCookies: () => Promise notifyActiveTabChanged: (args: { browserPageId: string }) => Promise } export type DetectedBrowserProfileInfo = { name: string directory: string } export type DetectedBrowserInfo = { family: BrowserSessionProfileSource['browserFamily'] label: string profiles: DetectedBrowserProfileInfo[] selectedProfile: string }