Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript
30.0 KB
Raw Blame
import type { DesktopCommandId, DesktopCommandSource } from './desktopCommands.js'
import type {
  PluginAuditEntryView,
  PluginConsentRequest,
  PluginGrantView,
} from './pluginSdkProtocol.js'
import {
  AccessCatalog,
  AgentWithMcpServers,
  ApprovalDecisionResult,
  ChatAuthorityScope,
  ChatDeleteFence,
  ChatDeleteResult,
  ChatIndex,
  ChatMessage,
  ChatMetadata,
  ContextBreakdownResult,
  DesktopAppInfo,
  DesktopReleaseStatus,
  DesktopRuntimeConfig,
  DesktopRuntimeConfigHandoffSelection,
  DesktopRuntimeConfigState,
  EntityChangeStreamEvent,
  ExternalChannelsSummary,
  HostActivitySnapshot,
  HostActivityStreamEvent,
  HostMessageRequest,
  HostMessageResponse,
  HostModelsResult,
  HostRuntimeStatus,
  HostStatusStreamEvent,
  LoginBackendHint,
  MessageToolStep,
  PasswordLoginResult,
  PendingWorkflowApproval,
  PrewarmHostResult,
  ProfileSettingsOpenOptions,
  ReplaceChatMessagesOptions,
  RpcAllowedServersResult,
  RpcConnectorsResult,
  SandboxUiApp,
  SandboxUiDeepLinkEnvelope,
  SandboxUiReleasedEvent,
  SessionLifecycleState,
  SessionMessagesQuery,
  SessionMessagesResult,
  SessionState,
  SessionsListQuery,
  SessionsListResult,
  SetHostModelResult,
  TaskProgressStreamEvent,
  TeamDirectoryResult,
  TeamMember,
  TeamSummary,
  TokenMetadata,
  WorkflowApprovalDecisionResult,
  WorkflowNotificationStreamEvent,
  WorkflowRecipeListResult,
  WorkflowRunArtifactsResult,
  WorkflowRunsResult,
} from './types.js'

