/** * Native NAPI module loader — loads the compiled .node addon. * Supports macOS (darwin) and Windows (win32) with platform-specific binaries. */ export interface AXBounds { x: number; y: number; width: number; height: number; } export interface AXElement { role: string; label: string | null; value: string | null; bounds: AXBounds; actions: string[]; /** Present on full tree nodes; omitted by flat find_element results. */ children?: AXElement[]; /** Present on find_element results — indices from the walk root. */ path?: number[]; /** Set when a subtree or the whole tree hit the depth / node cap. */ truncated?: boolean; } export interface MenuItem { title: string; enabled: boolean; shortcut?: string; submenu?: MenuItem[]; } export interface MenuBarEntry { title: string; enabled: boolean; items: MenuItem[]; } export interface WindowRecord { windowId: number; bundleId: string | null; displayName: string; pid: number; title: string | null; bounds: AXBounds; isOnScreen: boolean; isFocused: boolean; displayId: number; } export interface NativeModule { mouseMove(x: number, y: number): void; mouseClick(x: number, y: number, button: string, count: number): void; mouseButton(action: string, x: number, y: number): void; mouseScroll(dy: number, dx: number): void; mouseDrag(x: number, y: number): void; cursorPosition(): { x: number; y: number; }; keyPress(combo: string, repeat?: number): void; typeText(text: string): void; holdKey(keys: string[], durationMs: number): void; activateApp(bundleId: string, timeoutMs?: number): { bundleId: string; activated: boolean; displayName?: string; }; getFrontmostApp(): { bundleId: string; displayName: string; pid: number; } | null; getWindow(windowId: number): WindowRecord | null; getCursorWindow(): WindowRecord | null; activateWindow(windowId: number, timeoutMs?: number): { windowId: number; activated: boolean; reason: string | null; }; listWindows(bundleId?: string): Array; listRunningApps(): Array<{ bundleId: string; displayName: string; pid: number; isHidden: boolean; }>; hideApp(bundleId: string): boolean; unhideApp(bundleId: string): boolean; getDisplaySize(displayId?: number): { width: number; height: number; pixelWidth: number; pixelHeight: number; scaleFactor: number; displayId: number; }; listDisplays(): Array<{ width: number; height: number; scaleFactor: number; displayId: number; }>; takeScreenshot(width?: number, targetApp?: string, quality?: number, previousHash?: string, windowId?: number): { base64?: string; width: number; height: number; mimeType: string; hash: string; unchanged: boolean; }; /** Depth-limited AX tree rooted at the window; caps at 500 nodes. */ getUiTree(windowId: number, maxDepth?: number): AXElement; /** Currently focused AX element (or null). */ getFocusedElement(): AXElement | null; /** Depth-first search within the window's AX tree. */ findElement(windowId: number, role?: string, label?: string, value?: string, maxResults?: number): AXElement[]; /** Perform an AX action (e.g. AXPress) on the first (role, label) match. */ performAction(windowId: number, role: string, label: string, action: string): { performed: boolean; reason?: string; bounds?: AXBounds; }; /** Set AXValue on the first (role, label) match. */ setElementValue(windowId: number, role: string, label: string, value: string): { set: boolean; reason?: string; }; /** Walk the app's menu bar and return nested menu structure. */ getMenuBar(bundleId: string): MenuBarEntry[]; /** Press a named menu item, optionally nested under a submenu. */ pressMenuItem(bundleId: string, menu: string, item: string, submenu?: string): { pressed: boolean; reason?: string; }; /** List user Spaces grouped by display, with the active Space ID. */ listSpaces(): { supported: boolean; reason?: string; active_space_id: number | null; displays: Array<{ display_id: string; spaces: Array<{ id: number; type: number; uuid: string; }>; }>; }; /** Active Space ID or null if CGS is unreachable. */ getActiveSpace(): number | null; /** Create a new Space. Reports `attached: false` when the created Space is * orphaned (not visible in Mission Control). */ createAgentSpace(): { supported: boolean; spaceId?: number; attached?: boolean; reason?: string; note?: string; }; /** Move a window into a Space. `verified: true` only when the window * visibly disappears from the on-screen window list. */ moveWindowToSpace(windowId: number, spaceId: number): { moved: boolean; verified?: boolean; reason?: string; note?: string; window_on_screen_before?: boolean; window_on_screen_after?: boolean; }; /** Remove a window from a Space (restores visibility). */ removeWindowFromSpace(windowId: number, spaceId: number): { removed: boolean; reason?: string; }; /** Destroy a Space created via createAgentSpace. */ destroySpace(spaceId: number): { destroyed: boolean; reason?: string; }; /** * Pump the main CFRunLoop once. Used by the session layer during a CU * session to keep NSWorkspace / AX state fresh. Cheap when idle. */ drainRunloop(): void; /** Read clipboard text (Windows native). Undefined on macOS. */ readClipboard?(): string; /** Write text to clipboard (Windows native). Undefined on macOS. */ writeClipboard?(text: string): void; /** Draw annotations and grid lines on an image. Cross-platform. */ annotateImage(base64Jpeg: string, annotations: string | null, gridCols: number | null, gridRows: number | null, quality: number | null): { base64: string; width: number; height: number; mimeType: string; }; /** Crop a region from a base64 image at full resolution. Cross-platform. */ cropImage(base64Image: string, x1: number, y1: number, x2: number, y2: number, quality: number | null): { base64: string; width: number; height: number; mimeType: string; }; /** * Hide every regular running app except the target and the keep-visible * set. Defends against focus-stealing background apps (screenshot * watchers, notification panels) before input dispatch. * * Returns the bundle IDs we actually hid — apps already hidden are NOT * included, so callers can restore exactly the state they changed. */ prepareDisplay(targetBundleId: string, keepVisible: string[]): { targetBundleId: string; hiddenBundleIds: string[]; }; } export declare function loadNative(): NativeModule;