import { VSBuffer } from "../../../base/common/buffer.js"; import { Event } from "../../../base/common/event.js"; import { URI, UriComponents } from "../../../base/common/uri.js"; import { MessageBoxOptions, MessageBoxReturnValue, OpenDevToolsOptions, OpenDialogOptions, OpenDialogReturnValue, SaveDialogOptions, SaveDialogReturnValue } from "../../../base/parts/sandbox/common/electronTypes.js"; import { ISerializableCommandAction } from "../../action/common/action.js"; import { AgentHostEditorUpdate, IAgentHostEditorState, IAgentsWindowInvitation } from "../../chat/common/agentsWindowInvitation.js"; import { INativeOpenDialogOptions } from "../../dialogs/common/dialogs.js"; import { IV8Profile } from "../../profiling/common/profiling.js"; import { AuthInfo, Credentials } from "../../request/common/request.js"; import { IPartsSplash } from "../../theme/common/themeService.js"; import { AgentsWindowOpenSource, IAgentsWindowDraft, IColorScheme, IOpenedAuxiliaryWindow, IOpenedMainWindow, IOpenEmptyWindowOptions, IOpenWindowOptions, IPoint, IRectangle, IWindowOpenable } from "../../window/common/window.js"; export interface IToastOptions { readonly id: string; /** * Prevents another live toast with the same key from being shown. */ readonly dedupeKey?: string; readonly title: string; readonly body?: string; readonly actions?: readonly string[]; readonly silent?: boolean; } export interface IToastResult { readonly supported: boolean; /** * True when a live toast with the requested dedupe key is already visible. */ readonly suppressed?: boolean; readonly clicked: boolean; readonly actionIndex?: number; } /** * A count badge to render on the application icon in the dock (macOS), the * launcher (Linux) or over the taskbar icon of a window (Windows). */ export interface IApplicationBadge { /** The number to show. A count of `0` clears the badge. */ readonly count: number; /** Accessible description of the badge, used for the Windows taskbar overlay. */ readonly description: string; /** * PNG image data as a `data:` URL for the Windows taskbar overlay icon, * which has no built-in count rendering. Ignored on other platforms, * where the OS renders {@link count} itself. */ readonly iconDataURL?: string; } /** * A ZIP entry whose contents are inline or streamed from a local file. */ export type INativeZipFile = { readonly path: string; readonly contents: string; } | { readonly path: string; readonly source: URI; readonly size: number; readonly compress?: boolean; /** Skip this entry when its source cannot be opened or inspected. */ readonly skipSourceErrors?: boolean; } | { readonly sourceArchive: URI; }; export interface INativeZipOptions { readonly maxSize?: number; readonly maxEntries: number; readonly operationId?: string; } export interface INativeZipProgress { readonly operationId: string; readonly bytes: number; readonly total: number; readonly path: string; } export interface INativeZipResult { readonly skippedFiles: readonly { readonly path: string; readonly error: string; }[]; } export interface IOpenAgentsWindowOptions { readonly folderUri?: UriComponents; /** Use the invoking editor's folder only for a fresh composer, without replacing an existing session or user choice. */ readonly folderUriIsDefault?: boolean; /** Reveal a session or the new-session composer; otherwise preserve the view of an already-open window. */ readonly reveal?: UriComponents | "new"; /** Session to spotlight after a contextual invitation, even when it is not opened. */ readonly onboardingSessionResource?: UriComponents; readonly source?: AgentsWindowOpenSource; /** Copy a draft only when explicitly revealing the new-session composer. */ readonly draft?: IAgentsWindowDraft; } export interface ICPUProperties { model: string; speed: number; } export interface IOSProperties { type: string; release: string; arch: string; platform: string; cpus: ICPUProperties[]; } export interface IOSStatistics { totalmem: number; freemem: number; loadavg: number[]; } export interface IOSProxy { readonly kind: "direct" | "http" | "socks"; readonly host?: string; } export interface IOSProxyEnvironmentVariableStatus { readonly variable: string; readonly value: string; readonly error?: string; } export interface IOSProxyPacSourceStatus { readonly state: "disabled" | "unsupported" | "unconfigured" | "not-found" | "available" | "error-discovery" | "error-download" | "unknown"; readonly url?: string; readonly error?: string; } export interface IOSProxyConfig { readonly environment: { readonly httpProxy?: IOSProxyEnvironmentVariableStatus; readonly httpsProxy?: IOSProxyEnvironmentVariableStatus; readonly allProxy?: IOSProxyEnvironmentVariableStatus; readonly noProxy?: IOSProxyEnvironmentVariableStatus; }; readonly autoDetect: boolean; readonly pacUrl?: string; readonly pac?: { readonly url: string; readonly content: string; readonly source: "wpad-dns" | "wpad-dhcp" | "configured" | "unknown"; }; readonly wpadDhcp: IOSProxyPacSourceStatus; readonly wpadDns: IOSProxyPacSourceStatus; readonly configuredPac: IOSProxyPacSourceStatus; readonly staticRules?: { readonly http?: IOSProxy; readonly https?: IOSProxy; readonly socks?: IOSProxy; }; readonly platform?: { readonly kind: "windows"; readonly proxy?: string; readonly proxyBypass?: string; } | { readonly kind: "macos"; readonly exceptions: readonly string[]; readonly excludeSimpleHostnames: boolean; } | { readonly kind: "linux"; readonly mode?: string; readonly ignoreHosts: readonly string[]; } | { readonly kind: "unknown"; }; } export interface INativeHostOptions { readonly targetWindowId?: number; } export interface IStartTracingOptions { /** * Whether to enable heap profiling for MemoryInfra traces. Only takes effect * if the `disabled-by-default-memory-infra` category is included in the trace * and requires the recording to also collect periodic memory dumps. */ readonly enableHeapProfiling?: boolean; } export declare enum FocusMode { /** * (Default) Transfer focus to the target window * when the editor is focused. */ Transfer = 0, /** * Transfer focus to the target window when the * editor is focused, otherwise notify the user that * the app has activity (macOS/Windows only). */ Notify = 1, /** * Force the window to be focused, even if the editor * is not currently focused. */ Force = 2 } export interface INativeSystemWideKeybinding { /** * The keybinding in Electron accelerator format (e.g. `Control+Cmd+A`). * See https://www.electronjs.org/docs/latest/api/accelerator. */ readonly accelerator: string; /** * The command to execute when the global shortcut is triggered. */ readonly commandId: string; /** * Optional command arguments as configured in `keybindings.json`. Must be JSON-serializable. */ readonly args?: unknown; /** * The user settings label (e.g. `ctrl+cmd+a`) for diagnostics/notifications. */ readonly userSettingsLabel?: string; } export interface INativeSystemWideKeybindingResult { /** * The user settings labels (or accelerators) that could not be registered, e.g. because the * accelerator is already taken by the OS or another application. */ readonly failed: string[]; } export interface ICommonNativeHostService { readonly _serviceBrand: undefined; readonly windowId: number; readonly onDidOpenMainWindow: Event; readonly onDidMaximizeWindow: Event; readonly onDidUnmaximizeWindow: Event; readonly onDidFocusMainWindow: Event; readonly onDidBlurMainWindow: Event; readonly onDidChangeWindowFullScreen: Event<{ windowId: number; fullscreen: boolean; }>; readonly onDidChangeWindowAlwaysOnTop: Event<{ windowId: number; alwaysOnTop: boolean; }>; readonly onDidFocusMainOrAuxiliaryWindow: Event; readonly onDidBlurMainOrAuxiliaryWindow: Event; readonly onDidChangeDisplay: Event; readonly onDidChangeGPUCompositing: Event; readonly onDidChangeAgentHostEditorState: Event; readonly onDidSuspendOS: Event; readonly onDidResumeOS: Event; readonly onDidChangeOnBatteryPower: Event; readonly onDidChangeThermalState: Event; readonly onDidChangeSpeedLimit: Event; readonly onWillShutdownOS: Event; readonly onDidLockScreen: Event; readonly onDidUnlockScreen: Event; readonly onDidChangeColorScheme: Event; readonly onDidChangePassword: Event<{ readonly service: string; readonly account: string; }>; readonly onDidTriggerWindowSystemContextMenu: Event<{ readonly windowId: number; readonly x: number; readonly y: number; }>; getWindows(options: { includeAuxiliaryWindows: true; }): Promise>; getWindows(options: { includeAuxiliaryWindows: false; }): Promise>; getWindowCount(): Promise; getActiveWindowId(): Promise; getActiveWindowPosition(): Promise; getNativeWindowHandle(windowId: number): Promise; openWindow(options?: IOpenEmptyWindowOptions): Promise; openWindow(toOpen: IWindowOpenable[], options?: IOpenWindowOptions): Promise; openAgentsWindow(options?: IOpenAgentsWindowOptions): Promise; getAgentHostEditorState(legacyEditorSessionCount: number): Promise; updateAgentHostEditorState(update: AgentHostEditorUpdate): Promise; claimAgentsWindowInvitation(resource: UriComponents, developerMode: boolean): Promise; markAgentsWindowInvitationShown(id: string): Promise; releaseAgentsWindowInvitation(id: string): Promise; /** * Registers this window's set of system-wide (OS global) keybindings with the main process, * replacing any previously registered by this window. The shortcuts fire even when the * application is not focused. Returns the set that could not be registered. */ syncSystemWideKeybindings(keybindings: INativeSystemWideKeybinding[]): Promise; isFullScreen(options?: INativeHostOptions): Promise; toggleFullScreen(options?: INativeHostOptions): Promise; getCursorScreenPoint(): Promise<{ readonly point: IPoint; readonly display: IRectangle; }>; isMaximized(options?: INativeHostOptions): Promise; maximizeWindow(options?: INativeHostOptions): Promise; unmaximizeWindow(options?: INativeHostOptions): Promise; minimizeWindow(options?: INativeHostOptions): Promise; moveWindowTop(options?: INativeHostOptions): Promise; positionWindow(position: IRectangle, options?: INativeHostOptions): Promise; isWindowAlwaysOnTop(options?: INativeHostOptions): Promise; toggleWindowAlwaysOnTop(options?: INativeHostOptions): Promise; setWindowAlwaysOnTop(alwaysOnTop: boolean, options?: INativeHostOptions): Promise; updateWindowControls(options: INativeHostOptions & { height?: number; horizontalInset?: number; backgroundColor?: string; foregroundColor?: string; dimmed?: boolean; }): Promise; updateWindowAccentColor(color: "default" | "off" | string, inactiveColor: string | undefined): Promise; setMinimumSize(width: number | undefined, height: number | undefined): Promise; saveWindowSplash(splash: IPartsSplash): Promise; setBackgroundThrottling(allowed: boolean): Promise; /** * Make the window focused. * @param options specify the specific window to focus and the focus mode. * Defaults to {@link FocusMode.Transfer}. */ focusWindow(options?: INativeHostOptions & { mode?: FocusMode; }): Promise; showMessageBox(options: MessageBoxOptions & INativeHostOptions): Promise; showSaveDialog(options: SaveDialogOptions & INativeHostOptions): Promise; showOpenDialog(options: OpenDialogOptions & INativeHostOptions): Promise; pickFileFolderAndOpen(options: INativeOpenDialogOptions): Promise; pickFileAndOpen(options: INativeOpenDialogOptions): Promise; pickFolderAndOpen(options: INativeOpenDialogOptions): Promise; pickWorkspaceAndOpen(options: INativeOpenDialogOptions): Promise; showItemInFolder(path: string): Promise; /** * Drags the file or folder at absolute `path` out of the window, as if the user dragged it from the file manager, so * other apps can take it. Call it from a `dragstart` handler that cancels the HTML drag, while the mouse button is * still down. Does nothing for a path that doesn't exist. */ startFileDrag(path: string, options?: INativeHostOptions): Promise; setRepresentedFilename(path: string, options?: INativeHostOptions): Promise; setDocumentEdited(edited: boolean, options?: INativeHostOptions): Promise; /** * Renders a count badge on the application icon. Passing `undefined` or a * badge with a count of `0` clears it again. */ setApplicationBadge(badge: IApplicationBadge | undefined, options?: INativeHostOptions): Promise; openExternal(url: string, defaultApplication?: string): Promise; moveItemToTrash(fullPath: string): Promise; getMediaAccessStatus(mediaType: "microphone" | "camera" | "screen"): Promise<"not-determined" | "granted" | "denied" | "restricted" | "unknown">; /** Requests screen-capture permission without starting a recording. */ requestScreenCaptureAccess(): Promise; isAdmin(): Promise; writeElevated(source: URI, target: URI, options?: { unlock?: boolean; }): Promise; isRunningUnderARM64Translation(): Promise; getOSProperties(): Promise; getOSStatistics(): Promise; /** Returns the bytes available to the user on the filesystem containing the path or its nearest existing ancestor. */ getFreeDiskSpace(path: string): Promise; getOSVirtualMachineHint(): Promise; isGPUCompositingEnabled(): Promise; getOSColorScheme(): Promise; hasWSLFeatureInstalled(): Promise; getScreenshot(rect?: IRectangle): Promise; uploadFileViaMobileApi(token: string, repoId: string, fileName: string, fileBytes: VSBuffer, contentType: string): Promise<{ fileName: string; assetUrl: string; contentType: string; }>; getProcessId(): Promise; killProcess(pid: number, code: string): Promise; triggerPaste(options?: INativeHostOptions): Promise; readClipboardText(type?: "selection" | "clipboard"): Promise; writeClipboardText(text: string, type?: "selection" | "clipboard"): Promise; readClipboardFindText(): Promise; writeClipboardFindText(text: string): Promise; writeClipboardBuffer(format: string, buffer: VSBuffer, type?: "selection" | "clipboard"): Promise; readClipboardBuffer(format: string): Promise; hasClipboard(format: string, type?: "selection" | "clipboard"): Promise; readImage(): Promise; writeImage(data: VSBuffer): Promise; newWindowTab(): Promise; showPreviousWindowTab(): Promise; showNextWindowTab(): Promise; moveWindowTabToNewWindow(): Promise; mergeAllWindowTabs(): Promise; toggleWindowTabsBar(): Promise; updateTouchBar(items: ISerializableCommandAction[][]): Promise; installShellCommand(): Promise; uninstallShellCommand(): Promise; notifyReady(): Promise; relaunch(options?: { addArgs?: string[]; removeArgs?: string[]; }): Promise; reload(options?: { disableExtensions?: boolean; }): Promise; closeWindow(options?: INativeHostOptions): Promise; quit(): Promise; exit(code: number): Promise; openDevTools(options?: Partial & INativeHostOptions): Promise; toggleDevTools(options?: INativeHostOptions): Promise; openGPUInfoWindow(): Promise; openDevToolsWindow(url: string): Promise; openContentTracingWindow(): Promise; stopTracing(): Promise; profileRenderer(session: string, duration: number): Promise; startTracing(categories: string, options?: IStartTracingOptions): Promise; resolveProxy(url: string): Promise; resolveProxyWithPackage(url: string): Promise; readProxyConfigWithPackage(): Promise; lookupAuthorization(authInfo: AuthInfo): Promise; lookupKerberosAuthorization(url: string): Promise; loadCertificates(): Promise; isPortFree(port: number): Promise; findFreePort(startPort: number, giveUpAfter: number, timeout: number, stride?: number): Promise; windowsGetStringRegKey(hive: "HKEY_CURRENT_USER" | "HKEY_LOCAL_MACHINE" | "HKEY_CLASSES_ROOT" | "HKEY_USERS" | "HKEY_CURRENT_CONFIG", path: string, name: string): Promise; showToast(options: IToastOptions): Promise; clearToast(id: string): Promise; clearToasts(): Promise; /** * Creates a zip file at the specified path containing the provided files. * * @param zipPath The URI where the zip file should be created. * @param files An array of file entries to include in the zip. Each entry has * a relative path and is either given inline string `contents`, or a local * file `source` URI together with the number of leading bytes (`size`) to * stream from it. */ createZipFile(zipPath: URI, files: INativeZipFile[], options?: INativeZipOptions): Promise; readonly onDidProgressZipFile: Event; cancelZipFile(operationId: string): Promise; getSystemIdleState(idleThreshold: number): Promise; getSystemIdleTime(): Promise; getCurrentThermalState(): Promise; isOnBatteryPower(): Promise; startPowerSaveBlocker(type: PowerSaveBlockerType): Promise; stopPowerSaveBlocker(id: number): Promise; isPowerSaveBlockerStarted(id: number): Promise; } /** * Represents the system's idle state. */ export type SystemIdleState = "active" | "idle" | "locked" | "unknown"; /** * Represents the system's thermal state. */ export type ThermalState = "unknown" | "nominal" | "fair" | "serious" | "critical"; /** * The type of power save blocker. */ export type PowerSaveBlockerType = "prevent-app-suspension" | "prevent-display-sleep";