diff --git a/docs/adapters/desktop/codex.md b/docs/adapters/desktop/codex.md index e338b587c..cd045c80a 100644 --- a/docs/adapters/desktop/codex.md +++ b/docs/adapters/desktop/codex.md @@ -8,13 +8,13 @@ Control the **OpenAI Codex Desktop App** headless or headfully via Chrome DevToo 2. Launch it via the terminal and expose the remote debugging port: ```bash # macOS - /Applications/Codex.app/Contents/MacOS/Codex --remote-debugging-port=9222 + /Applications/Codex.app/Contents/MacOS/Codex --remote-debugging-port=9238 ``` ## Setup ```bash -export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9222" +export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9238" ``` ## Commands diff --git a/docs/advanced/electron.md b/docs/advanced/electron.md index 13dcaeae8..60b33ec83 100644 --- a/docs/advanced/electron.md +++ b/docs/advanced/electron.md @@ -14,7 +14,7 @@ Electron apps are essentially local Chromium browser instances. By exposing a de ### Launching the Target App ```bash -/Applications/AppName.app/Contents/MacOS/AppName --remote-debugging-port=9222 +/Applications/AppName.app/Contents/MacOS/AppName --remote-debugging-port= ``` ### Verifying Electron @@ -82,7 +82,7 @@ await page.wait(1); // Wait for re-render ## Environment Variable ```bash -export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9222" +export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:" ``` ## Non-Electron Pattern (AppleScript) @@ -108,7 +108,7 @@ Core techniques: ## Pitfalls & Gotchas -1. **Port conflicts (EADDRINUSE)**: Only one app per port. Use unique ports: Codex=9222, ChatGPT=9224, Cursor=9226, ChatWise=9228, Discord=9232 +1. **Port conflicts (EADDRINUSE)**: Only one app per port. Use unique ports matching the builtin registry: Codex=9238, Doubao=9225, Cursor=9226, ChatWise=9228, Discord=9232, Antigravity=9234, ChatGPT=9236. Avoid `9222`, the default Chrome DevTools port the opencli browser bridge already binds. 2. **IPage abstraction**: OpenCLI wraps the browser page as `IPage` (`src/types.ts`). Use `page.pressKey()` and `page.evaluate()`, NOT direct DOM APIs 3. **Timing**: Always add `await page.wait(0.5)` to `1.0` after DOM mutations. Returning too early disconnects prematurely 4. **AppleScript requires Accessibility**: Terminal app must be granted permission in System Settings → Privacy & Security → Accessibility @@ -117,8 +117,10 @@ Core techniques: | App | Port | Mode | |-----|------|------| -| Codex | 9222 | CDP | -| ChatGPT | 9224 | CDP / AppleScript | +| Codex | 9238 | CDP | +| Doubao | 9225 | CDP | | Cursor | 9226 | CDP | | ChatWise | 9228 | CDP | | Discord App | 9232 | CDP | +| Antigravity | 9234 | CDP | +| ChatGPT | 9236 | CDP / AppleScript | diff --git a/docs/guide/electron-app-cli.md b/docs/guide/electron-app-cli.md index 956f7fdd1..0c1777ace 100644 --- a/docs/guide/electron-app-cli.md +++ b/docs/guide/electron-app-cli.md @@ -35,13 +35,13 @@ If Electron is present, the next step is usually to launch the app with a debugg ### 2. Launch it with CDP enabled ```bash -/Applications/AppName.app/Contents/MacOS/AppName --remote-debugging-port=9222 +/Applications/AppName.app/Contents/MacOS/AppName --remote-debugging-port= ``` Then point OpenCLI at that CDP endpoint: ```bash -export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9222" +export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:" ``` ### 3. Start with the 5-command pattern diff --git a/docs/zh/guide/electron-app-cli.md b/docs/zh/guide/electron-app-cli.md index 45c71e10a..e492d04c4 100644 --- a/docs/zh/guide/electron-app-cli.md +++ b/docs/zh/guide/electron-app-cli.md @@ -31,13 +31,13 @@ ls /Applications/AppName.app/Contents/Frameworks/Electron\ Framework.framework ### 2. 带 CDP 端口启动应用 ```bash -/Applications/AppName.app/Contents/MacOS/AppName --remote-debugging-port=9222 +/Applications/AppName.app/Contents/MacOS/AppName --remote-debugging-port= ``` 然后把 OpenCLI 指到这个端口: ```bash -export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9222" +export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:" ``` ### 3. 先做 5 个基础命令 diff --git a/src/electron-apps.test.ts b/src/electron-apps.test.ts index cbe01fce4..9d07138a4 100644 --- a/src/electron-apps.test.ts +++ b/src/electron-apps.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest'; -import { getElectronApp, isElectronApp, loadApps } from './electron-apps.js'; +import { builtinApps, getElectronApp, isElectronApp, loadApps } from './electron-apps.js'; describe('electron-apps registry', () => { it('returns builtin app entry for cursor', () => { @@ -12,7 +12,14 @@ describe('electron-apps registry', () => { it('returns builtin app entry for codex', () => { const app = getElectronApp('codex'); expect(app).toBeDefined(); - expect(app!.port).toBe(9222); + expect(app!.port).toBe(9238); + }); + + it('keeps builtin Electron app CDP ports unique and off the browser-bridge port', () => { + const ports = Object.values(builtinApps).map((app) => app.port); + + expect(new Set(ports).size).toBe(ports.length); + expect(ports).not.toContain(9222); }); it('returns undefined for non-Electron sites', () => { diff --git a/src/electron-apps.ts b/src/electron-apps.ts index 9eb061de2..8f5089600 100644 --- a/src/electron-apps.ts +++ b/src/electron-apps.ts @@ -27,7 +27,7 @@ export interface ElectronAppEntry { export const builtinApps: Record = { cursor: { port: 9226, processName: 'Cursor', bundleId: 'com.todesktop.runtime.Cursor', displayName: 'Cursor' }, - codex: { port: 9222, processName: 'Codex', bundleId: 'com.openai.codex', displayName: 'Codex' }, + codex: { port: 9238, processName: 'Codex', bundleId: 'com.openai.codex', displayName: 'Codex' }, chatwise: { port: 9228, processName: 'ChatWise', bundleId: 'com.chatwise.app', displayName: 'ChatWise' }, 'discord-app': { port: 9232, processName: 'Discord', bundleId: 'com.discord.app', displayName: 'Discord' }, 'doubao-app': { port: 9225, processName: 'Doubao', bundleId: 'com.volcengine.doubao', displayName: 'Doubao' },