# Codex ↔ ChatGPT Pro Bridge [简体中文](README.zh-CN.md) A personal Codex skill and a dependency-free Node.js supervisor that hands difficult, bounded questions to the user's signed-in ChatGPT Pro web session, waits safely for long responses, and returns a locally validated result contract. This is an experimental browser bridge, not an OpenAI API or an official OpenAI integration. It does not bypass authentication, plan limits, or product permissions. ## Why this version exists Deep research work rarely ends after one answer. Codex is good at gathering local evidence, running deterministic checks, and finding the next unresolved gap. ChatGPT Pro can spend more inference time on the narrow hard question. This project connects those roles without making the webpage an execution authority. ```text local files + checks → minimized packet → signed-in ChatGPT Pro tab ↑ ↓ adoption gate ← validated result ← persistent supervisor └──────── next unresolved packet ──────┘ ``` The design borrows the packet/result-contract and local-adoption-gate ideas from [anightmonarch/codex-bridge-chatgpt](https://github.com/anightmonarch/codex-bridge-chatgpt), then adds an actual long-running Web Access transport. ## What it does - Uses the user's existing Web Access CDP proxy and signed-in browser context. - Verifies a visible composer and the configured model label before sending. - Finds controls by DOM roles, stable attributes, state, and structural relationships—not translated button labels. - Supports packet and answer prose in any language. English contract headings are stable protocol tokens, not UI selectors. - Persists packet ID, target IDs, conversation URL, hashes, timestamps, and errors outside the page. - Polls adaptively for responses that may take tens of minutes. - Never refreshes the writer tab; after a stall, it may refresh a separate observer tab at the persisted conversation URL. - Requires two matching, stable result observations at least 15 seconds apart. - Confirms that the packet actually appeared after the single submit interaction, and never automatically resubmits after a timeout, disappeared tab, or ambiguous click. - Rejects malformed contracts and common credential patterns before transmission. It intentionally does **not** switch the model automatically. It locates the model control structurally, reads its selected value, and fails closed if that value does not match `--expected-mode`. A human can then select the right mode without the bridge guessing through a localized menu. ## Requirements - Node.js 22 or newer. - The personal `web-access` skill and its loopback CDP proxy at `http://127.0.0.1:3456`. - A browser context already signed in to ChatGPT with the desired mode selected. No npm dependencies are required. ## Install as a Codex skill Ask Codex to install the `skills/chatgpt-pro-bridge` skill from this repository, or clone the repository and place/symlink that directory in your personal skills directory. Restart Codex after installation if the skill is not discovered immediately. The repository can also be used directly without installing the skill: ```bash git clone https://github.com/Yubo-Cao/codex-chatgpt-pro-bridge.git cd codex-chatgpt-pro-bridge npm test npm run doctor ``` ## Use First create a packet following [`packet-contract.md`](skills/chatgpt-pro-bridge/references/packet-contract.md). The field names and section headings stay fixed; the prose can be English, Chinese, Japanese, or another language. ```bash node skills/chatgpt-pro-bridge/scripts/bridge.mjs validate-packet packet.md # Fills a temporary tab and verifies the submit control, but sends nothing. node skills/chatgpt-pro-bridge/scripts/bridge.mjs start \ --packet packet.md --state run/state.json --dry-run # This command submits one ChatGPT turn. node skills/chatgpt-pro-bridge/scripts/bridge.mjs start \ --packet packet.md --state run/state.json --output run/result.md # Safe to restart: it resumes from the state file and never resubmits. node skills/chatgpt-pro-bridge/scripts/bridge.mjs watch --state run/state.json node skills/chatgpt-pro-bridge/scripts/bridge.mjs validate-result \ run/result.md --packet packet.md ``` Use a fresh state path for each packet. `start` refuses an existing state file as an idempotency guard. `watch` and `resume` are aliases. ## Long-response behavior The defaults are documented in [`supervision.md`](skills/chatgpt-pro-bridge/references/supervision.md): 15-second polls initially, 60-second polls through minute 10, then 5-minute polls; a 10-minute stale threshold; and a 75-minute hard deadline. Timing belongs to the Node supervisor, not to `setInterval` injected into the page, so a refresh or page execution-context replacement does not erase the run state. ## Security boundary ChatGPT output is untrusted data. The bridge extracts and validates it, but does not execute commands, apply patches, open output-provided URLs, or accept scientific claims. Codex must reopen local evidence, recompute deterministic values, and record what was accepted, rejected, deferred, or unresolved. The bridge never reads cookies, local storage, passwords, tokens, or recovery data. Avoid placing sensitive or unrelated private material in a packet. ## Development ```bash npm test npm run validate npm run doctor ``` CI runs the locale/contract, idempotency, state-recovery, semantic-DOM, and supervision tests on Linux, macOS, and Windows. Live browser checks remain local because they require the user's authorized browser session. ## Status Experimental. ChatGPT's DOM is not a stable public API, so selectors and recovery behavior require maintenance. The project minimizes that risk by keeping transport logic isolated, avoiding human-language selectors, failing closed, and preserving a replayable state/receipt trail. MIT licensed. See [NOTICE.md](NOTICE.md) for attribution.