|
1 | | -# `npx codex-web-local` |
| 1 | +<div align="center"> |
2 | 2 |
|
3 | | -A lightweight web interface for [Codex](https://github.com/openai/codex) that replicates the desktop UI and runs on top of the Codex `app-server`. It exposes Codex through a web application, allowing you to access your local Codex instance remotely from any browser. |
| 3 | +# 🔥 Codex Mobile |
4 | 4 |
|
5 | | -## Prerequisites |
| 5 | +### 📱 OpenAI Codex CLI — In Your Pocket — On Android 📱 |
6 | 6 |
|
7 | | -- [Codex CLI](https://github.com/openai/codex) installed and available in your `PATH` |
| 7 | +[](https://developer.android.com) |
| 8 | +[](https://kotlinlang.org) |
| 9 | +[](https://nodejs.org) |
| 10 | +[](https://vuejs.org) |
| 11 | +[](#) |
| 12 | +[](LICENSE) |
8 | 13 |
|
9 | | -## Installation |
| 14 | +<br /> |
| 15 | + |
| 16 | +> **They built an AI coding agent for the terminal.** |
| 17 | +> **We put an entire Linux environment inside an Android app and ran it there.** |
| 18 | +> **One APK. No root. Full Codex.** |
| 19 | +
|
| 20 | +<br /> |
| 21 | + |
| 22 | +``` |
| 23 | +╔═══════════════════════════════════════════════╗ |
| 24 | +║ ██████╗ ██████╗ ██████╗ ███████╗██╗ ██╗ ║ |
| 25 | +║ ██╔════╝██╔═══██╗██╔══██╗██╔════╝╚██╗██╔╝ ║ |
| 26 | +║ ██║ ██║ ██║██║ ██║█████╗ ╚███╔╝ ║ |
| 27 | +║ ██║ ██║ ██║██║ ██║██╔══╝ ██╔██╗ ║ |
| 28 | +║ ╚██████╗╚██████╔╝██████╔╝███████╗██╔╝ ██╗ ║ |
| 29 | +║ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ║ |
| 30 | +║ M O B I L E E D I T I O N ║ |
| 31 | +╚═══════════════════════════════════════════════╝ |
| 32 | +``` |
| 33 | + |
| 34 | +</div> |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +## 🤯 What Is This? |
| 39 | + |
| 40 | +OpenAI shipped [Codex CLI](https://github.com/openai/codex) — a terminal-based AI coding agent that can read, write, and execute code. **But it only runs on Linux and macOS.** |
| 41 | + |
| 42 | +We said: *what if it ran on your phone?* |
| 43 | + |
| 44 | +This app bundles a **full Termux Linux environment**, **Node.js 21**, the **Codex CLI**, and a **Vue.js web interface** — all inside a single Android APK. No root required. No terminal knowledge needed. Open the app, authenticate with OpenAI, and start coding from your pocket. |
| 45 | + |
| 46 | +**Yes, that's a real Linux userland. Yes, that's the real Codex binary. Yes, it runs on your phone.** 🧠 |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## 📱 How It Works |
| 51 | + |
| 52 | +<div align="center"> |
| 53 | +<table> |
| 54 | +<tr> |
| 55 | +<td align="center" width="50%"> |
| 56 | +<br /><b>🏗️ Architecture</b><br /> |
| 57 | +<sub>Android WebView → Vue.js frontend → Express bridge → <code>codex app-server</code> (native ARM64 binary) → OpenAI API</sub> |
| 58 | +</td> |
| 59 | +<td align="center" width="50%"> |
| 60 | +<br /><b>⚡ First Launch</b><br /> |
| 61 | +<sub>Extracts Termux bootstrap → installs Node.js via apt → deploys Codex CLI → downloads native binary → authenticates via OAuth → ready in ~2 minutes</sub> |
| 62 | +</td> |
| 63 | +</tr> |
| 64 | +</table> |
| 65 | +</div> |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## 🌍 What Can You Do With This? |
| 70 | + |
| 71 | +| | Use Case | Description | |
| 72 | +|---|---|---| |
| 73 | +| 💻 | **Code on the go** | Write, debug, and refactor code from your phone or tablet | |
| 74 | +| 🤖 | **AI pair programming** | Full Codex agent with tool use, file I/O, and shell access | |
| 75 | +| 📂 | **Manage projects** | Multiple threads, model selection, reasoning effort control | |
| 76 | +| 🔓 | **Full access mode** | `danger-full-access` sandbox — no approval prompts, maximum speed | |
| 77 | +| 🌐 | **OAuth login** | Browser-based OpenAI authentication, no manual API keys needed | |
| 78 | +| 📡 | **Background running** | Foreground service keeps the server alive when screen is off | |
| 79 | +| 🔌 | **Offline-capable setup** | Bootstrap and binaries cached after first install | |
| 80 | +| 🧩 | **Real Linux env** | Termux-compatible userland with apt, Node.js, npm, and more | |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +## ⚡ Quick Start |
10 | 85 |
|
11 | 86 | ```bash |
12 | | -# Run directly with npx (no install required) |
13 | | -npx codex-web-local |
| 87 | +# 🔧 Clone and build |
| 88 | +git clone https://github.com/friuns2/codex-web-local.git |
| 89 | +cd codex-web-local |
| 90 | + |
| 91 | +# 📦 Download Termux bootstrap |
| 92 | +cd android && bash scripts/download-bootstrap.sh && cd .. |
14 | 93 |
|
15 | | -# Or install globally |
16 | | -npm install -g codex-web-local |
| 94 | +# 🏗️ Build Vue frontend + server bundle |
| 95 | +bash android/scripts/build-server-bundle.sh |
| 96 | + |
| 97 | +# 🚀 Build APK |
| 98 | +cd android && ./gradlew assembleDebug |
| 99 | +# APK at: android/app/build/outputs/apk/debug/app-debug.apk ✈️ |
17 | 100 | ``` |
18 | 101 |
|
19 | | -## Usage |
| 102 | +Or grab the latest APK from [**Releases**](https://github.com/friuns2/codex-web-local/releases) 📥 |
| 103 | + |
| 104 | +--- |
20 | 105 |
|
| 106 | +## 📁 Project Structure |
| 107 | + |
| 108 | +``` |
| 109 | +codex-web-local/ |
| 110 | +├── 🌐 src/ # Vue.js frontend + Express server |
| 111 | +│ ├── components/ # UI components (composer, sidebar, threads) |
| 112 | +│ ├── api/ # RPC client → codex app-server bridge |
| 113 | +│ ├── server/ # Express HTTP server + SSE events |
| 114 | +│ └── cli/ # CLI entry point |
| 115 | +├── 📱 android/ # Android app (Kotlin) |
| 116 | +│ ├── app/src/main/java/ # Kotlin source |
| 117 | +│ │ ├── MainActivity.kt # WebView + setup orchestration |
| 118 | +│ │ ├── CodexServerManager.kt # Node.js/Codex process management |
| 119 | +│ │ ├── BootstrapInstaller.kt # Termux environment extraction |
| 120 | +│ │ └── CodexForegroundService.kt # Background service |
| 121 | +│ ├── app/src/main/assets/ # proxy.js, bootstrap zip, server bundle |
| 122 | +│ └── scripts/ # Build helper scripts |
| 123 | +├── 📖 documentation/ # App-server JSON-RPC schemas |
| 124 | +└── 🔧 vite.config.ts # Frontend build config |
21 | 125 | ``` |
22 | | -Usage: codex-web-local [options] |
23 | 126 |
|
24 | | -Web interface for Codex app-server |
| 127 | +--- |
| 128 | + |
| 129 | +## 🏗️ Architecture |
25 | 130 |
|
26 | | -Options: |
27 | | - -p, --port <port> port to listen on (default: "3000") |
28 | | - --password <pass> set a specific password |
29 | | - --no-password disable password protection |
30 | | - -h, --help display help for command |
| 131 | +``` |
| 132 | +┌──────────────────────────────────────────────────────┐ |
| 133 | +│ Android App │ |
| 134 | +│ │ |
| 135 | +│ ┌─────────┐ ┌──────────────┐ ┌──────────────┐ │ |
| 136 | +│ │ WebView │───▶│ Vue.js SPA │───▶│ Express │ │ |
| 137 | +│ │ │ │ (frontend) │ │ HTTP Server │ │ |
| 138 | +│ └─────────┘ └──────────────┘ └──────┬───────┘ │ |
| 139 | +│ │ JSON-RPC │ |
| 140 | +│ ┌─────────────────────────────────────────▼───────┐ │ |
| 141 | +│ │ codex app-server (native ARM64) │ │ |
| 142 | +│ │ approval: never | sandbox: full-access │ │ |
| 143 | +│ └────────────────────┬────────────────────────────┘ │ |
| 144 | +│ │ HTTPS via CONNECT proxy │ |
| 145 | +│ ┌────────────────────▼────────────────────────────┐ │ |
| 146 | +│ │ Node.js HTTP CONNECT Proxy │ │ |
| 147 | +│ │ (DNS + TLS for musl binary) │ │ |
| 148 | +│ └────────────────────┬────────────────────────────┘ │ |
| 149 | +│ │ │ |
| 150 | +│ ┌────────────────────▼────────────────────────────┐ │ |
| 151 | +│ │ Termux Bootstrap (Linux userland) │ │ |
| 152 | +│ │ /data/data/com.codex.mobile/files/usr/ │ │ |
| 153 | +│ └─────────────────────────────────────────────────┘ │ |
| 154 | +└──────────────────────────┬───────────────────────────┘ |
| 155 | + │ |
| 156 | + ┌──────▼──────┐ |
| 157 | + │ OpenAI API │ |
| 158 | + └─────────────┘ |
31 | 159 | ``` |
32 | 160 |
|
33 | | -## Examples |
| 161 | +--- |
34 | 162 |
|
35 | | -```bash |
36 | | -# Start with auto-generated password on default port 3000 |
37 | | -codex-web-local |
| 163 | +## 🔧 Key Technical Challenges Solved |
38 | 164 |
|
39 | | -# Start on a custom port |
40 | | -codex-web-local --port 8080 |
| 165 | +> **Running a statically-linked musl Rust binary on Android? Yeah, that was fun.** |
41 | 166 |
|
42 | | -# Start with a specific password |
43 | | -codex-web-local --password my-secret |
| 167 | +1. 🔌 **DNS/TLS for native binary** — The Codex Rust binary is compiled for `musl` Linux and can't use Android's DNS resolver. Solution: a Node.js HTTP CONNECT proxy that routes all traffic through Android's native network stack. |
44 | 168 |
|
45 | | -# Start without password protection (use only on trusted networks) |
46 | | -codex-web-local --no-password |
47 | | -``` |
| 169 | +2. 🔒 **W^X execution policy** — Android 10+ blocks executing binaries from app data. Solution: `targetSdk = 28` (same approach as Termux F-Droid). |
| 170 | + |
| 171 | +3. 📦 **Platform binary mismatch** — npm refuses to install `@openai/codex-linux-arm64` on Android (`os: android ≠ linux`). Solution: download the tarball directly via Node.js and extract it manually. |
| 172 | + |
| 173 | +4. 🔑 **OAuth in embedded environment** — `codex login` spawns a local callback server. The app parses the OAuth URL from stdout and opens the system browser. |
| 174 | + |
| 175 | +5. 🗂️ **Termux path remapping** — All hardcoded `/data/data/com.termux` paths in apt/dpkg configs are rewritten to the app's private directory at install time. |
| 176 | + |
| 177 | +--- |
| 178 | + |
| 179 | +## 🎯 Requirements |
| 180 | + |
| 181 | +- 📱 Android 7.0+ (API 24+) — ARM64 device |
| 182 | +- 🌐 Internet connection (for OpenAI API + first-time setup) |
| 183 | +- 🔑 OpenAI account with Codex access |
| 184 | +- 💾 ~200MB storage for bootstrap + Node.js + Codex |
| 185 | + |
| 186 | +--- |
| 187 | + |
| 188 | +## 🐛 Troubleshooting |
| 189 | + |
| 190 | +| Problem | Solution | |
| 191 | +|---|---| |
| 192 | +| 🔴 "Failed to install Node.js" | Check internet connection; apt needs to download ~40MB | |
| 193 | +| 🔴 OpenSSL config error | The app handles this — if you see it in logs, it's from a stale process | |
| 194 | +| 🔴 Message disappears after sending | Force-stop and relaunch — server bundle may need re-extraction | |
| 195 | +| 🔴 "Health check failed" | Verify OpenAI account has Codex access; check proxy is running | |
| 196 | +| 🔴 App killed in background | Grant battery optimization exemption (prompted at startup) | |
| 197 | + |
| 198 | +--- |
| 199 | + |
| 200 | +## 🤝 Contributing |
| 201 | + |
| 202 | +PRs welcome! Key areas: |
| 203 | + |
| 204 | +- 🎨 UI improvements for mobile form factor |
| 205 | +- 📱 Multi-architecture support (x86_64 for emulators) |
| 206 | +- 🔧 Startup time optimization |
| 207 | +- 📋 File browser / workspace management |
| 208 | + |
| 209 | +--- |
| 210 | + |
| 211 | +## ⭐ Star This Repo |
| 212 | + |
| 213 | +If you believe **AI coding agents should run everywhere** — not just on laptops with terminal access — smash that star button. ⭐ |
| 214 | + |
| 215 | +Your stars fuel the mass delusion that shipping a Linux distro inside an Android app is totally normal and fine. 🚀 |
48 | 216 |
|
49 | | -When started with password protection (default), the server prints the password to the console. Open the URL in your browser, enter the password, and you're in. |
| 217 | +--- |
50 | 218 |
|
51 | | -## Contributing |
| 219 | +<div align="center"> |
52 | 220 |
|
53 | | -Issues and pull requests are welcome! If you have ideas, suggestions, or found a bug, please open an issue on the [GitHub repository](https://github.com/pavel-voronin/codex-web-local/issues). |
| 221 | +**Built by shoving an entire Linux userland into a WebView** 🔬 |
54 | 222 |
|
55 | | -## License |
| 223 | +*"Can it run Codex?" — yes, even your phone can now* 😏 |
56 | 224 |
|
57 | | -[MIT](./LICENSE) |
| 225 | +</div> |
0 commit comments