declare global {
  interface Window {
    clerum: {
      shortcuts: {
        onCommand: (
          callback: (commandId: DesktopCommandId, source: DesktopCommandSource) => void
        ) => () => void
      }
      auth: {
        getSessionState: () => Promise<SessionState>
        getSessionGeneration: () => Promise<number>
        getDependenciesHealth: () => Promise<{
          externalRestApi: { ok: boolean; detail?: string }
          rpcProxy: { ok: boolean; detail?: string }
        }>
        getRuntimeConfigState: () => Promise<DesktopRuntimeConfigState>
        selectRuntimeConfig: (optionId: string) => Promise<DesktopRuntimeConfigState>
        selectRuntimeConfigForHandoff: (
          optionId: string,
          expectedSessionGeneration: number
        ) => Promise<DesktopRuntimeConfigHandoffSelection>
        clearRuntimeConfigSelection: () => Promise<DesktopRuntimeConfigState>
        saveRuntimeConfig: (
          config: DesktopRuntimeConfig,
          expectedSessionGeneration?: number
        ) => Promise<DesktopRuntimeConfigState>
        deleteRuntimeConfig: (optionId: string) => Promise<DesktopRuntimeConfigState>
        googleLogin: (idToken: string) => Promise<SessionState>
        passwordLogin: (email: string, password: string) => Promise<PasswordLoginResult>
        diagnoseLoginBackend: () => Promise<LoginBackendHint | null>
        probeLocalhostReachable: () => Promise<boolean>
        openDeploymentDocs: () => Promise<{ opened: true }>
        openHostedSignup: () => Promise<{ opened: true }>
        startDesktopSetup: (email: string) => Promise<{ profileUiUrl: string; appName: string }>
        openForgotPassword: (email?: string) => Promise<{ profileUiUrl: string }>
        openProfileSettings: (
          email?: string,
          options?: ProfileSettingsOpenOptions
        ) => Promise<{ profileUiUrl: string }>
        completeDesktopSetup: (
          email: string,
          authorizationToken: string
        ) => Promise<DesktopRuntimeConfigState>
        onDesktopSetupToken: (
          callback: (payload: { email: string; authorizationToken: string }) => void
        ) => () => void
        onDesktopEnvironmentSetup: (
          callback: (payload: { externalRestApiBaseUrl: string; appName?: string }) => void
        ) => () => void
        getDesktopReleaseStatus: () => Promise<DesktopReleaseStatus>
        getDesktopAppInfo: () => Promise<DesktopAppInfo>
        openDesktopRelease: (releaseUrl: string) => Promise<{ opened: true }>
        onExternalLogout: (callback: () => void) => () => void
        logout: () => Promise<{ ok: true; sessionGeneration: number }>
      }
      team: {
        list: () => Promise<{ currentTeamId: string; items: TeamSummary[] }>
        members: () => Promise<TeamMember[]>
        directory: () => Promise<TeamDirectoryResult>
        initialDirectory: () => Promise<TeamDirectoryResult>
        switch: (teamId: string) => Promise<SessionState>
      }
      gfs: {
        resolve: (uri: string) => Promise<{
          drive: string
          resourceId: string
          parentResourceId: string | null
          rid?: string
          gfsUri: string
          name: string
          kind: string
          pathCache: string | null
          path?: string | null
          version: number
          bytes?: number
          updatedAt?: string
        }>
        download: (
          uri: string,
          options?: { maxBytes?: number; signal?: AbortSignal }
        ) => Promise<{
          resource: {
            drive: string
            resourceId: string
            parentResourceId: string | null
            rid?: string
            gfsUri: string
            name: string
            kind: string
            pathCache: string | null
            path?: string | null
            version: number
            bytes?: number
            updatedAt?: string
          }
          bytes: ArrayBuffer
        }>
        downloadPreview: (
          uri: string,
          maxBytes: number
        ) => Promise<{
          resource: {
            drive: string
            resourceId: string
            parentResourceId: string | null
            rid?: string
            gfsUri: string
            name: string
            kind: string
            pathCache: string | null
            path?: string | null
            version: number
            bytes?: number
            updatedAt?: string
          }
          bytes: ArrayBuffer
        }>
        listAccessible: (
          drive?: string,
          cursor?: string
        ) => Promise<{
          items: Array<{
            resourceId: string
            rid: string
            gfsUri: string
            drive?: string
            parentResourceId?: string | null
            name: string
            kind: 'file' | 'directory'
            path: string | null
            version: number
            bytes: number
            updatedAt?: string
            sources?: string[]
            permissions?: string[]
            coversDescendants?: boolean
          }>
          nextCursor: string | null
          rootResourceId?: string
          view?: 'operator'
        }>
        listChildren: (
          resourceId: string,
          drive?: string,
          cursor?: string,
          options?: { signal?: AbortSignal }
        ) => Promise<{
          items: Array<{
            resourceId: string
            rid: string
            gfsUri: string
            drive: string
            parentResourceId: string | null
            name: string
            kind: 'file' | 'directory'
            path: string | null
            version: number
            bytes: number
            updatedAt?: string
          }>
          nextCursor: string | null
        }>
        affordances: (
          resourceId: string,
          drive?: string
        ) => Promise<{
          held: string[]
          canDelegate: boolean
          grantableBits: string[]
          canCreateShare: boolean
        }>
        zipStream: {
          start: () => Promise<{ jobId: string }>
          append: (jobId: string, name: string, bytes: ArrayBuffer) => Promise<{ name: string }>
          /**
           * Appends one entry by URI: the main process fetches the resource
           * and writes it into the archive chunk by chunk, so the payload
           * never crosses the IPC boundary (R1-H2).
           */
          appendFromUri: (
            jobId: string,
            name: string,
            uri: string,
            options?: { maxBytes?: number; signal?: AbortSignal }
          ) => Promise<{ name: string; bytes: number }>
          finish: (
            jobId: string,
            suggestedName: string
          ) => Promise<{ saved: boolean; filePath: string | null; entryCount: number }>
          abort: (jobId: string) => Promise<{ aborted: boolean }>
        }
        createFolder: (
          parentResourceId: string,
          name: string,
          drive?: string
        ) => Promise<{
          resourceId: string
          rid: string
          gfsUri: string
          drive: string
          parentResourceId: string | null
          name: string
          kind: 'file' | 'directory'
          path: string | null
          version: number
          bytes: number
        }>
        createFile: (
          parentResourceId: string,
          name: string,
          encodedData: string,
          drive?: string
        ) => Promise<{
          resourceId: string
          rid: string
          gfsUri: string
          drive: string
          parentResourceId: string | null
          name: string
          kind: 'file' | 'directory'
          path: string | null
          version: number
          bytes: number
        }>
        createFileFromPath: (
          parentResourceId: string,
          name: string,
          filePath: string,
          drive?: string
        ) => Promise<{
          uploadId: string
          state: string
          resultResourceId?: string
          resultVersion?: number
        }>
        startFileUpload: (
          parentResourceId: string,
          name: string,
          filePath: string,
          drive?: string,
          resumeUploadId?: string
        ) => Promise<{
          uploadId: string
          state: string
          expectedBytes: number
          committedBytes: number
          partBytes: number
          partCount: number
        }>
        startFileReplace: (
          resourceId: string,
          filePath: string,
          drive?: string,
          ifMatch?: number,
          resumeUploadId?: string
        ) => Promise<{
          uploadId: string
          state: string
          expectedBytes: number
          committedBytes: number
          partBytes: number
          partCount: number
        }>
        getUploadSnapshot: (
          uploadId: string,
          drive?: string
        ) => Promise<{
          state:
            | 'initiated'
            | 'uploading'
            | 'paused'
            | 'suspended_auth'
            | 'finalizing'
            | 'canceling'
            | 'completed'
            | 'aborted'
            | 'failed'
          session: {
            uploadId: string
            state: string
            expectedBytes: number
            committedBytes: number
            resultResourceId?: string
            resultVersion?: number
          } | null
          uploadedBytes: number
          totalBytes: number
        } | null>
        listUploadSessions: (drive?: string) => Promise<
          Array<{
            uploadId: string
            fileName: string
            fileSize: number
            name: string
            drive: string
            status: 'active' | 'paused' | 'failed' | 'suspended_auth'
            target: {
              operation: 'create' | 'replace'
              parentRid?: string
              resourceRid?: string
              ifMatch?: number
            }
          }>
        >
        pauseUpload: (uploadId: string, drive?: string) => Promise<unknown>
        resumeUpload: (uploadId: string, drive?: string) => Promise<unknown>
        cancelUpload: (uploadId: string, drive?: string) => Promise<{ ok: true }>
        replaceFile: (
          resourceId: string,
          encodedData: string,
          drive?: string,
          ifMatch?: number
        ) => Promise<{
          resourceId: string
          rid: string
          gfsUri: string
          drive: string
          parentResourceId: string | null
          name: string
          kind: 'file' | 'directory'
          path: string | null
          version: number
          bytes: number
        }>
        replaceFileFromPath: (
          resourceId: string,
          filePath: string,
          drive?: string,
          ifMatch?: number
        ) => Promise<{
          uploadId: string
          state: string
          resultResourceId?: string
          resultVersion?: number
        }>
        getPathForFile: (file: File) => string
        renameResource: (
          resourceId: string,
          newName: string,
          drive?: string,
          ifMatch?: number
        ) => Promise<{ resourceId: string; version: number }>
        moveResource: (
          resourceId: string,
          destinationId: string,
          drive?: string,
          ifMatch?: number,
          newName?: string
        ) => Promise<{ resourceId: string; version: number }>
        deleteResource: (
          resourceId: string,
          drive?: string,
          ifMatch?: number
        ) => Promise<{ deleted: boolean; resourceId: string }>
        grant: (
          resourceId: string,
          subjectKeys: string[],
          bits: string[],
          drive?: string,
          inherit?: boolean
        ) => Promise<void>
        listGrants: (
          resourceId: string,
          drive?: string
        ) => Promise<
          Array<{
            id: string
            drive: string
            resourceId: string
            subject: { type: string; id?: string }
            permissions: string[]
            inherit: boolean
          }>
        >
        revokeGrant: (grantId: string) => Promise<void>
        listShares: (
          resourceId: string,
          drive?: string
        ) => Promise<
          Array<{
            id: string
            drive: string
            resourceId: string
            subject: { type: string; id?: string }
            permissions: string[]
            includeDescendants: boolean
          }>
        >
        revokeShare: (shareId: string) => Promise<void>
        createShare: (resourceId: string, subjectKeys: string[], drive?: string) => Promise<void>
      }
      agents: {
        listMine: () => Promise<AgentWithMcpServers[]>
      }
      approvals: {
        listPending: (limit?: number) => Promise<PendingWorkflowApproval[]>
        decide: (
          approvalId: string,
          decision: 'approve' | 'deny',
          note?: string,
          options?: { teamId?: string | null }
        ) => Promise<WorkflowApprovalDecisionResult>
      }
      notifications: {
        subscribe: (
          onEvent: (event: WorkflowNotificationStreamEvent) => void
        ) => Promise<() => Promise<void>>
        status: () => Promise<{
          active: number
          open: number
          connecting: number
          error: number
          approvalRequested: number
          snapshot: number
          updated: number
        }>
        isSupported: () => Promise<boolean>
        show: (payload: {
          id: string
          title: string
          body: string
          tag?: string
          silent?: boolean
          actions?: Array<{ action: string; title: string }>
        }) => Promise<{ supported: boolean; id: string }>
        onClick: (callback: (payload: { id: string }) => void) => () => void
        onAction: (callback: (payload: { id: string; action: string }) => void) => () => void
        onFailed: (callback: (payload: { id: string; error: string }) => void) => () => void
        ack: (notificationId: string) => Promise<{ ok: boolean; status: string }>
      }
      entityChanges: {
        subscribe: (
          onEvent: (event: EntityChangeStreamEvent) => void
        ) => Promise<() => Promise<void>>
      }
      notificationPreferences: {
        get: () => Promise<import('./types').UserNotificationPreferences>
        update: (payload: {
          preferredMedium: 'telegram' | 'slack' | null
          channelFallbackEnabled: boolean
        }) => Promise<import('./types').UserNotificationPreferences>
      }
      socialChannels: {
        getSummary: () => Promise<ExternalChannelsSummary>
      }
      access: {
        getCatalog: () => Promise<AccessCatalog>
        refreshCatalog: () => Promise<AccessCatalog>
      }
      sharedFiles: {
        listAttached: (contextId: string) => Promise<{
          items: Array<{
            name: string
            mountPath: string
            phase: string | null
            pvcName: string | null
            message: string | null
          }>
        }>
        listDirectory: (
          contextId: string,
          sfsName: string,
          path: string
        ) => Promise<{
          path: string
          entries: Array<{
            name: string
            kind: 'file' | 'directory' | 'other'
            size: number
            mtime: string
          }>
          truncated: boolean
        }>
        download: (
          contextId: string,
          sfsName: string,
          path: string
        ) => Promise<{ saved: boolean; filePath: string | null }>
      }
      rpc: {
        listServers: (hostRefs?: string[]) => Promise<RpcAllowedServersResult>
        invokeHostMessage: (
          hostRef: string,
          payload: HostMessageRequest,
          hostRefs?: string[],
          options?: { async?: boolean }
        ) => Promise<HostMessageResponse>
        getTaskResult: (
          hostRef: string,
          taskId: string,
          hostRefs?: string[]
        ) => Promise<HostMessageResponse>
        getHostStatus: (hostRef: string, hostRefs?: string[]) => Promise<HostRuntimeStatus>
        prewarmHost: (hostRef: string, hostRefs?: string[]) => Promise<PrewarmHostResult>
        getHostActivity: (
          hostRef: string,
          limit?: number,
          sinceEventId?: string,
          hostRefs?: string[]
        ) => Promise<HostActivitySnapshot>
        subscribeHostStatus: (
          hostRef: string,
          hostRefs: string[] | undefined,
          onEvent: (event: HostStatusStreamEvent) => void
        ) => Promise<() => Promise<void>>
        subscribeHostActivity: (
          hostRef: string,
          hostRefs: string[] | undefined,
          onEvent: (event: HostActivityStreamEvent) => void
        ) => Promise<() => Promise<void>>
        subscribeTaskProgress: (
          hostRef: string,
          taskId: string,
          onEvent: (event: TaskProgressStreamEvent) => void
        ) => Promise<() => Promise<void>>
        cancelTask: (hostRef: string, taskId: string) => Promise<void>
        approveToolCall: (
          hostRef: string,
          taskId: string,
          toolCallId: string,
          hostRefs?: string[],
          options?: { teamId?: string | null }
        ) => Promise<ApprovalDecisionResult>
        denyToolCall: (
          hostRef: string,
          taskId: string,
          toolCallId: string,
          reason: string,
          hostRefs?: string[],
          options?: { teamId?: string | null }
        ) => Promise<ApprovalDecisionResult>
        listArtifacts: (
          hostRef: string,
          hostRefs?: string[]
        ) => Promise<{
          artifacts: Array<{ name: string; format: string; sizeBytes: number; createdAt: string }>
        }>
        downloadArtifact: (
          hostRef: string,
          filename: string,
          hostRefs?: string[]
        ) => Promise<Buffer>
        listSessions: (
          hostRef: string,
          hostRefs?: string[],
          query?: SessionsListQuery
        ) => Promise<SessionsListResult>
        loadSessionMessages: (
          hostRef: string,
          agent: string,
          chatId: string,
          hostRefs?: string[],
          query?: SessionMessagesQuery
        ) => Promise<SessionMessagesResult>
        getContextBreakdown: (
          hostRef: string,
          agent: string,
          chatId: string,
          hostRefs?: string[]
        ) => Promise<ContextBreakdownResult>
        /**
         * R2 model selector. Resolves to `null` when the host predates the
         * endpoint (404/501) so the UI hides the selector (compat, R2.6).
         */
        getHostModels: (
          hostRef: string,
          chatId: string,
          hostRefs?: string[]
        ) => Promise<HostModelsResult | null>
        /**
         * Sets the per-session model (applies to the next task). Rejects with an
         * error whose message contains `model_not_allowed` when the model is not
         * in the operator allowlist.
         */
        setHostModel: (
          hostRef: string,
          chatId: string,
          model: string,
          hostRefs?: string[],
          /**
           * Optional CAS precondition (issue #654). Only sent when the host
           * projected `modelSelectionRevision`; a stale value is rejected with
           * `model_selection_conflict` instead of silently overwriting a newer
           * selection.
           */
          expectedRevision?: number
        ) => Promise<SetHostModelResult>
        /**
         * Spec 15 Fase B — explicit user rename, propagated to the server. Rejects
         * with an error whose message carries the HTTP status `(NNN)` so the
         * renderer's pending-rename queue can branch on 404 / 400·403 / 5xx.
         */
        renameSession: (
          hostRef: string,
          agent: string,
          chatId: string,
          title: string
        ) => Promise<{ title: string }>
        getTokenMetadata: () => Promise<TokenMetadata>
        // U5 (mcp-oauth reactive consent): "Connect <server>" for a task
        // suspended with `connect_required`. Host-bound to that conversation.
        connectMcpServer: (
          mcpServerName: string,
          hostRef: string,
          contextId?: string,
          options?: { confirmShared?: boolean }
        ) => Promise<void>
        // Proactive connectors panel (spec 11 U2): the classified per-agent fleet.
        listConnectors: () => Promise<RpcConnectorsResult>
        // Proactive disconnect (spec 11 U4): revoke an mcp-server's OAuth grant.
        // Main shows a native confirm dialog first; resolves `{ confirmed:false }`
        // when the user cancels. `options.shared` drives only the confirm copy.
        disconnectMcpServer: (
          mcpServerName: string,
          hostRef: string,
          contextId?: string,
          options?: { shared?: boolean }
        ) => Promise<{ confirmed: boolean }>
        // Push fired when the OAuth deep-link returns with `source=mcp`; the
        // renderer correlates `mcpServerName` and resumes the suspended task.
        onMcpOauthCompleted: (
          callback: (args: { mcpServerName: string; provider: string }) => void
        ) => () => void
      }
      app: {
        openUrl: (url: string) => Promise<void>
        rendererReady: () => Promise<void>
      }
      window: {
        getVisibility: () => Promise<{ visible: boolean; focused: boolean }>
        getControlsState: () => Promise<{ fullscreen: boolean; maximized: boolean }>
        minimize: () => Promise<void>
        toggleMaximize: () => Promise<void>
        close: () => Promise<void>
        onVisibilityChange: (
          callback: (state: { visible: boolean; focused: boolean }) => void
        ) => () => void
        onControlsStateChange: (
          callback: (state: { fullscreen: boolean; maximized: boolean }) => void
        ) => () => void
      }
      system: {
        /** GAP-D1 (§4.5-4): OS resume / screen unlock tick — reconcile in-flight chats. */
        onResume: (callback: () => void) => () => void
      }
      desktop: {
        openWindow: (args: { hostRef: string }) => Promise<void>
        closeWindow: (args: { hostRef: string }) => Promise<void>
        getStatus: (args: {
          hostRef: string
        }) => Promise<{ hostRef: string; status: string; message?: string }>
        onWindowClosed: (callback: (args: { hostRef: string }) => void) => () => void
      }
      workflows: {
        list: () => Promise<WorkflowRecipeListResult>
        read: (ns: string, name: string) => Promise<unknown>
        health: (ns: string, name: string) => Promise<unknown>
        trigger: (
          ns: string,
          name: string,
          inputs?: Record<string, unknown>,
          idempotencyKey?: string
        ) => Promise<unknown>
        runs: (ns: string, name: string, limit?: number) => Promise<WorkflowRunsResult>
        listRunArtifacts: (
          ns: string,
          name: string,
          runId: string
        ) => Promise<WorkflowRunArtifactsResult>
        downloadRunArtifact: (
          ns: string,
          name: string,
          runId: string,
          artifactName: string
        ) => Promise<{ saved: boolean; filePath: string; filename: string }>
      }
      chat: {
        list: (agentRef: string) => Promise<ChatMetadata[]>
        create: (agentRef: string, chatId: string) => Promise<ChatMetadata>
        rename: (
          agentRef: string,
          chatId: string,
          title: string,
          bindingGeneration: number
        ) => Promise<void>
        getBindingGeneration: () => Promise<number>
        captureDeleteFence: (expectedAuthorityScope: ChatAuthorityScope) => Promise<ChatDeleteFence>
        delete: (
          agentRef: string,
          chatId: string,
          fence: ChatDeleteFence
        ) => Promise<ChatDeleteResult>
        loadMessages: (
          agentRef: string,
          chatId: string,
          limit?: number,
          offset?: number
        ) => Promise<ChatMessage[]>
        appendMessages: (agentRef: string, chatId: string, messages: ChatMessage[]) => Promise<void>
        upsertMessages: (agentRef: string, chatId: string, messages: ChatMessage[]) => Promise<void>
        replaceMessages: (
          agentRef: string,
          chatId: string,
          messages: ChatMessage[],
          options?: ReplaceChatMessagesOptions
        ) => Promise<void>
        backfillCounters?: (
          agentRef: string,
          chatId: string,
          messages: ChatMessage[]
        ) => Promise<void>
        getLastActive: (agentRef: string) => Promise<string | null>
        setLastActive: (agentRef: string, chatId: string) => Promise<void>
        getIndex: (agentRef: string) => Promise<ChatIndex>
        reconcileServerSessions: (
          agentRef: string,
          sessions: Array<{ chatId: string; lastActivityAt?: string; title?: string }>
        ) => Promise<number>
        dismissOnboarding: (agentRef: string) => Promise<void>
        markUnreadTerminal: (agentRef: string, chatId: string) => Promise<void>
        clearUnreadTerminal: (agentRef: string, chatId: string) => Promise<void>
      }
      sandboxUi: {
        listApps: () => Promise<{
          apps: SandboxUiApp[]
        }>
        mintSession: (recipeNs: string, recipeName: string) => Promise<{ setCookie: string }>
        open: (args: {
          recipeNs: string
          recipeName: string
          defaultPath?: string
          routePath?: string
          bounds: { x: number; y: number; width: number; height: number; dpr?: number }
          // Echoed by main on `onReleased` / `onRefreshError` / `onRefreshRecovered` /
          // `onTitleChanged` for the view this open mounts.
          launchId: string
        }) => Promise<void>
        // Closes that launch's view only if it is still the live one.
        close: (args: { launchId: string }) => Promise<void>
        // Reloads that launch's view in place only if it is still the live one.
        reload: (args: { launchId: string }) => Promise<void>
        copyDeepLink: (teamId?: string) => Promise<{ url: string }>
        listPendingDeepLinks: () => Promise<{ links: SandboxUiDeepLinkEnvelope[] }>
        clearPendingDeepLinks: () => Promise<void>
        acknowledgeDeepLink: (id: number) => Promise<void>
        setBounds: (bounds: {
          x: number
          y: number
          width: number
          height: number
          dpr?: number
        }) => Promise<void>
        setVisible: (visible: boolean) => Promise<void>
        capturePreview: () => Promise<string | null>
        findInPage: (
          query: string,
          options: {
            operation: 'start' | 'next' | 'previous'
            clientRequestId: number
          }
        ) => Promise<
          | { status: 'started'; requestId: number }
          | {
              status: 'unavailable'
              reason: 'no-active-view' | 'document-loading' | 'no-session'
            }
        >
        stopFindInPage: () => Promise<void>
        focusActive: () => Promise<boolean>
        onFindResult: (
          callback: (result: {
            requestId: number
            clientRequestId: number
            activeMatchOrdinal: number
            matches: number
            finalUpdate: boolean
          }) => void
        ) => () => void
        onDeepLink: (callback: (args: SandboxUiDeepLinkEnvelope) => void) => () => void
        // Once per view main tears down, whatever the reason, with the route it
        // represented (`null`: unreadable, keep the last known one).
        onReleased: (callback: (args: SandboxUiReleasedEvent) => void) => () => void
        onRefreshError: (
          callback: (args: { appRef: string; launchId: string; message: string }) => void
        ) => () => void
        // A refresh that `onRefreshError` reported as failed succeeded later.
        onRefreshRecovered: (
          callback: (args: { appRef: string; launchId: string }) => void
        ) => () => void
        onTitleChanged: (
          callback: (args: { appRef: string; launchId: string; title: string }) => void
        ) => () => void
      }
      pluginSdk: {
        onConsentRequested: (callback: (request: PluginConsentRequest) => void) => () => void
        onConsentCancelled: (callback: (args: { promptId: string }) => void) => () => void
        onOpenGfsResource: (
          callback: (args: {
            gfsUri: string
            name: string
            kind: string
            bytes: number | null
            version?: number
          }) => void
        ) => () => void
        onNotificationClicked: (
          callback: (args: { pluginId: string; ref: string | null }) => void
        ) => () => void
        resolveConsent: (promptId: string, allowed: string[]) => Promise<boolean>
        listGrants: () => Promise<PluginGrantView[]>
        revoke: (pluginId: string, capability?: string) => Promise<void>
        activity: (limit?: number, includeAmbient?: boolean) => Promise<PluginAuditEntryView[]>
        clearActivity: () => Promise<void>
        setTheme: (theme: string) => Promise<void>
      }
    }
  }
}

export {}