import type { CreatePublishJobResponse, DesktopAccountInfo, DesktopBugReportSubmitRequest, DesktopBugReportSubmitResponse, DesktopClientReleaseCheckResponse, DesktopClientRotateResponse, DesktopClientUpdateProgressEvent, DesktopClientUpdateResult, DesktopPublishTaskListResponse, DesktopRuntimeSessionSyncRequest, DesktopTaskInfo, ListDesktopPublishTasksParams, } from '@geo/shared-types' import type { DesktopObservedRequest } from '../shared/network-debug' import type { DesktopRuntimeSnapshot } from './types' export {} declare global { interface DesktopAppSettings { openAtLogin: boolean keepRunningInBackground: boolean autoCleanStorageWeekly: boolean } interface DesktopLoginCredentials { identifier: string password: string } interface DesktopStorageEntry { id: string label: string kind: 'app-cache' | 'bound-account' | 'unbound-session' partition: string | null accountId: string | null sizeBytes: number cleanableBytes: number lastModifiedAt: number | null cleanable: boolean active: boolean } interface DesktopStorageSnapshot { generatedAt: number totalBytes: number cleanableBytes: number appCacheBytes: number boundAccountBytes: number boundAccountCleanableBytes: number unboundSessionBytes: number unboundSessionCount: number boundAccountCount: number entries: DesktopStorageEntry[] autoCleanStorageWeekly: boolean lastCleanupAt: number | null nextCleanupAt: number | null } interface DesktopStorageCleanupResult { cleanedAt: number cleanedBytes: number removedEntries: number before: DesktopStorageSnapshot after: DesktopStorageSnapshot } interface WorkbenchNavigationState { canGoBack: boolean canGoForward: boolean loading: boolean url: string title: string host: string secure: boolean } interface DesktopAuthRecoveryRequest { reason: 'desktop-client-token-unauthorized' method: string path: string status: number code?: number message: string requestId: string at: number } interface Window { desktopBridge: { app: { ping(): Promise versionInfo(): Promise<{ version: string channel: string }> checkClientRelease(): Promise clientReleaseDownloadURL(): Promise<{ download_url: string }> quitApp(): Promise startClientUpdate(): Promise deviceInfo(): Promise<{ device_name: string os: string cpu_arch: string }> clientId(scope: { tenant_id: number workspace_id: number user_id: number }): Promise runtimeSnapshot(): Promise runtimeAccountSnapshot( accountId: string, ): Promise submitBugReport( payload: DesktopBugReportSubmitRequest, ): Promise bindPublishAccount(platformId: string): Promise refreshRuntimeAccounts(): Promise probeRuntimeAccount( accountId: string, ): Promise openPublishAccountConsole(account: { id: string platform: string platformUid: string displayName: string }): Promise unbindPublishAccount(accountId: string, syncVersion: number): Promise listPublishTasks( params?: ListDesktopPublishTasksParams, ): Promise retryPublishTask(taskId: string): Promise cancelPublishTask(taskId: string): Promise deletePublishRecord(recordId: number): Promise<{ deleted: boolean }> openExternalUrl(url: string): Promise openSettingsWindow(): Promise getAppSettings(): Promise getLoginCredentials(): Promise saveLoginCredentials(credentials: DesktopLoginCredentials): Promise clearLoginCredentials(): Promise setAppSetting(key: keyof DesktopAppSettings, value: boolean): Promise storageSnapshot(): Promise cleanStorage(): Promise syncRuntimeSession(session: DesktopRuntimeSessionSyncRequest | null): Promise rotateRuntimeClientToken(): Promise releaseRuntimeSession(revoke?: boolean, options?: { skipRemote?: boolean }): Promise setWindowMode( mode: 'login' | 'main', request?: { source?: 'auth-state' | 'login' | 'logout' animate?: boolean }, ): Promise onAuthRecoveryRequested(listener: (event: DesktopAuthRecoveryRequest) => void): () => void onRuntimeInvalidated( listener: (event: { reason: | 'account-health' | 'publish-task-lease' | 'publish-task-progress' | 'playwright-cdp-recovery' | 'playwright-cdp-fatal' at: number accountId?: string taskId?: string message?: string }) => void, ): () => void onNetworkObserved(listener: (event: DesktopObservedRequest) => void): () => void onClientUpdateProgress( listener: (event: DesktopClientUpdateProgressEvent) => void, ): () => void } workbenchNavigation: { getState(): Promise goBack(): Promise goForward(): Promise reload(): Promise onStateChanged(listener: (state: WorkbenchNavigationState) => void): () => void } } } }