{"record":{"id":"28f518b329037f13","repo":"jackwener/OpenCLI","slug":"chatgpt-desktop-integration-requires-macos-osascr-28f518","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/read.js","lineNumber":17,"sourceCode":"import { execSync } from 'node:child_process';\nimport { cli, Strategy } from '@jackwener/opencli/registry';\nimport { CommandExecutionError, ConfigError, getErrorMessage } from '@jackwener/opencli/errors';\nimport { getVisibleChatMessages } from './ax.js';\nexport const readCommand = cli({\n    site: 'chatgpt-app',\n    name: 'read',\n    access: 'read',\n    description: 'Read the last visible message from the focused ChatGPT Desktop window',\n    domain: 'localhost',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [],\n    columns: ['Role', 'Text'],\n    func: async () => {\n        if (process.platform !== 'darwin') {\n            throw new ConfigError('ChatGPT Desktop integration requires macOS (osascript is not available on this platform)');\n        }\n        try {\n            execSync(\"osascript -e 'tell application \\\"ChatGPT\\\" to activate'\");\n            execSync(\"osascript -e 'delay 0.3'\");\n            const messages = getVisibleChatMessages();\n            if (!messages.length) {\n                return [{ Role: 'System', Text: 'No visible chat messages were found in the current ChatGPT window.' }];\n            }\n            return [{ Role: 'Assistant', Text: messages[messages.length - 1] }];\n        }\n        catch (err) {\n            throw new CommandExecutionError(\"Failed to read from ChatGPT: \" + getErrorMessage(err));\n        }\n    },\n});\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatgpt-app/read.js#L1-L33","documentation":"The `chatgpt-app read` command reads visible messages from the ChatGPT Desktop app via AppleScript/Accessibility APIs, which only exist on macOS. It throws this ConfigError immediately when `process.platform !== 'darwin'` since osascript is unavailable elsewhere.","triggerScenarios":"Running `opencli chatgpt-app read` on Linux or Windows; the platform guard at the top of readCommand throws before any osascript call.","commonSituations":"Same as [600]: Linux CI, containers, WSL; or users intending the browser-based `chatgpt read` but typing `chatgpt-app read`.","solutions":["Run on macOS with the ChatGPT Desktop app installed","Use the browser-based `chatgpt` read/ask commands on non-macOS platforms","Check process.platform before invoking chatgpt-app commands in scripts"],"exampleFix":"// before\nconst out = execSync('opencli chatgpt-app read');\n// after\nconst out = process.platform === 'darwin'\n  ? execSync('opencli chatgpt-app read')\n  : execSync('opencli chatgpt read');","handlingStrategy":"validation","validationCode":"if (process.platform !== 'darwin') {\n  console.error('chatgpt-app read requires macOS; falling back to browser chatgpt');\n  process.exitCode = 1;\n}","typeGuard":"const isMacOS = (): boolean => process.platform === 'darwin';","tryCatchPattern":"try {\n  const out = execSync('opencli chatgpt-app read').toString();\n} catch (e) {\n  if (String(e.message).includes('requires macOS')) {\n    const out = execSync('opencli chatgpt read').toString(); // browser fallback\n  } else throw e;\n}","preventionTips":["Gate chatgpt-app calls on process.platform === 'darwin'","Use `chatgpt read` for Linux/Windows environments","Keep a single platform-conditional helper for all desktop-app automation"],"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"}