import { execSync } from 'child_process';
import { ensureProductionServer } from '../utils/ensure-server.js';
export async function jarvisCommand() {
    const port = process.env.PORT ?? '3001';
    const url = `http://localhost:${port}/jarvis`;
    await ensureProductionServer(port);
    console.log(`Opening Jarvis assistant at ${url}`);
    const platform = process.platform;
    try {
        if (platform === 'darwin') {
            execSync(`open ${url}`);
        }
        else if (platform === 'linux') {
            execSync(`xdg-open ${url}`);
        }
        else if (platform === 'win32') {
            execSync(`start ${url}`);
        }
    }
    catch {
        console.log(`Could not open browser. Visit ${url} manually.`);
    }
}
