Zhenyu98/codex-chatgpt-bridge
codex-chatgpt-bridge is a Codex agent skill plus external PowerShell control scripts (On/Off/Reboot/Rotate) built on top of the open-source DevSpace MCP bridge, which lets ChatGPT act as a planning/review "architect" while Codex stays the local executor that applies and verifies changes. It adds a token-saving router (NORMAL / TOKEN_SAVING / CHATGPT_ARCHITECT modes) and a lifecycle layer — Cloudflare Quick Tunnels or a stable Cloudflare Worker proxy, DPAPI-protected credentials, OAuth token rotation, and a scheduled-task recovery entrypoint — so the bridge's public endpoint can be closed when idle without re-authorizing the ChatGPT app on every restart.
What it claims
This repository is a Codex skill plus PowerShell scripts. It drives DevSpace (@waishnav/devspace from npm), which it uses unmodified rather than forking, patching or proxying it. DevSpace owns the MCP server, OAuth, the file tools and run_shell. This repo adds two things: routing guidance for the agent, and an external lifecycle controller. The controller lets you close the public endpoint when idle without re-linking the ChatGPT app. It is released under the MIT License.
How it works
Routing. The router decides by marginal cost. Work goes to ChatGPT when it saves "far more Codex tokens than the cost of one slow bridge round-trip."
- In CHATGPT_ARCHITECT mode, ChatGPT can also act as the pool for parallel subagents. Codex stays the single orchestrator that integrates and verifies.
- By default, Codex applies every change.
- With an explicit L3 grant, ChatGPT writes over the bridge directly. Codex then reviews the diff, runs an independent check, and owns Git operations.
Lifecycle.
- The controller keeps a non-secret desired-state profile separate from runtime state, so "off on purpose" is recorded rather than guessed.
RebootandRestartare the same mutex-protected transaction: stop, start, refresh Worker KV, then verify the local, Quick Tunnel and Worker endpoints against a 200/401 health contract.Rebootrefuses to reopen a bridge that was stopped withOff.Offkeeps the app's authorization material. OnlyRotaterevokes tokens and mints a new Owner password.- The stable-URL chain is: fixed ChatGPT app URL → Cloudflare Worker (upstream stored in KV) → rotating Quick Tunnel → local DevSpace.
Hardening details.
- The Cloudflare token is stored with DPAPI. The helper verifies an encrypt/decrypt round trip before saving and migrates away any plaintext
cf-api.json.OnandRebootreject plaintext legacy credentials. - A downloaded
cloudflaredbinary must carry a valid Authenticode signature from Cloudflare, Inc. - Public base URLs must be HTTPS, with no embedded credentials, query string or fragment.
- An unrelated process on the configured port is reported and left running; recovery fails instead of killing it.
How to use it
Windows/PowerShell only. Install the skill:
git clone https://github.com/Zhenyu98/codex-chatgpt-bridge.git
cd codex-chatgpt-bridge
powershell -ExecutionPolicy Bypass -File .\install.ps1Installer flags:
- An existing install is moved to a timestamped backup automatically.
-ForceOverwritediscards the installed copy instead.-RegisterRestartTaskadds the optional Reboot task.
Install the upstream bridge, then check the environment (this starts no tunnel):
npm install -g @waishnav/devspace
$skill = "$env:USERPROFILE\.codex\skills\codex-chatgpt-bridge"
powershell -ExecutionPolicy Bypass -File "$skill\scripts\local_bridge.ps1" -Action DoctorSet up a stable Worker:
$controller = "$skill\scripts\bridge_controller.ps1"
powershell -ExecutionPolicy Bypass -File $controller -Action Configure -ProjectRoot "D:\your\project" -Tunnel cloudflare-worker -PublicBaseUrl https://bridge.example.workers.dev -InstallCloudflared
powershell -ExecutionPolicy Bypass -File "$skill\scripts\set_cf_api_config.ps1" -Action Set -AccountId <account-id> -KvNamespaceId <namespace-id>
powershell -ExecutionPolicy Bypass -File $controller -Action OnDay-to-day operation:
- Use
On,Off,Reboot,StatusandDoctoron the controller. - Avoid DevSpace's raw Start/Stop. They bypass the desired-state record and the health checks.
-AllowedRoots "A;B;C"authorizes several roots, stored in profile schema v2.ProjectRootmust sit inside one of them.- The scheduled task (
restart_task.ps1 -Action Install|Run) has no automatic trigger and runs asynchronously. Check%LOCALAPPDATA%\devspace-bridge\controller-result.jsonand then runDoctorto confirm the result.
Limits
- The permission levels are not enforced. L0–L5 are policy that Codex asks ChatGPT to follow; the bridge does not enforce them.
run_shellis not confined to the root. An authorized ChatGPT app effectively has code execution as your local user.- Only three boundaries are enforced:
- OAuth approval with the Owner password (DevSpace).
allowedRoots, which applies to file tools only (DevSpace).- Reachability, closed via
Off(this repo). - The scheduled task is not a security boundary. It runs as the same interactive user, who must be logged on. Real isolation needs a separate least-privilege account with ACL-separated scripts, state, logs and credentials, or a VM.
- Some generated files hold sensitive details:
worker-proxy.jsonholds the Worker URL and KV namespace ID; keep it out of git.- Controller logs contain paths, PIDs and tunnel URLs; redact them before sharing.
- Shell-command logging is off by default. Set
DEVSPACE_LOG_SHELL_COMMANDS=trueif you need an audit trail. - Broad roots are flagged.
Doctor.securityWarningsflags drive roots, the user profile, and its ancestors. - Raw Quick Tunnel URLs suit smoke tests only. They rotate on every restart, so a saved app needs a Worker or other stable proxy.
- No token-savings figures are given. The page publishes no measurements to back up its routing claims.
Organisations named here
- Cloudflare, Inc.
- LINUX.DO
- OpenAI
- Claude Code
- Cloudflare
- Cursor
Technologies named here
- ChatGPT
- DevSpace
- Codex
- codex-chatgpt-bridge
- Cloudflare Tunnel
- Cloudflare Worker
- Claude Code
- Cursor
- Model Context Protocol
- Cloudflare
- Node.js
Techniques named here
- Marginal-cost task routing
- Desired-state vs runtime-state separation
- Mutex-protected Restart/Reboot transaction
- Layered stable-endpoint fronting
- DPAPI credential protection
- L0–L5 permission levels
Related in coding-agents
