import { tspmIpcClient } from '../../client/tspm.ipcclient.js'; /** * Preflight the daemon if required. Uses getDaemonStatus() which is safe and cheap: * it only connects if the PID file is valid. */ export async function ensureDaemonOrHint( requireDaemon: boolean | undefined, actionLabel?: string, ): Promise { if (requireDaemon === false) return true; // command does not require daemon const status = await tspmIpcClient.getDaemonStatus(); if (!status) { // Same hint as handleDaemonError, but early and consistent console.error( `Error: Cannot ${actionLabel || 'perform action'} - TSPM daemon is not running.`, ); console.log('\nTo start the daemon, run one of:'); console.log(' tspm daemon start - Start for this session only'); console.log( ' tspm enable - Enable as system service (recommended)', ); return false; } return true; }