{"record":{"id":"5d0df30fd9229fda","repo":"jackwener/OpenCLI","slug":"chatgpt-desktop-integration-requires-macos-osascr-5d0df3","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/new.js","lineNumber":19,"sourceCode":"import { execSync } from 'node:child_process';\nimport { cli, Strategy } from '@jackwener/opencli/registry';\nimport { CommandExecutionError, ConfigError, getErrorMessage } from '@jackwener/opencli/errors';\nimport { isTemporaryChatVisible } from './ax.js';\nexport const newCommand = cli({\n    site: 'chatgpt-app',\n    name: 'new',\n    access: 'write',\n    description: 'Open a new chat in ChatGPT Desktop App',\n    domain: 'localhost',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'temp', type: 'boolean', default: false, help: 'Open a temporary chat with privacy protection' }\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        try {\n            execSync(\"osascript -e 'tell application \\\"ChatGPT\\\" to activate'\");\n            execSync(\"osascript -e 'delay 0.5'\");\n            if (kwargs.temp) {\n                const appleScript = [\n                    'tell application \"System Events\"',\n                    '  tell process \"ChatGPT\"',\n                    '    try',\n                    '      click menu item \"新的临时聊天\" of menu \"文件\" of menu bar 1',\n                    '    on error',\n                    '      try',\n                    '        click menu item \"新的臨時聊天\" of menu \"檔案\" of menu bar 1',\n                    '      on error',\n                    '        try',\n                    '          click menu item \"New Temporary Chat\" of menu \"File\" of menu bar 1',\n                    '        on error',\n                    '          error \"Unable to locate Temporary Chat menu item. Ensure Accessibility permissions are granted and the language is supported.\"' ,","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatgpt-app/new.js#L1-L37","documentation":"The `chatgpt-app new` command drives the ChatGPT macOS desktop app via AppleScript (`osascript`), which only exists on macOS. The library throws this ConfigError before doing any work when `process.platform !== 'darwin'`, because the integration cannot function on Linux or Windows.","triggerScenarios":"Running `opencli chatgpt-app new` (with or without --temp) on a non-macOS platform; the guard at the top of newCommand checks process.platform before any osascript call.","commonSituations":"CI runners on Linux, Docker containers, WSL without proper macOS targeting, or developers who confuse the browser-based `chatgpt` commands with the `chatgpt-app` desktop-app commands.","solutions":["Run this command on macOS with the ChatGPT Desktop app installed","Use the browser-based `chatgpt` commands (cookie/browser strategy) on non-macOS platforms","Gate your script: only invoke chatgpt-app subcommands when process.platform === 'darwin'"],"exampleFix":"// before\nawait run('opencli chatgpt-app new --temp');\n// after\nif (process.platform !== 'darwin') await run('opencli chatgpt new --temp');\nelse await run('opencli chatgpt-app new --temp');","handlingStrategy":"validation","validationCode":"if (process.platform !== 'darwin') {\n  throw new Error('chatgpt-app commands require macOS; use browser-based chatgpt commands instead');\n}","typeGuard":"const isMacOS = (): boolean => process.platform === 'darwin';","tryCatchPattern":"try {\n  await run('opencli chatgpt-app new');\n} catch (e) {\n  if (String(e.message).includes('requires macOS')) {\n    await run('opencli chatgpt new'); // fallback path\n  } else throw e;\n}","preventionTips":["Check process.platform === 'darwin' before invoking any chatgpt-app subcommand","Prefer the browser-based `chatgpt` command family for cross-platform scripts","Document platform requirements in your automation entrypoints"],"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"}