status.js
1 import { execSync } from 'node:child_process'; 2 import { cli, Strategy } from '@jackwener/opencli/registry'; 3 import { CommandExecutionError, ConfigError } from '@jackwener/opencli/errors'; 4 export const statusCommand = cli({ 5 site: 'chatgpt-app', 6 name: 'status', 7 description: 'Check if ChatGPT Desktop App is running natively on macOS', 8 domain: 'localhost', 9 strategy: Strategy.PUBLIC, 10 browser: false, 11 args: [], 12 columns: ['Status'], 13 func: async (page) => { 14 if (process.platform !== 'darwin') { 15 throw new ConfigError('ChatGPT Desktop integration requires macOS (osascript is not available on this platform)'); 16 } 17 try { 18 const output = execSync("osascript -e 'application \"ChatGPT\" is running'", { encoding: 'utf-8' }).trim(); 19 return [{ Status: output === 'true' ? 'Running' : 'Stopped' }]; 20 } 21 catch { 22 throw new CommandExecutionError('Error querying ChatGPT application state'); 23 } 24 }, 25 });