# BridgeDEF ## Durable Exchange Fabric for the ChatGPT Web you already use. BridgeDEF (Durable Exchange Fabric) is a local-first, open-source runtime for connecting a local agent session to one or more selected, authenticated ChatGPT Web conversations — without API keys, a second browser, or copy-paste handoffs. It is deliberately narrow and opinionated: the local agent owns execution, the visible browser remains the cloud conversation surface, and BridgeDEF owns only reliable routing, delivery, observation, and recovery. > **Best fit:** workflows where a local agent must ask ChatGPT Web for > research or decisions, preserve the complete answer, and continue working > after long generations, browser reloads, or process restarts. ## Why BridgeDEF exists Most browser bridges optimize for controlling pages. BridgeDEF optimizes for the boundary between two agent runtimes. That changes the design priorities: - **Dynamic routing.** Register any number of local agents and map each one to one or many conversations. There are no hard-coded agent slots. - **Opaque payloads.** Text is transferred as bytes. No markers, envelopes, semantic filters, rewrites, or hidden protocol are inserted into the chat. - **Durable correlation.** Every request has a local message ID and every response records the request it answers. This makes concurrent mappings auditable instead of order-dependent. - **Evidence-based completion.** A non-empty DOM fragment is not promoted to a final answer. The observer waits for a changed assistant turn, technical quiescence, and conversation-record reconciliation when available. - **Recoverable operation.** Mailbox state persists locally. Ambiguous uploads fail closed instead of being silently resent; observations can resume after a daemon restart. - **Attachments included.** Local-to-Web and Web-to-local transfers use bounded chunks with size, order, and SHA-256 verification. - **One runtime.** A single supervisor owns the daemon and browser gateway, preventing competing daemons, ports, or extension transports. - **Local-first boundary.** The control plane uses a Unix socket and the browser adapter connects only to localhost. No hosted relay is required. These are concrete design claims, not a claim that one tool is universally best. BridgeDEF is strongest when routing, fidelity, recovery, and a visible ChatGPT Web conversation matter more than broad multi-site browser control. ## Architecture ```text local agent(s) │ Unix socket ▼ BridgeDEF daemon ── persistent mailbox + registry + response observer │ localhost WebSocket ▼ Manifest V3 extension ── Chrome debugger API ── selected ChatGPT Web tabs ``` The extension is intentionally small. It does not call a model API. The authenticated browser session is used only through the visible ChatGPT Web tab selected by a local mapping. ## Quick start ### Requirements - Linux with Python 3.11+; - Google Chrome or Chromium; - the `websockets` Python package; - an authenticated ChatGPT Web session. ### Install ```bash git clone https://github.com/OWNER/BridgeDEF.git cd BridgeDEF python3 -m venv .venv . .venv/bin/activate python -m pip install -r requirements.txt ``` Load `extension/` as an unpacked extension from `chrome://extensions` with Developer mode enabled. Copy the extension ID shown by Chrome, then register the Native Messaging host: ```bash python install_native_host.py --extension-id YOUR_EXTENSION_ID ``` Start the single local runtime: ```bash python bridgedef_runtime.py serve ``` The runtime keeps state in `state/`, which is ignored by Git and must remain local. For a persistent user service, adapt [`deploy/bridgedef.service`](deploy/bridgedef.service) to the directory where you installed the project. ### Register an agent and a conversation Use stable, local identifiers chosen by your own workflow: ```bash python bridge.py init python bridge.py agent-add local-agent \ --name "Local Agent" \ --session-id "desktop-session-1" \ --project-dir "/path/to/your/project" python bridge.py mapping-add local-agent \ "https://chatgpt.com/c/CONVERSATION_ID" \ --mapping-id research-chat ``` To let BridgeDEF create a new ChatGPT Web conversation in the background: ```bash python bridge.py mapping-new local-agent --mapping-id research-chat ``` Send an exact text payload and keep the returned request ID: ```bash python bridge.py agent-send local-agent research-chat request.txt python bridge.py agent-receive local-agent research-chat \ --for-message-id MESSAGE_ID \ --wait-seconds 600 \ --output response.txt ``` The explicit `--for-message-id` form is recommended when more than one mapping is active. See [`AGENT_RUNBOOK.md`](AGENT_RUNBOOK.md) for recovery, diagnostics, concurrency, and attachment workflows. ## Test The automated suite uses synthetic payloads and does not require a browser or an account: ```bash python -m unittest -v ``` The repository includes unit coverage for dynamic routing, persistence, opaque byte framing, chunk validation, response completion decisions, and attachment assembly. Browser behavior remains sensitive to changes in the ChatGPT Web UI and should be tested manually after installing the extension. ## Comparison: a precise claim, not hype The projects below are valuable reference points, but they optimize for different jobs. The comparison is based on their public repositories and documentation, not on a common benchmark. | Project | Primary focus | Where BridgeDEF differs | | --- | --- | --- | | [browser-bridge](https://github.com/whg517/browser-bridge) | Broad MCP control of an already-authenticated Chrome, including many page capabilities | BridgeDEF is narrower: it treats the selected ChatGPT conversation as a durable, correlated endpoint and keeps payloads opaque | | [chrome-agent-bridge](https://github.com/escapeWu/chrome-agent-bridge) | User-approved Chrome Native Messaging to MCP browser automation | BridgeDEF centers on local-agent ↔ ChatGPT Web mailbox semantics, not a general browser tool surface | | [chatgpt-bridge](https://github.com/DrA1ex/chatgpt-bridge) | HTTP/OpenAI-shaped API, sessions, files, artifacts, and normalized UI events | BridgeDEF favors a smaller Python runtime, a dynamic registry, fail-closed recovery, and explicit message correlation | | [council-bridge](https://github.com/christopherdent/council-bridge) | Deterministic handoffs between assigned ChatGPT and Gemini conversations | BridgeDEF is a general local-agent routing layer with one-to-many mappings and attachment transport | | [OpenBrowser](https://github.com/1129Aliasgar/OpenBrowser) | Local coding agent across several browser AI providers | BridgeDEF is intentionally ChatGPT Web-specific and focuses on transport integrity and recovery rather than a multi-provider CLI | | [chatgpt-use](https://github.com/leeguooooo/chatgpt-use) | Use a browser ChatGPT subscription as a coding-agent backend | BridgeDEF separates the transport from agent policy and keeps the local mailbox usable by independent agent runtimes | | [ChatGPT API Bridge](https://github.com/Zetaphor/chatgpt-api-bridge) | WebSocket access to the ChatGPT interface through a browser extension | BridgeDEF adds persistent registry, targeted correlation, long-turn observation, and restart-safe state | | [OLmatter/chatgpt-bridge](https://github.com/OLmatter/chatgpt-bridge) | Local HTTP bridge and GUI monitor for multiple ChatGPT tabs | BridgeDEF is smaller in surface area and makes opaque payloads, one runtime ownership, and fail-closed recovery first-class | | [ai-browser-bridge](https://github.com/YosefHayim/ai-browser-bridge) | Local terminal/MCP bridge to browser AI chats | BridgeDEF concentrates on a durable local control plane for multiple mapped agent sessions and verifiable response acquisition | The concise positioning is: > **If you need a general browser, choose a general browser bridge. If you > need a reliable local-agent conversation transport for ChatGPT Web, start > with BridgeDEF.** ## Security and scope BridgeDEF can operate an authenticated browser tab, so treat it as privileged local software. Read [`SECURITY.md`](SECURITY.md) before installation. Important boundaries: - BridgeDEF is not affiliated with or endorsed by OpenAI. - It is not an official ChatGPT API and depends on the current Web UI. - It does not bypass authentication, quotas, access controls, or safety systems. - It does not include credentials, local state, conversation transcripts, or machine-specific configuration. - Do not point it at sensitive conversations unless you understand the local and remote data flow and the terms that apply to your account. ## Collaboration BridgeDEF is released to be tested, challenged, and improved in public. Good first contributions include: - reproductions against a changed ChatGPT Web UI; - tests for recovery, ordering, and attachment edge cases; - review of the threat model and least-privilege browser permissions; - compatibility reports across Linux distributions and Chromium variants; - adapters or interoperability experiments that preserve the core contracts. Please open an issue before a large redesign. See [`CONTRIBUTING.md`](CONTRIBUTING.md) for the project rules. ## License MIT. See [`LICENSE`](LICENSE).