{"record":{"id":"a0f806fb8de22039","repo":"jackwener/OpenCLI","slug":"chatgpt-desktop-integration-requires-macos-osascr-a0f806","errorCode":null,"errorMessage":"ChatGPT Desktop integration requires macOS (osascript is not available on this platform)","messagePattern":"ChatGPT Desktop integration requires macOS \\(osascript is not available on this platform\\)","errorType":"validation","errorClass":"ConfigError","httpStatus":null,"severity":"error","filePath":"clis/chatgpt-app/send.js","lineNumber":19,"sourceCode":"import { cli, Strategy } from '@jackwener/opencli/registry';\nimport { CommandExecutionError, ConfigError, getErrorMessage } from '@jackwener/opencli/errors';\nimport { activateChatGPT, selectModel, MODEL_CHOICES, sendPrompt } from './ax.js';\nexport const sendCommand = cli({\n    site: 'chatgpt-app',\n    name: 'send',\n    access: 'write',\n    description: 'Send a message to the active ChatGPT Desktop App window',\n    domain: 'localhost',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'text', required: true, positional: true, help: 'Message to send' },\n        { name: 'model', required: false, help: 'Model/mode to use: auto, instant, thinking, 5.2-instant, 5.2-thinking', choices: MODEL_CHOICES },\n    ],\n    columns: ['Status'],\n    func: async (kwargs) => {\n        if (process.platform !== 'darwin') {\n            throw new ConfigError('ChatGPT Desktop integration requires macOS (osascript is not available on this platform)');\n        }\n        const text = kwargs.text;\n        const model = kwargs.model;\n        try {\n            // Switch model before sending if requested\n            if (model) {\n                activateChatGPT();\n                selectModel(model);\n            }\n            activateChatGPT();\n            sendPrompt(text);\n            return [{ Status: 'Success' }];\n        }\n        catch (err) {\n            throw new CommandExecutionError(\"Failed to send ChatGPT message: \" + getErrorMessage(err));\n        }\n    },\n});","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatgpt-app/send.js#L1-L37","documentation":"The `chatgpt-app send` command sends a message into the ChatGPT Desktop app via AppleScript, macOS-only. It throws this ConfigError up front when `process.platform !== 'darwin'`, before the message text is used, because osascript is not available on other platforms.","triggerScenarios":"Running `opencli chatgpt-app send \"text\"` (optionally with --model) on Linux or Windows; the platform guard throws before selectModel/activateChatGPT/sendPrompt.","commonSituations":"Automations/scheduled jobs on Linux servers; developers mixing up `chatgpt send` (browser) and `chatgpt-app send` (desktop).","solutions":["Run on macOS with ChatGPT Desktop installed","Use browser-based `chatgpt send`/`ask` on non-macOS platforms","Route the call conditionally on process.platform in automation scripts"],"exampleFix":"// before\nexecSync(`opencli chatgpt-app send \"${msg}\"`);\n// after\nif (process.platform === 'darwin') execSync(`opencli chatgpt-app send \"${msg}\"`);\nelse execSync(`opencli chatgpt ask \"${msg}\"`);","handlingStrategy":"validation","validationCode":"if (process.platform !== 'darwin') {\n  throw new Error('chatgpt-app send requires macOS');\n}\nconst MODEL_CHOICES = ['auto','instant','thinking','5.2-instant','5.2-thinking'];\nif (model && !MODEL_CHOICES.includes(model)) throw new Error(`invalid model: ${model}`);","typeGuard":"const isMacOS = (): boolean => process.platform === 'darwin';","tryCatchPattern":"try {\n  execSync(`opencli chatgpt-app send \"${text}\"`);\n} catch (e) {\n  if (String(e.message).includes('requires macOS')) {\n    execSync(`opencli chatgpt ask \"${text}\"`); // cross-platform fallback\n  } else throw e;\n}","preventionTips":["Validate --model against MODEL_CHOICES before invoking","Gate desktop-app sends on darwin platform","Test sends with the app in the foreground before scheduling unattended jobs"],"tags":["macos","platform-check","config-error","desktop-app"],"backgroundTag":"unsupported-platform","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}