9b395f5cc3
Build Chrome Extension / build (push) Waiting to run
Trigger Website Rebuild (Docs Updated) / dispatch (push) Waiting to run
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
38 lines
1.5 KiB
JavaScript
38 lines
1.5 KiB
JavaScript
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
import { CommandExecutionError, ConfigError, getErrorMessage } from '@jackwener/opencli/errors';
|
|
import { activateChatGPT, selectModel, MODEL_CHOICES, sendPrompt } from './ax.js';
|
|
export const sendCommand = cli({
|
|
site: 'chatgpt-app',
|
|
name: 'send',
|
|
access: 'write',
|
|
description: 'Send a message to the active ChatGPT Desktop App window',
|
|
domain: 'localhost',
|
|
strategy: Strategy.PUBLIC,
|
|
browser: false,
|
|
args: [
|
|
{ name: 'text', required: true, positional: true, help: 'Message to send' },
|
|
{ name: 'model', required: false, help: 'Model/mode to use: auto, instant, thinking, 5.2-instant, 5.2-thinking', choices: MODEL_CHOICES },
|
|
],
|
|
columns: ['Status'],
|
|
func: async (kwargs) => {
|
|
if (process.platform !== 'darwin') {
|
|
throw new ConfigError('ChatGPT Desktop integration requires macOS (osascript is not available on this platform)');
|
|
}
|
|
const text = kwargs.text;
|
|
const model = kwargs.model;
|
|
try {
|
|
// Switch model before sending if requested
|
|
if (model) {
|
|
activateChatGPT();
|
|
selectModel(model);
|
|
}
|
|
activateChatGPT();
|
|
sendPrompt(text);
|
|
return [{ Status: 'Success' }];
|
|
}
|
|
catch (err) {
|
|
throw new CommandExecutionError("Failed to send ChatGPT message: " + getErrorMessage(err));
|
|
}
|
|
},
|
|
});
|