codex-in-chrome 0.0.0-stage → 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SinghAbhinav04 and Sudhanshu5669
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,363 @@
1
- # Temporary Holding Version
1
+ <p align="center"><img src="assets/logo.svg" width="72" alt=""></p>
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <h1 align="center">Codex in Chrome</h1>
4
+
5
+ <p align="center">
6
+ Let <a href="https://developers.openai.com/codex">OpenAI Codex</a> browse in <b>your own Chrome</b>, in its own tab group, while you keep working.
7
+ </p>
8
+
9
+ ---
10
+
11
+ Codex in Chrome is a Chrome extension plus a small MCP server for Codex (the CLI, the IDE extension and the desktop app all read the same `~/.codex/config.toml`). Codex gets 25 browser tools: open and search, click, type, fill forms, drag, upload, read pages, debug, take screenshots and record video. All of it happens in a green **Codex** tab group inside the Chrome you already use, with your logins.
12
+
13
+ Agent tabs stay **behind your tabs**. Clicks and keystrokes go into the agent's tab through the Chrome DevTools Protocol, never through your real mouse or keyboard. You can keep using Chrome, or another app, while Codex works, and nothing pops to the front.
14
+
15
+ It is a port of agy-in-chrome (the same browser engine, built for Antigravity) with Codex-native setup: a `config.toml` MCP entry, a Codex skill, server `instructions`, and Codex tool approvals. Because it uses a different port (`38955`), tab group and attribute names, both can be installed in the same Chrome at once.
16
+
17
+ ## Contents
18
+
19
+ - [Highlights](#highlights)
20
+ - [Setup guide](#setup-guide)
21
+ - [Using it](#using-it)
22
+ - [Tools](#tools)
23
+ - [Performance and token cost](#performance-and-token-cost)
24
+ - [How it works](#how-it-works)
25
+ - [Configuration](#configuration)
26
+ - [Troubleshooting](#troubleshooting)
27
+ - [Security and privacy](#security-and-privacy)
28
+ - [Development and tests](#development-and-tests)
29
+ - [Limits](#limits)
30
+
31
+ ## Highlights
32
+
33
+ - **Your browser, not a second one.** No separate Chromium, no remote-debugging flags, no logging in again. Codex only touches tabs in its own group; your other tabs are never read, navigated or closed.
34
+ - **Runs in the background.** Clicking, typing, scrolling, screenshots and recording all work while the agent tab is hidden behind yours.
35
+ - **Background screen recording.** `pilot_record_start` / `pilot_record_stop` record only the agent tab, from Chrome's own renderer, to mp4, webm, gif or avi.
36
+ - **Screenshots** of the viewport, the full page, one element or a zoomed region. They're saved to a file, so they cost no tokens unless the model asks to see one.
37
+ - **Lean on tokens.** Snapshots are one line per element, actions return only what changed, and lookups return a few lines. See [the numbers](#performance-and-token-cost).
38
+ - **Handles hard pages:**
39
+ - closed shadow DOM, same-origin and cross-origin iframes (for example card fields)
40
+ - rich editors and React-controlled inputs
41
+ - inner scroll panels, hover menus and right-click menus
42
+ - HTML5 drag and drop, drop zones, downloads
43
+ - `alert` / `confirm` / "Leave site?" dialogs, which are accepted automatically and reported
44
+ - **Several Codex sessions, one Chrome.** Each session keeps its own tab and never closes another session's tabs. If the session that owns the connection exits, another one takes over.
45
+ - **Stealth mode (human-like interaction).** Natural typing cadence, curved mouse paths with micro-jitter, realistic click dwell times, smooth scrolling, and `navigator.webdriver` masking.
46
+ - **Visible cursor.** An animated cursor, highlight and click ripple are drawn in the page, so recordings show what the agent did.
47
+
48
+ ## Setup guide
49
+
50
+ Two things get installed, once: the **Codex side** (an MCP server and a skill, registered with Codex) and the **Chrome extension**. Setup takes a couple of minutes. It works on Windows, macOS and Linux.
51
+
52
+ ### 1. Check the requirements
53
+
54
+ | You need | Check with | Get it |
55
+ |---|---|---|
56
+ | Node.js 18 or newer | `node -v` | [nodejs.org](https://nodejs.org) (LTS) |
57
+ | Google Chrome (or another Chromium browser) | — | [google.com/chrome](https://www.google.com/chrome/) |
58
+ | OpenAI Codex (CLI, IDE extension or desktop app) | `codex --version` | `npm i -g @openai/codex` |
59
+ | *Optional:* ffmpeg, for mp4/webm/gif recordings | `ffmpeg -version` | Windows: `winget install Gyan.FFmpeg` · macOS: `brew install ffmpeg` · Linux: `sudo apt install ffmpeg` |
60
+
61
+ Without ffmpeg everything still works, but recordings are saved as `.avi`.
62
+
63
+ ### 2. Install the Codex side
64
+
65
+ Pick one. **Option A is the recommended one.**
66
+
67
+ #### Option A: npm (one command, no clone)
68
+
69
+ ```bash
70
+ npx codex-in-chrome install --allow-tools
71
+ ```
72
+
73
+ This copies a self-contained server (no dependencies to install) to `~/.codex/codex-in-chrome/`, registers it with Codex and links the skill. It works for the CLI, the IDE extension and the desktop app.
74
+
75
+ #### Option B: Codex plugin marketplace
76
+
77
+ ```bash
78
+ codex plugin marketplace add Sudhanshu5669/codex-in-chrome
79
+ ```
80
+
81
+ Then open `/plugins` in Codex (or the desktop app's Plugins directory) and install **Codex in Chrome**. This route needs Node on your PATH, doesn't set the longer tool timeout that `pilot_wait` and recordings want, and isn't available in the IDE extension, so Option A is better unless you prefer managing it from the plugin UI.
82
+
83
+ #### Option C: from a clone (for development)
84
+
85
+ ```bash
86
+ git clone https://github.com/Sudhanshu5669/codex-in-chrome.git
87
+ cd codex-in-chrome
88
+ node scripts/install.mjs --allow-tools
89
+ ```
90
+
91
+ Codex runs the server from this folder, so don't move or delete it later (if you do, re-run the installer).
92
+
93
+ #### What the installer does, and the only things it touches
94
+
95
+ | Step | Details |
96
+ |---|---|
97
+ | Server files | Option A copies the bundle, extension and skill to `~/.codex/codex-in-chrome/` (the folder is marked, and only a marked folder is ever removed). Option C runs `npm install` in `server/` and uses the clone in place |
98
+ | MCP server | Adds one marked block, `[mcp_servers.codex-in-chrome]`, to `~/.codex/config.toml` (honours `CODEX_HOME`). It uses the absolute path of your `node`, a 30 s startup timeout and a 180 s tool timeout (Codex's default of 60 s is too short for long `pilot_wait` calls and recordings). `config.toml` is backed up once as `config.toml.codex-in-chrome.bak` |
99
+ | Skill | Links the `codex-in-chrome` skill into `~/.agents/skills/`, which Codex scans for skills |
100
+ | `--allow-tools` | Sets `default_tools_approval_mode = "approve"` on this server only, so Codex doesn't ask before every browser step. Leave the flag out to approve each step. Other servers are unaffected |
101
+ | `--agents-md` | Also adds a short, marked rules block to `~/.codex/AGENTS.md`. Optional: the skill and the server's built-in `instructions` already cover the same ground |
102
+
103
+ The installer refuses to run if `config.toml` already has a `[mcp_servers.codex-in-chrome]` table it didn't write (a duplicate table would make `config.toml` invalid). Run `codex mcp remove codex-in-chrome` first in that case.
104
+
105
+ ### 3. Add the extension to Chrome
106
+
107
+ **From the Chrome Web Store** (once it's listed): search for the extension and click **Add to Chrome**. The store listing and its review are covered in [docs/PUBLISHING.md](docs/PUBLISHING.md).
108
+
109
+ **Unpacked** (works today, and is the fallback if you don't want the store):
110
+
111
+ 1. Open **`chrome://extensions`** in the Chrome you use every day.
112
+ 2. Turn on **Developer mode** (switch in the top-right corner).
113
+ 3. Click **Load unpacked** and select the extension folder that the installer printed (Option A: `~/.codex/codex-in-chrome/extension`; Option C: the `extension` folder of your clone). Option B prints nothing: use `~/.codex/plugins/cache/codex-in-chrome/codex-in-chrome/<version>/extension`. On macOS the folder picker hides `.codex`: press **Cmd+Shift+G** and paste the path.
114
+ 4. *Optional:* pin it via the puzzle-piece icon so you can see its badge.
115
+
116
+ Only this extension is allowed to talk to the server: it is identified by its ID, which the manifest pins to `akiibfcidjlkfgjggmhaeclgpneejlmk` for unpacked installs. If you loaded an older unpacked copy of this extension before the ID was pinned, remove it and load the folder again; the server logs a one-line message explaining this when it refuses a connection.
117
+
118
+ ### 4. Restart Codex and check the connection
119
+
120
+ 1. Restart Codex (a new CLI session, reload the IDE window, or restart the desktop app) so it loads the MCP server. `codex mcp list` should show `codex-in-chrome` as `enabled`.
121
+ 2. Ask it something simple:
122
+
123
+ ```text
124
+ > open example.com in chrome and tell me the heading
125
+ ```
126
+
127
+ 3. Check the result:
128
+ - A green **Codex** tab group appears with example.com in it.
129
+ - Your current tab stays in front.
130
+ - The extension badge shows **ON**.
131
+ - Codex answers "Example Domain".
132
+
133
+ Any time something looks off, run `npx codex-in-chrome check` (or `node scripts/install.mjs --check` from a clone). It checks Node, the Codex CLI, the config entry, the skill link, the bridge and the extension connection, and says what to fix.
134
+
135
+ The badge shows **…** while Codex isn't running; that's normal. Chrome also shows a bar saying *"Codex in Chrome" started debugging this browser* while agent tabs are open. It comes from Chrome itself and can't be hidden.
136
+
137
+ ### Updating
138
+
139
+ ```bash
140
+ npx codex-in-chrome@latest install --allow-tools # Option A
141
+ # or, from a clone: git pull && node scripts/install.mjs --allow-tools
142
+ ```
143
+
144
+ Then restart Codex. Unpacked extensions also need the **reload** icon on their card in `chrome://extensions`; store installs update themselves.
145
+
146
+ ### Uninstalling
147
+
148
+ ```bash
149
+ npx codex-in-chrome uninstall # or: node scripts/install.mjs --uninstall
150
+ codex plugin remove codex-in-chrome@codex-in-chrome # only if you used Option B
151
+ ```
152
+
153
+ This removes the managed block from `config.toml` (and from `AGENTS.md` if you added it), the skill link and the copy in `~/.codex/codex-in-chrome/`. Then remove the extension in `chrome://extensions` and, for Option C, delete the clone.
154
+
155
+ ## Using it
156
+
157
+ Just ask Codex. For example:
158
+
159
+ ```text
160
+ > find the cheapest 1TB NVMe on amazon.in and add it to the cart
161
+ > open my GitHub notifications and summarise the unread ones
162
+ > fill this form with the details from notes.txt and stop before submitting
163
+ > record yourself signing up on localhost:3000 and give me the video
164
+ > why is the checkout page on staging throwing an error? check the console and network
165
+ ```
166
+
167
+ Codex starts with `pilot_start`, works in the Codex group, and tells you where it saved files:
168
+
169
+ | Output | Default folder |
170
+ |---|---|
171
+ | Screenshots | `~/Pictures/codex-in-chrome` |
172
+ | Recordings | `~/Videos/codex-in-chrome` |
173
+ | Downloads | Your normal Chrome download folder (`pilot_downloads` returns the path) |
174
+
175
+ To watch Codex work in the foreground instead, ask it to start with `background: false`, or set `CODEX_PILOT_BACKGROUND=0`.
176
+
177
+ For non-interactive runs (`codex exec`), install with `--allow-tools`. Without pre-approval there's nobody to answer the prompt, so tool calls are declined.
178
+
179
+ ## Tools
180
+
181
+ | Tool | What it does |
182
+ |---|---|
183
+ | **Session and tabs** | |
184
+ | `pilot_start` | Connect to Chrome and prepare the tab group (`background` defaults to true, `stealth` for human-like interaction) |
185
+ | `pilot_tabs` | List agent tabs (yours marked `*`, another Codex session's tabs marked) and running recordings |
186
+ | `pilot_open` | Open a URL in the current agent tab, or `newTab: true`. Returns the page snapshot |
187
+ | `pilot_search` | Opens the DuckDuckGo, Google or Bing results page directly |
188
+ | `pilot_navigate` | A URL, or `back` / `forward` / `reload` |
189
+ | `pilot_select_tab` · `pilot_close_tab` · `pilot_close_group` | Tab control. Never closes another session's tabs |
190
+ | **Reading the page** | |
191
+ | `pilot_snapshot` | Interactive elements as `[uid]` lines with state (checked, expanded, selected…). `query="login button"` returns only the best matches. `frame=f7` lists a cross-origin iframe |
192
+ | `pilot_read` | Main article text first (`all` for the whole page), one element (`uid`), or only lines matching `find` |
193
+ | `pilot_logs` | Console messages (`onlyErrors`) or network requests (`kind: "network"`), filtered by `pattern` |
194
+ | `pilot_eval` | JavaScript with statements and top-level `await` |
195
+ | **Acting** | |
196
+ | `pilot_click` | By uid, text or selector, or `x,y` from a screenshot. `button` right/middle, `clicks` 2–3, `modifiers`, `hover`. Waits for the new page when the click navigates |
197
+ | `pilot_fill` | Text inputs, rich editors (Slack, Notion, Docs), selects by option text, checkboxes and radios. Falls back to real typing when a site rejects scripted values. With no target, types into the focused element |
198
+ | `pilot_press` | Keys, combos and sequences: `"ctrl+a Backspace"`, `"ArrowDown"`, `repeat` |
199
+ | `pilot_drag` | Sliders, sortable lists, HTML5 drag and drop, canvas |
200
+ | `pilot_scroll` | The page, or the panel under an element or point (Gmail, chat panes). `uid` alone scrolls that element into view |
201
+ | `pilot_upload` | Files into `<input type=file>`, or dropped onto a drop zone |
202
+ | `pilot_wait` | Until text or a selector appears or disappears, instead of fixed sleeps |
203
+ | `pilot_downloads` | Recent downloads with saved file paths. `wait: true` waits for the current one to finish |
204
+ | `pilot_batch` | Several actions (click, hover, fill, press, scroll, navigate, wait, drag) in one call, with one diff at the end |
205
+ | **Emulation and capture** | |
206
+ | `pilot_viewport` | Emulate a screen size or a mobile device in the agent tab only. Your window is never resized |
207
+ | `pilot_screenshot` | Viewport, `fullPage`, one element (`uid`) or a zoomed `region`. Options: `clean` (no cursor), `png`, `inline` (returns the image plus click coordinates) |
208
+ | `pilot_record_start` · `pilot_record_stop` | Background video recording of an agent tab: mp4, webm, gif or avi |
209
+
210
+ In Codex these appear as `mcp__codex-in-chrome__pilot_*`.
211
+
212
+ ## Performance and token cost
213
+
214
+ Measured with `node tests/bench.mjs` on Hacker News (`/newest`), with the agent tab in the background and another tab in front, on Windows 11 with Chrome. Times are medians of 3 runs. Tokens are the size of what the tool returns to the model: text/4, plus about w×h/750 for images.
215
+
216
+ | Step | Time | Tokens returned |
217
+ |---|---|---|
218
+ | Open a page (returns a 60-element snapshot) | 396 ms | 925 |
219
+ | Snapshot, default 60 elements | 18 ms | 925 |
220
+ | Snapshot, 200 elements | 31 ms | 3,209 |
221
+ | Find an element (`query=`) | 20 ms | 38 |
222
+ | Scroll | 77 ms | 7 |
223
+ | Screenshot, saved to a file | 98 ms | 26 |
224
+ | Screenshot, inline | 176 ms | 860 |
225
+ | Click a link that navigates (returns a diff) | 508 ms | 24 |
226
+ | Hover | 699 ms | 24 |
227
+ | Page text | 13 ms | 1,019 |
228
+ | Page text with `find=` | 11 ms | 117 |
229
+ | Network log | 6 ms | 152 |
230
+ | Eval | 5 ms | 6 |
231
+
232
+ Tool definitions: 25 tools, about 2.7k tokens, sent on every turn. Your own tab stayed in front for the whole run. Hovering on a background tab is the slowest action, at about 0.7 s, because Chrome only delivers mouse moves with a rendered frame.
233
+
234
+ ### Where the token savings come from
235
+
236
+ | Where tokens go | What Codex in Chrome does |
237
+ |---|---|
238
+ | Tool definitions (sent every turn) | Short descriptions, rarely used settings moved to env vars, and the SDK's per-tool `$schema` URL stripped |
239
+ | Page snapshots | One short line per element (`[e12] a "Pricing" ->/pricing`), same-site links as paths, labels capped at 60 chars, 60 elements by default. Cross-origin iframes are summarised in one line |
240
+ | After each action | **A diff, not a new snapshot.** uids stay stable on a page, so a click returns only changed and new elements, or `(no visible change)` |
241
+ | Missed targets | "Not found" errors list the 5 closest controls with uids, so the model can retry without a new snapshot |
242
+ | Round trips | `pilot_batch` runs a known sequence (fill → fill → click) in one call |
243
+ | Finding and reading | `query=` and `find=` return matching lines only |
244
+ | Waiting | `pilot_wait` returns as soon as something appears, so there are no screenshot-and-retry loops |
245
+ | Images | Screenshots go to disk; `inline` sends a ≤1024 px JPEG only when the model needs to look; `region` zooms into part of the page |
246
+ | Video | Recordings never pass through the model; you get a path and a one-line summary |
247
+
248
+ ## How it works
249
+
250
+ ```
251
+ Codex ──stdio (MCP)──► server/index.mjs ──ws://127.0.0.1:38955──► extension/background.js (your Chrome)
252
+ │ recorder.mjs ├─ chrome.tabs / tabGroups → the "Codex" group
253
+ │ frames → ffmpeg / avi ├─ chrome.scripting → dom.js, overlay.js (snapshots, cursor)
254
+ ▼ ├─ chrome.debugger (CDP) → input, dialogs, screenshots, screencast
255
+ ~/Videos, ~/Pictures └─ chrome.downloads → saved file paths
256
+ ```
257
+
258
+ - **Bridge.** The first Codex session listens on `127.0.0.1:38955` and the extension connects to it. Other Codex sessions send their calls to that one over HTTP. Each call carries a session id, so every session keeps its own current tab.
259
+ - **Background tabs.** Chrome normally stops rendering hidden tabs. The extension turns on CDP focus emulation for agent tabs, so they keep running as if focused. Mouse moves, captures and some layout updates still wait for a rendered frame on a hidden tab. For those steps the extension briefly runs a tiny 32 px screencast, which makes Chrome render the tab on demand.
260
+ - **Input.** Clicks and keys are trusted CDP input events (`Input.dispatchMouseEvent`, `insertText`, drag interception), so sites treat them like real user input. Your real cursor is never involved.
261
+ - **Finding elements.** `dom.js` walks open and closed shadow roots and same-origin iframes, and computes accessible names. Cross-origin iframes are scripted per frame, and their controls get uids like `f7:e3`.
262
+ - **Waiting.** After an action, the extension follows the main frame's navigation events (requested, committed, stopped). It waits for the new page only when one is actually loading.
263
+ - **Recording.** `Page.startScreencast` streams JPEG frames of the agent tab. The server writes them to disk and encodes them on stop: mp4/webm with ffmpeg, gif with a generated palette, or a built-in Motion-JPEG AVI writer without ffmpeg.
264
+ - **Codex integration.** The server sends MCP `instructions` (the core workflow, front-loaded because Codex weighs the first 512 characters most), and the skill in `skills/codex-in-chrome` describes when to use it. Lifecycle: Codex closes the server's stdin when it exits, and the server exits with it so it never holds the bridge port with nobody attached.
265
+
266
+ ## Configuration
267
+
268
+ Set these in `[mcp_servers.codex-in-chrome.env]` in `~/.codex/config.toml`:
269
+
270
+ | Variable | Default | |
271
+ |---|---|---|
272
+ | `CODEX_PILOT_GROUP` / `CODEX_PILOT_COLOR` | `Codex` / `green` | Tab group name and colour |
273
+ | `CODEX_PILOT_BACKGROUND` | `1` | `0` brings agent tabs to the front |
274
+ | `CODEX_PILOT_STEALTH` | `0` | `1` enables stealth mode (human-like typing cadence, curved mouse movement, realistic click dwell times) |
275
+ | `CODEX_PILOT_PORT` | `38955` | Also change `BRIDGE_PORT` in `extension/background.js` |
276
+ | `CODEX_PILOT_OUTPUT_DIR` | unset | One folder for screenshots and recordings |
277
+ | `CODEX_PILOT_REC_WIDTH` / `CODEX_PILOT_REC_QUALITY` / `CODEX_PILOT_REC_BADGE` | `1280` / `70` / `1` | Recording size, JPEG quality, REC badge |
278
+ | `CODEX_PILOT_KEEP_FRAMES` | `0` | Keep raw frames after encoding |
279
+ | `CODEX_FFMPEG` | `ffmpeg` on PATH | Path to ffmpeg |
280
+ | `CODEX_CHROME_BROWSER_URL` | unset | Optional remote-debugging fallback |
281
+
282
+ Codex-side settings worth knowing (all under `[mcp_servers.codex-in-chrome]`): `tool_timeout_sec` (installer sets 180), `default_tools_approval_mode` (`approve` with `--allow-tools`), and `enabled = false` to switch the server off without uninstalling.
283
+
284
+ ## Troubleshooting
285
+
286
+ | Symptom | Fix |
287
+ |---|---|
288
+ | Badge shows **…** / "extension is not connected" | Start or restart Codex. Click the extension icon to retry right away (it backs off up to 15 s while Codex is closed). Run `npx codex-in-chrome check` |
289
+ | Server log says *refused a connection from extension ...* | An older unpacked copy with a different ID is loaded. Remove it in `chrome://extensions` and load the extension folder again (or allow that ID with `CODEX_PILOT_EXTENSION_IDS`) |
290
+ | `codex mcp list` doesn't show `codex-in-chrome` | Re-run the installer. If `CODEX_HOME` is set for Codex, it must be set the same way for the installer |
291
+ | Codex starts but says the server failed to start | The files moved or Node changed. Re-run the installer (it rewrites the absolute paths) |
292
+ | Codex asks permission for every browser step, or declines in `codex exec` | Re-run the installer with `--allow-tools` |
293
+ | A tool call times out after 60 s | The config doesn't have the installer's `tool_timeout_sec = 180`. Re-run the installer, or raise it by hand |
294
+ | A bar saying *"Codex in Chrome" started debugging this browser* | Chrome shows it whenever an extension uses `chrome.debugger`, and extensions can't hide it. It goes away when the agent tabs close |
295
+ | Clicks or typing fail on one tab | DevTools is open on that agent tab. Close DevTools; only one debugger can attach |
296
+ | Recording saved as `.avi` | ffmpeg isn't on PATH. Install it or set `CODEX_FFMPEG` |
297
+ | Port 38955 is taken by something else | Set `CODEX_PILOT_PORT` and change `BRIDGE_PORT` in `extension/background.js` to match, then reload the extension |
298
+ | Nothing happens on `chrome://` pages or the Web Store | Chrome blocks extensions there |
299
+
300
+ ## Security and privacy
301
+
302
+ - **Everything stays on your machine.** The server listens only on `127.0.0.1`. There is no telemetry and no cloud service.
303
+ - **Web pages and other extensions can't use the bridge.** Only this extension's pinned ID may open the WebSocket (`PINNED_EXTENSION_IDS` in `server/index.mjs`; add more with `CODEX_PILOT_EXTENSION_IDS`). HTTP calls that carry a web origin are rejected, and `/rpc` only accepts JSON, so a site can't drive your browser with a cross-site request. The test suite checks this from a real page.
304
+ - **Scope.** Codex only acts on tabs in its own group. The extension needs `<all_urls>` and `debugger` to work on any site in those tabs, `tabs`/`tabGroups` to manage the group, and `downloads` to report saved paths.
305
+ - **Tool approvals.** `--allow-tools` pre-approves every tool of this one server. With it, Codex can drive any site in the Codex tab group using your logins without asking. Skip the flag if you'd rather approve each step.
306
+ - **Not changed for you:** camera, microphone, location and notification permissions. Granting them would apply to your whole browser, not just agent tabs.
307
+ - Anything Codex reads goes to the model you run Codex with, so the usual care applies with sensitive pages. The full policy for the extension is in [docs/PRIVACY.md](docs/PRIVACY.md).
308
+
309
+ ## Development and tests
310
+
311
+ ```bash
312
+ cd server
313
+ npm test # 63 checks against local test pages (no internet needed)
314
+ BUNDLE=1 npm test # the same checks against dist/server.mjs, the file that ships (npm run build first)
315
+ npm run test:codex # end to end: the real Codex CLI fills and submits a form
316
+ npm run bench # speed and token cost on news.ycombinator.com
317
+ REAL=1 npm test # same suite in your own Chrome (quit Codex first)
318
+ ```
319
+
320
+ The tests never touch your Chrome profile, your `~/.codex/config.toml` or a running Codex. They start a throwaway Chrome profile in an off-screen window, load a copy of the extension pointed at test ports (388xx), and talk to the MCP server over stdio exactly as Codex does. Set `CHROME_PATH` if Chrome isn't in a standard location.
321
+
322
+ `npm run test:codex` injects the server through `codex exec -c mcp_servers...` overrides, so nothing is installed. It uses your Codex login for one short model call. If the model in your `config.toml` isn't available to the CLI, pick one with `CODEX_E2E_MODEL=<slug>` (see `~/.codex/models_cache.json`).
323
+
324
+ With `REAL=1` the tests use the extension already loaded in your Chrome. They open background tabs in the Codex group, close them again when done, and delete the one test file they download. PowerShell: `$env:REAL=1; npm test`.
325
+
326
+ The suite covers:
327
+
328
+ - shadow DOM and same-origin/cross-origin iframes
329
+ - selects, checkboxes, controlled inputs and editors
330
+ - key combos, hover, right-click and double click
331
+ - slider and HTML5 drag, drop-zone upload, downloads
332
+ - logs, `wait`, screenshots, viewport, inner scroll panels
333
+ - navigation after a click, `batch`
334
+ - two Codex sessions sharing a browser, with takeover when one exits
335
+ - bridge security checks
336
+ - gif recording, and checking that your own tab stayed in front
337
+
338
+ ```
339
+ extension/ manifest, background.js (bridge, tabs, CDP), dom.js (deep DOM helpers), overlay.js (cursor)
340
+ server/ index.mjs (MCP tools, bridge server), recorder.mjs (frames → video)
341
+ rules/ AGENTS.md – rules block the installer can add to ~/.codex/AGENTS.md
342
+ skills/ codex-in-chrome/SKILL.md – the browsing skill
343
+ dist/ server.mjs – single-file server bundle (git-ignored build output)
344
+ bin/ cli.mjs (what `npx codex-in-chrome` runs: server, install, check, uninstall)
345
+ scripts/ install.mjs, build.mjs (bundle, plugin, store zip), make-icons.mjs, store-screenshots.mjs
346
+ plugins/ codex-in-chrome/ – the Codex plugin (build output, committed on purpose)
347
+ .agents/ plugins/marketplace.json – lets `codex plugin marketplace add` find the plugin
348
+ docs/ HANDOFF.md (project state), PRIVACY.md, PUBLISHING.md (release runbook), store/ (Chrome Web Store listing + screenshots)
349
+ tests/ harness.mjs, suite.mjs, codex-e2e.mjs, bench.mjs
350
+ ```
351
+
352
+ ## Limits
353
+
354
+ - Only frames directly inside the page are handled as cross-origin iframes; deeper nesting, and frames inside closed shadow roots, can still be clicked by `x,y` from a screenshot.
355
+ - Hover and drag on background tabs take 0.4–0.7 s, because Chrome ties mouse moves to rendered frames.
356
+ - One Chrome profile at a time: Codex uses the profile the extension is loaded in.
357
+ - Console capture starts the first time `pilot_logs` reads the console on a tab (earlier messages are replayed). It isn't on from the start, because some bot checks detect it.
358
+ - Response bodies aren't captured in the network log; use `pilot_eval` with `fetch` when you need data.
359
+ - Native date and colour pickers aren't driven. Set the input with `pilot_fill` (for example `2026-12-01`) instead.
360
+
361
+ ## License
362
+
363
+ [MIT](LICENSE). Derived from agy-in-chrome (© 2026 SinghAbhinav04 and Sudhanshu5669, also MIT); the copyright notice is kept as the license requires.
Binary file
@@ -0,0 +1,9 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="none">
2
+ <rect width="64" height="64" rx="16" fill="#0B1F1A"/>
3
+ <rect x="6" y="6" width="52" height="52" rx="12" stroke="#10A37F" stroke-width="2" stroke-opacity="0.5"/>
4
+ <g transform="translate(30 29) rotate(-40) scale(1.9) translate(-7.5 -7)">
5
+ <path d="M7.5 0L13.5 11.5L7.5 9.2L1.5 11.5Z" fill="#FFFFFF" stroke="#0B1F1A" stroke-width="1.1" stroke-linejoin="round"/>
6
+ <path d="M7.5 0L7.5 9.2L1.5 11.5Z" fill="#10A37F"/>
7
+ </g>
8
+ <path d="M42 41l-5 4 5 4M50 41l5 4-5 4" stroke="#10A37F" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" transform="translate(-2 3)"/>
9
+ </svg>
package/bin/cli.mjs ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+ // codex-in-chrome CLI.
3
+ // codex-in-chrome run the MCP server on stdio (what Codex launches)
4
+ // codex-in-chrome install [flags] register it with Codex (flags: --allow-tools --agents-md)
5
+ // codex-in-chrome check diagnose the install
6
+ // codex-in-chrome uninstall remove what install added
7
+ // codex-in-chrome --version | help
8
+ import fs from 'node:fs';
9
+ import path from 'node:path';
10
+ import {fileURLToPath, pathToFileURL} from 'node:url';
11
+
12
+ const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
13
+ const [cmd, ...rest] = process.argv.slice(2);
14
+
15
+ const HELP = `Codex in Chrome: let OpenAI Codex work in your own Chrome.
16
+
17
+ npx codex-in-chrome install --allow-tools register with Codex (then add the Chrome extension)
18
+ npx codex-in-chrome check diagnose the install
19
+ npx codex-in-chrome uninstall remove it again
20
+ codex-in-chrome run the MCP server (Codex does this itself)
21
+
22
+ Docs: https://github.com/Sudhanshu5669/codex-in-chrome`;
23
+
24
+ const subcommands = {install: [], check: ['--check'], uninstall: ['--uninstall']};
25
+
26
+ if (cmd === '--version' || cmd === '-v') {
27
+ console.log(JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8')).version);
28
+ } else if (cmd === 'help' || cmd === '--help' || cmd === '-h') {
29
+ console.log(HELP);
30
+ } else if (cmd && Object.hasOwn(subcommands, cmd)) {
31
+ process.argv = [process.argv[0], path.join(ROOT, 'scripts', 'install.mjs'), ...subcommands[cmd], ...rest];
32
+ await import(pathToFileURL(path.join(ROOT, 'scripts', 'install.mjs')).href);
33
+ } else if (cmd === undefined || cmd.startsWith('-')) {
34
+ // Server mode. The bundled file ships in the npm package; a git clone runs the source.
35
+ const bundled = path.join(ROOT, 'dist', 'server.mjs');
36
+ const entry = fs.existsSync(bundled) ? bundled : path.join(ROOT, 'server', 'index.mjs');
37
+ await import(pathToFileURL(entry).href);
38
+ } else {
39
+ console.error(`Unknown command "${cmd}".\n\n${HELP}`);
40
+ process.exit(1);
41
+ }