()
| 26 | } | null = null; |
| 27 | |
| 28 | export async function ensureInputTool(): Promise<{ |
| 29 | tool: InputTool; |
| 30 | display: DisplayServer; |
| 31 | }> { |
| 32 | const provider = resolveLinuxToolProvider(); |
| 33 | if (cachedInputTool?.provider === provider) return cachedInputTool; |
| 34 | |
| 35 | const display = detectDisplayServer(); |
| 36 | |
| 37 | if (display === 'wayland') { |
| 38 | if (await provider.whichCommand('ydotool')) { |
| 39 | cachedInputTool = { tool: 'ydotool', display, provider }; |
| 40 | return cachedInputTool; |
| 41 | } |
| 42 | throw new AppError( |
| 43 | 'TOOL_MISSING', |
| 44 | 'ydotool is required for input synthesis on Wayland (xdotool does not work on Wayland). Install it via your package manager.', |
| 45 | ); |
| 46 | } |
| 47 | |
| 48 | if (await provider.whichCommand('xdotool')) { |
| 49 | cachedInputTool = { tool: 'xdotool', display, provider }; |
| 50 | return cachedInputTool; |
| 51 | } |
| 52 | throw new AppError( |
| 53 | 'TOOL_MISSING', |
| 54 | 'xdotool is required for input synthesis on X11. Install it via your package manager.', |
| 55 | ); |
| 56 | } |
| 57 | |
| 58 | /** Reset cached tool (for testing). */ |
| 59 | export function resetInputToolCache(): void { |
no test coverage detected
searching dependent graphs…