import { contextBridge, ipcRenderer } from "electron"; import type { DesktopServerConnection, DesktopServerSettings } from "../shared/server-settings"; const api = { /** Read the active Executor server connection backing this desktop window. */ getServerConnection(): Promise { return ipcRenderer.invoke("executor:server:connection"); }, /** Read the desktop-persisted server profile payload. */ getServerProfiles(): Promise { return ipcRenderer.invoke("executor:server-profiles:get"); }, /** Persist the server profile payload in desktop storage. */ setServerProfiles(value: string): Promise { return ipcRenderer.invoke("executor:server-profiles:set", value); }, /** Read the persisted server settings (port, requireAuth, password). */ getSettings(): Promise { return ipcRenderer.invoke("executor:settings:get"); }, /** Patch one or more server settings. Returns the new full settings. */ updateSettings(patch: Partial): Promise { return ipcRenderer.invoke("executor:settings:update", patch); }, /** Regenerate the random Basic-auth password. Returns the new settings. */ regeneratePassword(): Promise { return ipcRenderer.invoke("executor:settings:regenerate-password"); }, /** * Stop + restart the sidecar so settings changes take effect. * Main reloads the window and returns the refreshed server connection. */ restartServer(): Promise { return ipcRenderer.invoke("executor:server:restart"); }, /** * Open an http(s) URL in the user's default browser. Main-side validates * the scheme. Used by the system-browser OAuth flow. */ openExternal(url: string): Promise { return ipcRenderer.invoke("executor:shell:open-external", url); }, } as const; contextBridge.exposeInMainWorld("executor", api); export type ExecutorBridge = typeof api;