codex-web-ui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,372 @@
1
+ <div align="center">
2
+
3
+ # ๐ŸŒ Codex App Web UI Enabler
4
+
5
+ ### ๐Ÿš€ Run OpenAI Codex Desktop in Your Browser โ€” From Any Device ๐Ÿš€
6
+
7
+ [![Shell Script](https://img.shields.io/badge/Shell-Bash-4EAA25?logo=gnubash&logoColor=white&style=for-the-badge)](https://www.gnu.org/software/bash/)
8
+ [![Electron](https://img.shields.io/badge/Electron-Patched-47848F?logo=electron&logoColor=white&style=for-the-badge)](https://www.electronjs.org/)
9
+ [![Platform](https://img.shields.io/badge/Platform-macOS%20%7C%20Linux%20%7C%20Windows-blue?style=for-the-badge&logo=apple)](https://github.com/friuns2/codex-unpacked-toolkit)
10
+ [![License](https://img.shields.io/badge/License-MIT-yellow?style=for-the-badge)](LICENSE)
11
+ [![Status](https://img.shields.io/badge/Status-๐Ÿ”ฅ%20WORKS-brightgreen?style=for-the-badge)](https://github.com/friuns2/codex-unpacked-toolkit)
12
+ [![GitHub stars](https://img.shields.io/github/stars/friuns2/codex-unpacked-toolkit?style=for-the-badge&logo=github&color=gold)](https://github.com/friuns2/codex-unpacked-toolkit/stargazers)
13
+ [![GitHub forks](https://img.shields.io/github/forks/friuns2/codex-unpacked-toolkit?style=for-the-badge&logo=github&color=blue)](https://github.com/friuns2/codex-unpacked-toolkit/network)
14
+
15
+ <br />
16
+
17
+ <img src="https://img.shields.io/badge/โšก_ONE_SCRIPT_TO_RULE_THEM_ALL-black?style=for-the-badge&labelColor=black" />
18
+
19
+ <br />
20
+
21
+ > **Codex Desktop's full UI โ€” chat, skills, file editing, code execution โ€”**
22
+ > **accessible from any browser on any device. No Electron window required.**
23
+ >
24
+ > **One script. Full Web UI. Anywhere.** ๐ŸŒ
25
+
26
+ <br />
27
+
28
+ ```
29
+ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•—
30
+ โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ•šโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘
31
+ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ•šโ–ˆโ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ•‘ โ–ˆโ•— โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘
32
+ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ• โ–ˆโ–ˆโ•”โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ• โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘
33
+ โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ• โ•šโ–ˆโ–ˆโ•— โ•šโ–ˆโ–ˆโ–ˆโ•”โ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ• โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘
34
+ โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•โ•โ•šโ•โ• โ•šโ•โ• โ•šโ•โ•โ•โ•šโ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•โ•โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•
35
+ E N A B L E R
36
+ ```
37
+
38
+ </div>
39
+
40
+ ---
41
+
42
+ ## ๐Ÿคฏ What Is This?
43
+
44
+ OpenAI's Codex Desktop is a powerful AI coding agent โ€” but it's locked inside an Electron window on a single machine. What if you could access it **from any browser, on any device, anywhere on your network?**
45
+
46
+ We reverse-engineered the minified Electron bundle and built scripts that **patch the app at runtime** to expose the full Codex UI over HTTP + WebSocket. The same scripts also unlock a **hidden SSH remote execution engine** that was already compiled into the binary but never wired up.
47
+
48
+ **One command. Full Web UI. Plus SSH remote control. No recompilation.**
49
+
50
+ ---
51
+
52
+ ## ๐Ÿ“ฑ See It In Action โ€” Codex in Your Browser, From Any Device
53
+
54
+ > **Yes, that's a phone. Yes, that's Codex. Yes, it's running on a Mac across the network.**
55
+
56
+ <div align="center">
57
+ <table>
58
+ <tr>
59
+ <td align="center" width="50%">
60
+ <img src="images/mobile-chat-session.jpeg" width="300" />
61
+ <br />
62
+ <b>๐Ÿ’ฌ Live AI Chat Session</b>
63
+ <br />
64
+ <sub>Full Codex conversation running on a Mac, controlled from an Android phone over the network. GPT-5.3-Codex responding in real-time. The address bar says it all: <code>100.107.32.83:5999</code> โ€” that's a remote Mac.</sub>
65
+ </td>
66
+ <td align="center" width="50%">
67
+ <img src="images/mobile-skills-browser.jpeg" width="300" />
68
+ <br />
69
+ <b>๐Ÿงฉ Skills Manager โ€” From Your Pocket</b>
70
+ <br />
71
+ <sub>Browsing and managing Codex skills (Playwright, Oracle Cloud CLI, Three.js, YouTube Search...) from a mobile browser. Full desktop functionality, zero compromises.</sub>
72
+ </td>
73
+ </tr>
74
+ </table>
75
+ </div>
76
+
77
+ > ๐Ÿคฏ **This is not a mockup.** This is a real Codex Desktop instance running on macOS, patched with our Web UI Enabler scripts, accessed from a mobile phone browser over Tailscale. Every feature works โ€” chat, skills, file editing, code execution โ€” all from your pocket.
78
+
79
+ ---
80
+
81
+ ## ๐ŸŒ What Can You Actually Do With This?
82
+
83
+ With the Web UI enabled, Codex breaks free from the Electron window โ€” and with SSH mode unlocked, it reaches **any machine you own**:
84
+
85
+ | ๐ŸŽฏ Use Case | ๐Ÿ’ก Description |
86
+ |---|---|
87
+ | ๐Ÿ“ฑ **Code From Your Phone** | Open Codex in any mobile browser โ€” full chat, skills, file editing, code execution |
88
+ | ๐Ÿ’ป **Use Any Browser** | Chrome, Firefox, Safari, Arc โ€” no Electron install needed on the client |
89
+ | ๐ŸŒ **Access Over the Network** | Tailscale, LAN, VPN โ€” access your Codex instance from anywhere securely |
90
+ | ๐Ÿ–ฅ๏ธ **Control Your Mac Remotely** | SSH into your MacBook from anywhere and let Codex operate it as if you're sitting in front of it |
91
+ | ๐Ÿง **Orchestrate Linux Servers** | Point Codex at your Ubuntu/Debian/Arch boxes and run AI-powered coding sessions remotely |
92
+ | ๐ŸชŸ **Manage Windows via WSL** | Connect through WSL2 SSH and bring Codex intelligence to your Windows dev environment |
93
+ | ๐Ÿ  **Command Your Homelab** | Proxmox, TrueNAS, Raspberry Pi clusters โ€” Codex becomes your AI sysadmin |
94
+ | โ˜๏ธ **Cloud Fleet Management** | AWS EC2, Oracle Cloud, DigitalOcean droplets โ€” manage entire fleets from one Codex window |
95
+ | ๐Ÿ”ง **Web Service Orchestration** | Nginx configs, Docker containers, systemd services โ€” edit and deploy across machines |
96
+ | ๐Ÿงช **Remote CI/CD Pipelines** | Trigger builds, inspect logs, fix failing tests on remote CI runners in real-time |
97
+ | ๐Ÿ“ก **IoT & Edge Devices** | SSH into Raspberry Pis, Jetson Nanos, or any edge device and code directly on them |
98
+ | ๐Ÿ—๏ธ **Multi-Machine Refactoring** | Coordinate code changes across microservices running on different hosts simultaneously |
99
+
100
+ > **TL;DR:** Codex in your browser + SSH to any machine = your entire infrastructure as one AI-powered IDE. ๐Ÿง 
101
+
102
+ ---
103
+
104
+ ## โšก Quick Start
105
+
106
+ ```bash
107
+ # Clone this repo
108
+ git clone https://github.com/friuns2/codex-unpacked-toolkit.git
109
+ cd codex-unpacked-toolkit
110
+
111
+ # ๐ŸŒ Launch the Web UI โ€” access Codex from any browser
112
+ ./launch_codex_webui_unpacked.sh --port 5999
113
+
114
+ # ๐Ÿ”“ Or launch with SSH mode unlocked (connects to your remote host)
115
+ ./launch_codex_unpacked.sh --ssh-host user@your-server.com
116
+ ```
117
+
118
+ Open `http://127.0.0.1:5999/` and you're flying. โœˆ๏ธ
119
+
120
+ ---
121
+
122
+ ## ๐Ÿ“ Project Structure
123
+
124
+ ```
125
+ codex-unpacked-toolkit/
126
+ โ”œโ”€โ”€ ๐ŸŒ launch_codex_webui_unpacked.sh # WebUI mode launcher (browser access)
127
+ โ”œโ”€โ”€ ๐Ÿ”ง launch_codex_unpacked.sh # SSH unlock & debug launcher
128
+ โ”œโ”€โ”€ ๐Ÿ”Œ webui-bridge.js # Browser-side WebSocket โ†” IPC bridge
129
+ โ”œโ”€โ”€ ๐Ÿ“– PROJECT_STATE.md # Living project state & patching reference
130
+ โ”œโ”€โ”€ ๐Ÿ“‚ images/ # Screenshots & proof it works
131
+ โ”‚ โ”œโ”€โ”€ mobile-chat-session.jpeg # Codex chat from mobile phone
132
+ โ”‚ โ””โ”€โ”€ mobile-skills-browser.jpeg # Skills manager from mobile phone
133
+ โ””โ”€โ”€ ๐Ÿ“‚ skills/
134
+ โ””โ”€โ”€ launch-codex-unpacked/
135
+ โ””โ”€โ”€ SKILL.md # Codex skill definition
136
+ ```
137
+
138
+ ---
139
+
140
+ ## ๐ŸŒ `launch_codex_webui_unpacked.sh` โ€” Browser-Based Codex
141
+
142
+ > **The main event.** Run Codex in your browser. No Electron window needed. Access from any device on your network.
143
+
144
+ ### What It Does
145
+
146
+ 1. ๐Ÿ“ฆ **Extracts `app.asar`** โ€” Same unpacking as above
147
+ 2. ๐Ÿ’‰ **Injects WebUI runtime patch** โ€” Embeds a full HTTP server + WebSocket bridge directly into the Electron main process (~800 lines of runtime injection)
148
+ 3. ๐Ÿฉน **Patches renderer bundle** โ€” Fixes a `roots` guard compatibility issue in the React renderer that crashes in WebUI mode
149
+ 4. ๐Ÿ”Œ **Copies `webui-bridge.js`** โ€” Installs the browser-side bridge into the webview directory
150
+ 5. ๐Ÿš€ **Launches headless Electron** โ€” Starts with `--webui` flag, hides all native windows, serves UI over HTTP
151
+ 6. ๐Ÿ” **Optional token auth** โ€” Protect your instance with `--token` for secure remote access
152
+ 7. ๐ŸŒ **Origin allowlist** โ€” Restrict which domains can connect via `--origins`
153
+ 8. ๐Ÿ–ฅ๏ธ **Auto-opens browser** โ€” Polls the server and opens your default browser when ready
154
+
155
+ ### The Injected Runtime Includes
156
+
157
+ - ๐ŸŒ Full HTTP static file server (serves Codex webview assets)
158
+ - ๐Ÿ”„ RFC 6455-compliant WebSocket server (zero dependencies, hand-rolled frame parser)
159
+ - ๐Ÿ”’ Timing-safe token authentication (Bearer, header, query param, and cookie)
160
+ - ๐Ÿ›ก๏ธ Security headers (X-Content-Type-Options, X-Frame-Options, CORP, Referrer-Policy)
161
+ - ๐Ÿ“ก IPC-to-WebSocket bridge (intercepts `webContents.send` and mirrors to all connected clients)
162
+ - ๐Ÿšฆ Rate limiting (5000 messages/minute for local, configurable)
163
+ - ๐Ÿ‘ค Single-client policy (new tab takes over, old tab gets disconnected)
164
+ - ๐Ÿ’‰ SPA fallback with automatic `webui-bridge.js` injection into HTML
165
+
166
+ ### Options
167
+
168
+ ```
169
+ --app <path> Custom Codex.app path
170
+ --port <n> WebUI port (default: 5999)
171
+ --token <value> Auth token for secure access ๐Ÿ”
172
+ --origins <csv> Allowed origins (comma-separated)
173
+ --bridge <path> Custom webui-bridge.js path
174
+ --user-data-dir <path> Chromium user data dir override
175
+ --no-open Don't auto-open browser
176
+ --keep-temp Keep extracted app dir
177
+ ```
178
+
179
+ ### Examples
180
+
181
+ ```bash
182
+ # Basic local access
183
+ ./launch_codex_webui_unpacked.sh
184
+
185
+ # Secure remote access with auth
186
+ ./launch_codex_webui_unpacked.sh --port 8080 --token mysecrettoken
187
+
188
+ # Access from specific origins only
189
+ ./launch_codex_webui_unpacked.sh --origins "https://mysite.com,http://localhost:3000"
190
+ ```
191
+
192
+ ---
193
+
194
+ ## ๐Ÿ”ง `launch_codex_unpacked.sh` โ€” The SSH Unlocker
195
+
196
+ > **Bonus superpower.** This script extracts, patches, and launches Codex with the hidden SSH remote execution feature fully activated.
197
+
198
+ ### What It Does
199
+
200
+ 1. ๐Ÿ“ฆ **Extracts `app.asar`** โ€” Unpacks the Codex Electron bundle into a temp directory using `@electron/asar`
201
+ 2. ๐Ÿ”‘ **Injects SSH host into global state** โ€” Writes your SSH host into `.codex-global-state.json` so the app recognizes it as a configured remote
202
+ 3. ๐Ÿงฌ **Patches the main bundle** โ€” Performs a surgical AST-level patch on the minified `main-*.js` to auto-select the SSH host on startup (finds the startup sequence and rewires it to check `electron-ssh-hosts` first)
203
+ 4. ๐Ÿ” **Enables Node Inspector** โ€” Launches with `--inspect` for live debugging (port 9229 by default)
204
+ 5. ๐ŸŒ **Enables Chromium Remote Debug** โ€” Opens `--remote-debugging-port` (9222) for DevTools Protocol access
205
+ 6. โœ… **SSH preflight check** โ€” Validates connectivity to your host with `BatchMode=yes` and `ConnectTimeout=6` before launching
206
+ 7. ๐Ÿงน **Auto-cleanup** โ€” Temp directory is removed on exit (unless `--keep-temp`)
207
+
208
+ ### Options
209
+
210
+ ```
211
+ --app <path> Custom Codex.app path (default: /Applications/Codex.app)
212
+ --user-data-dir <path> Chromium user data dir override
213
+ --inspect-port <n> Node inspector port (default: 9229)
214
+ --remote-debug-port <n> Chromium remote debug port (default: 9222)
215
+ --ssh-host <user@host> The SSH host to unlock and auto-connect ๐Ÿ”‘
216
+ --no-inspect Disable Node inspector
217
+ --no-remote-debug Disable Chromium remote debugging
218
+ --keep-temp Keep extracted app dir for inspection
219
+ ```
220
+
221
+ ### Example
222
+
223
+ ```bash
224
+ # Unlock SSH to your homelab server with custom ports
225
+ ./launch_codex_unpacked.sh \
226
+ --ssh-host ubuntu@192.168.1.100 \
227
+ --inspect-port 9230 \
228
+ --remote-debug-port 9223
229
+ ```
230
+
231
+ ---
232
+
233
+ ## ๐Ÿ”Œ `webui-bridge.js` โ€” The Browser-Side Bridge
234
+
235
+ > **Makes the browser think it's Electron.** Replaces `window.electronBridge` with a WebSocket-backed implementation.
236
+
237
+ ### What It Does
238
+
239
+ 1. ๐Ÿ” **Detects environment** โ€” Only activates when the native Electron preload bridge is absent
240
+ 2. ๐Ÿ”„ **Establishes WebSocket connection** โ€” Connects to `/ws` with automatic reconnection (exponential backoff, 500ms โ†’ 5s)
241
+ 3. ๐Ÿ“จ **Implements full `electronBridge` API** โ€” `sendMessageFromView`, `sendWorkerMessageFromView`, `subscribeToWorkerMessages`, and more
242
+ 4. ๐Ÿ“ฌ **Message queue** โ€” Buffers outbound messages while disconnected, flushes on reconnect
243
+ 5. ๐Ÿ“ก **Event forwarding** โ€” Translates WebSocket packets into browser `MessageEvent`s that the React app expects
244
+ 6. ๐Ÿ”„ **Worker subscription system** โ€” Manages per-worker callback subscriptions with proper cleanup
245
+ 7. ๐Ÿท๏ธ **Session management** โ€” Emits `client-status-changed` on connect, handles `open-new-instance` redirects
246
+ 8. ๐Ÿ›ก๏ธ **Single-socket guard** โ€” Token-based deduplication prevents ghost connections
247
+
248
+ ---
249
+
250
+ ## ๐Ÿ”ฌ How We Found It โ€” The Investigation
251
+
252
+ > See the full reverse-engineering findings in [`PROJECT_STATE.md` ยง 9](PROJECT_STATE.md#9-ssh-reverse-engineering-findings)
253
+
254
+ We extracted the `app.asar`, deobfuscated the minified bundles, and traced the execution paths. Along the way we discovered a fully-built SSH remote execution engine hidden inside the binary. Here's what we found:
255
+
256
+ | ๐Ÿ”Ž Discovery | ๐Ÿ“ Detail |
257
+ |---|---|
258
+ | **Remote host detection** | Activates when host config `kind` is `ssh` or `brix` |
259
+ | **Command execution** | Builds args from `hostConfig.terminal_command`, appends `--`, env vars, and command |
260
+ | **SSH wrapper** | Wraps commands in `sh -lc <quoted>` with `-o BatchMode=yes -o ConnectTimeout=10` |
261
+ | **Git over SSH** | Routes git commands through remote shell with `GIT_TERMINAL_PROMPT=0` |
262
+ | **Remote git apply** | Full flow: `mktemp -d` โ†’ `cat > patch` โ†’ `test -e` โ†’ `git apply --3way` โ†’ `rm -rf` |
263
+ | **Codex home resolution** | Checks `$CODEX_HOME`, falls back to `$HOME/.codex` |
264
+
265
+ **All of this was already compiled into the app. We just wired it up.** โšก
266
+
267
+ ---
268
+
269
+ ## ๐Ÿ—๏ธ Architecture
270
+
271
+ ```
272
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
273
+ โ”‚ YOUR BROWSER โ”‚
274
+ โ”‚ โ”‚
275
+ โ”‚ webui-bridge.js โ”‚
276
+ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
277
+ โ”‚ โ”‚ window.electronBridge (fake) โ”‚ โ”‚
278
+ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚
279
+ โ”‚ โ”‚ โ”‚ sendMessage โ”‚ โ”‚ subscribe โ”‚ โ”‚ โ”‚
280
+ โ”‚ โ”‚ โ”‚ FromView โ”‚ โ”‚ ToWorker โ”‚ โ”‚ โ”‚
281
+ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
282
+ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
283
+ โ”‚ โ”‚ WebSocket โ”‚ โ”‚
284
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
285
+ โ”‚ /ws โ”‚
286
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
287
+ โ”‚ ELECTRON MAIN PROCESS (headless) โ”‚
288
+ โ”‚ โ”‚ โ”‚ โ”‚
289
+ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
290
+ โ”‚ โ”‚ WebUI Runtime Patch โ”‚ โ”‚
291
+ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚
292
+ โ”‚ โ”‚ โ”‚ HTTP โ”‚ โ”‚ WebSocket โ”‚ โ”‚ โ”‚
293
+ โ”‚ โ”‚ โ”‚ Server โ”‚ โ”‚ Server โ”‚ โ”‚ โ”‚
294
+ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
295
+ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚
296
+ โ”‚ โ”‚ webContents.send โ—„โ”€โ”€โ”˜ (intercept & mirror) โ”‚
297
+ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
298
+ โ”‚ โ”‚ โ”‚
299
+ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
300
+ โ”‚ โ”‚ SSH Transport โ”‚ โ—„โ”€โ”€ UNLOCKED ๐Ÿ”“ โ”‚
301
+ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
302
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
303
+ โ”‚ SSH
304
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
305
+ โ”‚ REMOTE HOST โ”‚
306
+ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
307
+ โ”‚ โ”‚ ~/.codex โ”‚ โ”‚
308
+ โ”‚ โ”‚ git apply โ”‚ โ”‚
309
+ โ”‚ โ”‚ sh -lc ... โ”‚ โ”‚
310
+ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
311
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
312
+ ```
313
+
314
+ ---
315
+
316
+ ## ๐ŸŽฏ Requirements
317
+
318
+ - ๐ŸŽ **macOS** with Codex Desktop installed (or custom `--app` path)
319
+ - ๐Ÿ“ฆ **Launcher dependencies are auto-installed** when missing:
320
+ - `node`/`npx` (both launchers)
321
+ - `ripgrep` (`launch_codex_webui_unpacked.sh`)
322
+ - via Homebrew bootstrap when `brew` is missing
323
+ - ๐ŸŒ Internet access and `curl` available for automatic Homebrew/tool installation
324
+ - โš™๏ธ Optional: set `AUTO_INSTALL_TOOLS=0` to disable auto-install behavior
325
+ - ๐ŸŒ **A modern browser** (Chrome, Firefox, Safari, Arc, etc.) for Web UI access
326
+ - ๐Ÿ”‘ **SSH key-based auth** configured for your target host โ€” only needed for SSH mode (`BatchMode=yes`)
327
+ - ๐Ÿ–ฅ๏ธ Target host with `~/.codex` directory (or `$CODEX_HOME` set) โ€” only needed for SSH mode
328
+
329
+ ---
330
+
331
+ ## ๐Ÿ›ก๏ธ Security Notes
332
+
333
+ - SSH uses `BatchMode=yes` โ€” no interactive password prompts, key-based auth only
334
+ - WebUI token auth uses **timing-safe comparison** to prevent timing attacks
335
+ - Security headers are set on all HTTP responses (DENY framing, no-sniff, no-referrer)
336
+ - Single-client policy prevents session hijacking from duplicate tabs
337
+ - Rate limiting protects against WebSocket flood attacks
338
+ - No `StrictHostKeyChecking` overrides โ€” your existing SSH config is respected
339
+
340
+ ---
341
+
342
+ ## ๐Ÿ› Troubleshooting
343
+
344
+ | Problem | Solution |
345
+ |---|---|
346
+ | `EADDRINUSE` | Port already in use โ€” try `--port 6002` |
347
+ | `SSH preflight failed` | Check your SSH key: `ssh -o BatchMode=yes user@host 'echo ok'` |
348
+ | `Renderer guard patch anchor not found` | Bundle version changed โ€” open an issue |
349
+ | `Missing app.asar` | Point `--app` to your Codex.app location |
350
+ | Blank page in WebUI | Check console for `roots` error โ€” renderer patch may need updating |
351
+
352
+ ---
353
+
354
+ ## ๐Ÿค Contributing
355
+
356
+ Found a new Codex version that breaks the patches? Bundle patterns change between releases โ€” [PRs](https://github.com/friuns2/codex-unpacked-toolkit/pulls) to update the patch anchors are always welcome! [Open an issue](https://github.com/friuns2/codex-unpacked-toolkit/issues) if you hit a new bundle shape.
357
+
358
+ ---
359
+
360
+ ## โญ Star This Repo
361
+
362
+ If you think Codex should be accessible **from any browser, on any device** โ€” not just the Electron window it shipped in โ€” [smash that star button](https://github.com/friuns2/codex-unpacked-toolkit). โญ
363
+
364
+ ---
365
+
366
+ <div align="center">
367
+
368
+ **Built by reverse-engineering Codex Desktop's Electron bundle** ๐Ÿ”ฌ
369
+
370
+ *Because the best features are the ones they already shipped but forgot to turn on.* ๐Ÿ˜
371
+
372
+ </div>
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
4
+ exec "$DIR/launch_codex_webui_unpacked.sh" "$@"