// electron driver — wraps the existing desktop-companion helper. availability // is "is the rnx desktop app installed on this machine". launch delegates // to launchDesktopCompanion, which already handles mac `open -a`, linux // AppImage, and the --device seed. import { findDesktopCompanion, launchDesktopCompanion } from '../desktop-companion' import type { Driver, DriverAvailability, DriverLaunchOptions, DriverLaunchResult, } from './types' function probe(): DriverAvailability { const install = findDesktopCompanion() if (!install) { return { available: false, reason: 'rnx desktop app not installed (run `rnx desktop install`)', } } return { available: true, reason: null, detail: `${install.kind} @ ${install.path}`, } } async function launch(opts: DriverLaunchOptions): Promise { const install = findDesktopCompanion() if (!install) { return { launched: false, message: 'rnx desktop app not installed', } } try { const result = await launchDesktopCompanion(opts.url, install, { device: opts.device, profileId: opts.profileId, ephemeralProfile: opts.ephemeralProfile, ownerPid: opts.ownerPid, }) if (!result.launched) { return { launched: false, message: 'desktop companion failed to start' } } return { launched: true, message: opts.url ? `electron launched via ${result.via} → ${opts.url}` : `electron launched via ${result.via}`, target: result.target, attachUrl: opts.url, } } catch (err) { return { launched: false, message: `electron launch failed: ${err instanceof Error ? err.message : String(err)}`, } } } export const electronDriver: Driver = { id: 'electron', name: 'electron', description: 'rnx desktop companion app (native window, menu bar)', kind: 'native', availability: probe, launch, }