jackwener/OpenCLI · error · ConfigError

ChatGPT Desktop integration requires macOS (osascript is not

Error message

ChatGPT Desktop integration requires macOS (osascript is not available on this platform)

What it means

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.

Source

Thrown at clis/chatgpt-app/read.js:17

import { execSync } from 'node:child_process';
import { cli, Strategy } from '@jackwener/opencli/registry';
import { CommandExecutionError, ConfigError, getErrorMessage } from '@jackwener/opencli/errors';
import { getVisibleChatMessages } from './ax.js';
export const readCommand = cli({
    site: 'chatgpt-app',
    name: 'read',
    access: 'read',
    description: 'Read the last visible message from the focused ChatGPT Desktop window',
    domain: 'localhost',
    strategy: Strategy.PUBLIC,
    browser: false,
    args: [],
    columns: ['Role', 'Text'],
    func: async () => {
        if (process.platform !== 'darwin') {
            throw new ConfigError('ChatGPT Desktop integration requires macOS (osascript is not available on this platform)');
        }
        try {
            execSync("osascript -e 'tell application \"ChatGPT\" to activate'");
            execSync("osascript -e 'delay 0.3'");
            const messages = getVisibleChatMessages();
            if (!messages.length) {
                return [{ Role: 'System', Text: 'No visible chat messages were found in the current ChatGPT window.' }];
            }
            return [{ Role: 'Assistant', Text: messages[messages.length - 1] }];
        }
        catch (err) {
            throw new CommandExecutionError("Failed to read from ChatGPT: " + getErrorMessage(err));
        }
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Run on macOS with the ChatGPT Desktop app installed
  2. Use the browser-based `chatgpt` read/ask commands on non-macOS platforms
  3. Check process.platform before invoking chatgpt-app commands in scripts

Example fix

// before
const out = execSync('opencli chatgpt-app read');
// after
const out = process.platform === 'darwin'
  ? execSync('opencli chatgpt-app read')
  : execSync('opencli chatgpt read');
Defensive patterns

Strategy: validation

Validate before calling

if (process.platform !== 'darwin') {
  console.error('chatgpt-app read requires macOS; falling back to browser chatgpt');
  process.exitCode = 1;
}

Type guard

const isMacOS = (): boolean => process.platform === 'darwin';

Try / catch

try {
  const out = execSync('opencli chatgpt-app read').toString();
} catch (e) {
  if (String(e.message).includes('requires macOS')) {
    const out = execSync('opencli chatgpt read').toString(); // browser fallback
  } else throw e;
}

Prevention

When it happens

Trigger: Running `opencli chatgpt-app read` on Linux or Windows; the platform guard at the top of readCommand throws before any osascript call.

Common situations: Same as [600]: Linux CI, containers, WSL; or users intending the browser-based `chatgpt read` but typing `chatgpt-app read`.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/28f518b329037f13. Report an issue: GitHub.