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 +21 -0
- package/README.md +362 -2
- package/assets/logo.png +0 -0
- package/assets/logo.svg +9 -0
- package/bin/cli.mjs +41 -0
- package/dist/server.mjs +39416 -0
- package/extension/background.js +2222 -0
- package/extension/dom.js +178 -0
- package/extension/icons/icon-128.png +0 -0
- package/extension/icons/icon-16.png +0 -0
- package/extension/icons/icon-32.png +0 -0
- package/extension/icons/icon-48.png +0 -0
- package/extension/manifest.json +35 -0
- package/extension/overlay.js +278 -0
- package/package.json +43 -6
- package/rules/AGENTS.md +10 -0
- package/scripts/install.mjs +271 -0
- package/skills/codex-in-chrome/SKILL.md +34 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Installs Codex in Chrome for OpenAI Codex (CLI, IDE extension and desktop app
|
|
3
|
+
// all read the same ~/.codex/config.toml).
|
|
4
|
+
//
|
|
5
|
+
// npx codex-in-chrome install same thing, from the npm package (no clone needed)
|
|
6
|
+
// node scripts/install.mjs register the MCP server + the browsing skill
|
|
7
|
+
// node scripts/install.mjs --allow-tools also pre-approve this server's tools (no prompt per browser step)
|
|
8
|
+
// node scripts/install.mjs --agents-md also add the short rules block to ~/.codex/AGENTS.md
|
|
9
|
+
// node scripts/install.mjs --check diagnose the install (read-only)
|
|
10
|
+
// node scripts/install.mjs --uninstall remove everything the installer added
|
|
11
|
+
//
|
|
12
|
+
// What it touches, and nothing else:
|
|
13
|
+
// ~/.codex/config.toml one marked block: [mcp_servers.codex-in-chrome]
|
|
14
|
+
// ~/.agents/skills/codex-in-chrome a link to skills/codex-in-chrome (in this repo, or in the stable copy below)
|
|
15
|
+
// ~/.codex/codex-in-chrome/ npm-package mode only: a copy of the bundled server, extension and skill
|
|
16
|
+
// (stable paths that survive npx cache cleanups)
|
|
17
|
+
// ~/.codex/AGENTS.md one marked block (only with --agents-md)
|
|
18
|
+
// CODEX_HOME is honoured. config.toml and AGENTS.md are backed up before the first change.
|
|
19
|
+
import {spawnSync} from 'node:child_process';
|
|
20
|
+
import fs from 'node:fs';
|
|
21
|
+
import os from 'node:os';
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
import {fileURLToPath} from 'node:url';
|
|
24
|
+
|
|
25
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
26
|
+
const CODEX_HOME = process.env.CODEX_HOME || path.join(os.homedir(), '.codex');
|
|
27
|
+
const CONFIG = path.join(CODEX_HOME, 'config.toml');
|
|
28
|
+
const AGENTS_MD = path.join(CODEX_HOME, 'AGENTS.md');
|
|
29
|
+
const SKILLS_DIR = process.env.CODEX_SKILLS_DIR || path.join(os.homedir(), '.agents', 'skills');
|
|
30
|
+
const SKILL_LINK = path.join(SKILLS_DIR, 'codex-in-chrome');
|
|
31
|
+
const read = file => (fs.existsSync(file) ? fs.readFileSync(file, 'utf8').replace(/^/, '') : '');
|
|
32
|
+
const SERVER = 'codex-in-chrome';
|
|
33
|
+
// Two ways to run this file: from a git clone (server/ source present) or from the
|
|
34
|
+
// npm package (only the bundled dist/server.mjs). The package copy goes to a stable folder.
|
|
35
|
+
const FROM_REPO = fs.existsSync(path.join(ROOT, 'server', 'index.mjs'));
|
|
36
|
+
const PKG = JSON.parse(read(path.join(ROOT, 'package.json')) || '{}');
|
|
37
|
+
const INSTALL_DIR = path.join(CODEX_HOME, 'codex-in-chrome');
|
|
38
|
+
const MANAGED_MARK = path.join(INSTALL_DIR, '.managed-by-codex-in-chrome');
|
|
39
|
+
const SERVER_ENTRY = FROM_REPO ? path.join(ROOT, 'server', 'index.mjs') : path.join(INSTALL_DIR, 'server', 'index.mjs');
|
|
40
|
+
const EXTENSION_PATH = FROM_REPO ? path.join(ROOT, 'extension') : path.join(INSTALL_DIR, 'extension');
|
|
41
|
+
const SKILL_SRC = FROM_REPO ? path.join(ROOT, 'skills', 'codex-in-chrome') : path.join(INSTALL_DIR, 'skills', 'codex-in-chrome');
|
|
42
|
+
const PORT = Number(process.env.CODEX_PILOT_PORT || 38955);
|
|
43
|
+
const args = new Set(process.argv.slice(2));
|
|
44
|
+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
45
|
+
|
|
46
|
+
const TOML_BEGIN = '# >>> codex-in-chrome (managed by scripts/install.mjs; edit freely, re-run installs to refresh) >>>';
|
|
47
|
+
const TOML_END = '# <<< codex-in-chrome <<<';
|
|
48
|
+
const MD_BEGIN = '<!-- >>> codex-in-chrome (managed by scripts/install.mjs) >>> -->';
|
|
49
|
+
const MD_END = '<!-- <<< codex-in-chrome <<< -->';
|
|
50
|
+
|
|
51
|
+
const step = msg => console.log(`\n> ${msg}`);
|
|
52
|
+
|
|
53
|
+
// Paths on Windows are full of backslashes: use a TOML literal string when
|
|
54
|
+
// possible, and a (JSON-compatible) basic string otherwise.
|
|
55
|
+
const tomlString = s => (/['\r\n]/.test(s) ? JSON.stringify(s) : `'${s}'`);
|
|
56
|
+
|
|
57
|
+
function backupOnce(file) {
|
|
58
|
+
const bak = `${file}.codex-in-chrome.bak`;
|
|
59
|
+
if (fs.existsSync(file) && !fs.existsSync(bak)) fs.copyFileSync(file, bak);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Replace the managed block in `text` (or append it); returns the new text.
|
|
63
|
+
function upsertBlock(text, begin, end, body) {
|
|
64
|
+
const block = `${begin}\n${body.trimEnd()}\n${end}\n`;
|
|
65
|
+
const i = text.indexOf(begin);
|
|
66
|
+
const j = text.indexOf(end);
|
|
67
|
+
if (i >= 0 && j > i) return text.slice(0, i) + block + text.slice(j + end.length).replace(/^\r?\n/, '');
|
|
68
|
+
const sep = text.length === 0 ? '' : text.endsWith('\n') ? '\n' : '\n\n';
|
|
69
|
+
return `${text}${sep}${block}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function removeBlock(text, begin, end) {
|
|
73
|
+
const i = text.indexOf(begin);
|
|
74
|
+
const j = text.indexOf(end);
|
|
75
|
+
if (i < 0 || j < i) return {text, removed: false};
|
|
76
|
+
const before = text.slice(0, i).replace(/\n+$/, '\n');
|
|
77
|
+
const after = text.slice(j + end.length).replace(/^\r?\n/, '');
|
|
78
|
+
return {text: (before + (after && before ? '\n' : '') + after) || '', removed: true};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// A second [mcp_servers.codex-in-chrome] table makes config.toml invalid and
|
|
82
|
+
// Codex refuses to start, so never add one next to a hand-written copy.
|
|
83
|
+
function hasUnmanagedServer(text) {
|
|
84
|
+
const {text: rest} = removeBlock(text, TOML_BEGIN, TOML_END);
|
|
85
|
+
return new RegExp(`^\\s*\\[mcp_servers\\.("?)${SERVER}\\1(\\.|\\])`, 'm').test(rest);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function mcpBlock() {
|
|
89
|
+
const lines = [
|
|
90
|
+
`[mcp_servers.${SERVER}]`,
|
|
91
|
+
`command = ${tomlString(process.execPath)}`,
|
|
92
|
+
`args = [${tomlString(SERVER_ENTRY)}]`,
|
|
93
|
+
'startup_timeout_sec = 30',
|
|
94
|
+
// pilot_wait and screen recording can legitimately run longer than the 60 s default.
|
|
95
|
+
'tool_timeout_sec = 180',
|
|
96
|
+
];
|
|
97
|
+
if (args.has('--allow-tools')) lines.push('default_tools_approval_mode = "approve"');
|
|
98
|
+
lines.push('', `[mcp_servers.${SERVER}.env]`, 'CODEX_PILOT_GROUP = "Codex"', 'CODEX_PILOT_COLOR = "green"');
|
|
99
|
+
if (PORT !== 38955) lines.push(`CODEX_PILOT_PORT = "${PORT}"`);
|
|
100
|
+
return lines.join('\n');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function agentsBlock() {
|
|
104
|
+
return read(path.join(ROOT, 'rules', 'AGENTS.md')).trim();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// npm-package mode: the files Codex runs and Chrome loads must outlive the npx cache, so copy them.
|
|
108
|
+
function installPayload() {
|
|
109
|
+
const dist = path.join(ROOT, 'dist', 'server.mjs');
|
|
110
|
+
if (!fs.existsSync(dist)) {
|
|
111
|
+
console.error(`${dist} is missing. This package is incomplete; reinstall it (npx codex-in-chrome@latest install).`);
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
// Only replace a folder this installer made: someone may have cloned or put files there.
|
|
115
|
+
if (fs.existsSync(INSTALL_DIR) && !fs.existsSync(MANAGED_MARK) && fs.readdirSync(INSTALL_DIR).length) {
|
|
116
|
+
console.error(`${INSTALL_DIR} already exists and was not created by this installer. Move or remove it and re-run.`);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
fs.rmSync(INSTALL_DIR, {recursive: true, force: true});
|
|
120
|
+
fs.mkdirSync(path.join(INSTALL_DIR, 'server'), {recursive: true});
|
|
121
|
+
// Marked first, so a copy that fails halfway can still be replaced by the next run.
|
|
122
|
+
fs.writeFileSync(MANAGED_MARK, `${PKG.version || ''}\n`);
|
|
123
|
+
fs.copyFileSync(dist, path.join(INSTALL_DIR, 'server', 'index.mjs'));
|
|
124
|
+
for (const d of ['extension', 'skills']) fs.cpSync(path.join(ROOT, d), path.join(INSTALL_DIR, d), {recursive: true});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function linkSkill() {
|
|
128
|
+
fs.mkdirSync(SKILLS_DIR, {recursive: true});
|
|
129
|
+
if (fs.existsSync(SKILL_LINK) || isLink(SKILL_LINK)) {
|
|
130
|
+
if (isLink(SKILL_LINK)) fs.unlinkSync(SKILL_LINK);
|
|
131
|
+
else {
|
|
132
|
+
console.error(`${SKILL_LINK} already exists and is not a link. Remove it and re-run.`);
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
fs.symlinkSync(SKILL_SRC, SKILL_LINK, process.platform === 'win32' ? 'junction' : 'dir');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function isLink(p) {
|
|
140
|
+
try {
|
|
141
|
+
return fs.lstatSync(p).isSymbolicLink();
|
|
142
|
+
} catch {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function bridgeStatus() {
|
|
148
|
+
try {
|
|
149
|
+
const res = await fetch(`http://127.0.0.1:${PORT}/health`, {signal: AbortSignal.timeout(1500)});
|
|
150
|
+
return await res.json();
|
|
151
|
+
} catch {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
if (args.has('--check')) {
|
|
158
|
+
let bad = 0;
|
|
159
|
+
const line = (ok, label, hint = '') => {
|
|
160
|
+
console.log(`${ok ? ' ok ' : 'FAIL'} ${label}${!ok && hint ? `\n -> ${hint}` : ''}`);
|
|
161
|
+
if (!ok) bad++;
|
|
162
|
+
};
|
|
163
|
+
const major = Number(process.versions.node.split('.')[0]);
|
|
164
|
+
line(major >= 18, `Node ${process.versions.node}`, 'Node 18 or newer is required');
|
|
165
|
+
const cx = spawnSync('codex --version', {shell: true, encoding: 'utf8'});
|
|
166
|
+
line(cx.status === 0, `codex CLI: ${(cx.stdout || '').trim() || 'not found'}`, 'Install Codex (npm i -g @openai/codex). The desktop app and IDE extension work without the CLI.');
|
|
167
|
+
if (FROM_REPO) line(fs.existsSync(path.join(ROOT, 'server', 'node_modules', '@modelcontextprotocol')), 'server dependencies installed', 'run: node scripts/install.mjs');
|
|
168
|
+
else line(fs.existsSync(SERVER_ENTRY), `bundled server installed at ${SERVER_ENTRY}`, 'run: npx codex-in-chrome@latest install');
|
|
169
|
+
const cfg = read(CONFIG);
|
|
170
|
+
const registered = cfg.includes(TOML_BEGIN) || hasUnmanagedServer(cfg);
|
|
171
|
+
line(registered, `registered in ${CONFIG}`, 'run: node scripts/install.mjs');
|
|
172
|
+
if (registered) {
|
|
173
|
+
const m = cfg.match(new RegExp(`\\[mcp_servers\\.${SERVER}\\][\\s\\S]*?args = \\[(.*)\\]`));
|
|
174
|
+
const serverPath = m && m[1].replace(/^['"]|['"]$/g, '');
|
|
175
|
+
line(!serverPath || serverPath === SERVER_ENTRY || fs.existsSync(serverPath), 'registered server path exists', 'the files moved: re-run the installer');
|
|
176
|
+
console.log(` tool approval: ${/default_tools_approval_mode\s*=\s*"approve"/.test(cfg) ? 'pre-approved' : 'asks per tool (re-run with --allow-tools to pre-approve)'}`);
|
|
177
|
+
}
|
|
178
|
+
line(fs.existsSync(path.join(SKILL_LINK, 'SKILL.md')), `skill linked at ${SKILL_LINK}`, 'run: node scripts/install.mjs');
|
|
179
|
+
const health = await bridgeStatus();
|
|
180
|
+
console.log(
|
|
181
|
+
health
|
|
182
|
+
? ` bridge on :${PORT}: up, extension ${health.connected ? 'CONNECTED' : 'not connected (load the extension in chrome://extensions, then click its icon)'}`
|
|
183
|
+
: ` bridge on :${PORT}: not running (normal while Codex is closed; it starts with Codex or the first browser tool call)`,
|
|
184
|
+
);
|
|
185
|
+
const ff = spawnSync('ffmpeg -hide_banner -version', {stdio: 'ignore', shell: true});
|
|
186
|
+
console.log(` ffmpeg: ${ff.status === 0 ? 'found (mp4/gif recordings)' : 'not found (recordings fall back to .avi)'}`);
|
|
187
|
+
console.log(bad ? `\n${bad} problem(s).` : '\nAll good.');
|
|
188
|
+
process.exit(bad ? 1 : 0);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (args.has('--uninstall')) {
|
|
192
|
+
const cfg = read(CONFIG);
|
|
193
|
+
const r = removeBlock(cfg, TOML_BEGIN, TOML_END);
|
|
194
|
+
if (r.removed) {
|
|
195
|
+
backupOnce(CONFIG);
|
|
196
|
+
fs.writeFileSync(CONFIG, r.text);
|
|
197
|
+
step(`Removed the codex-in-chrome block from ${CONFIG}`);
|
|
198
|
+
} else if (hasUnmanagedServer(cfg)) {
|
|
199
|
+
console.log(`\nNote: ${CONFIG} has a hand-written [mcp_servers.${SERVER}] table. Remove it yourself (or: codex mcp remove ${SERVER}).`);
|
|
200
|
+
}
|
|
201
|
+
const md = removeBlock(read(AGENTS_MD), MD_BEGIN, MD_END);
|
|
202
|
+
if (md.removed) {
|
|
203
|
+
backupOnce(AGENTS_MD);
|
|
204
|
+
fs.writeFileSync(AGENTS_MD, md.text);
|
|
205
|
+
step(`Removed the codex-in-chrome block from ${AGENTS_MD}`);
|
|
206
|
+
}
|
|
207
|
+
if (isLink(SKILL_LINK)) {
|
|
208
|
+
fs.unlinkSync(SKILL_LINK); // a link only points at this repo: never delete the repo
|
|
209
|
+
step(`Removed ${SKILL_LINK}`);
|
|
210
|
+
}
|
|
211
|
+
if (fs.existsSync(MANAGED_MARK)) {
|
|
212
|
+
fs.rmSync(INSTALL_DIR, {recursive: true, force: true}); // only the copy the installer made
|
|
213
|
+
step(`Removed ${INSTALL_DIR}`);
|
|
214
|
+
}
|
|
215
|
+
console.log(`
|
|
216
|
+
Done. Also remove the extension: chrome://extensions > Codex in Chrome > Remove, then restart Codex.
|
|
217
|
+
${FROM_REPO ? `This folder (${ROOT}) can now be deleted.` : ''}
|
|
218
|
+
`);
|
|
219
|
+
process.exit(0);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// --- install ---------------------------------------------------------------
|
|
223
|
+
if (Number(process.versions.node.split('.')[0]) < 18) {
|
|
224
|
+
console.error(`Node 18 or newer is required (found ${process.version}).`);
|
|
225
|
+
process.exit(1);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const cfg = read(CONFIG);
|
|
229
|
+
if (hasUnmanagedServer(cfg)) {
|
|
230
|
+
console.error(
|
|
231
|
+
`${CONFIG} already has a [mcp_servers.${SERVER}] table that this installer did not write.\n` +
|
|
232
|
+
`Remove it first (codex mcp remove ${SERVER}) and run the installer again.`,
|
|
233
|
+
);
|
|
234
|
+
process.exit(1);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (FROM_REPO) {
|
|
238
|
+
step('Installing server dependencies');
|
|
239
|
+
const r = spawnSync(`${npm} install --omit=dev --no-audit --no-fund`, {cwd: path.join(ROOT, 'server'), stdio: 'inherit', shell: true});
|
|
240
|
+
if (r.status !== 0) process.exit(r.status ?? 1);
|
|
241
|
+
} else {
|
|
242
|
+
step(`Copying the bundled server, extension and skill to ${INSTALL_DIR}`);
|
|
243
|
+
installPayload();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
step(`Registering the MCP server in ${CONFIG}`);
|
|
247
|
+
fs.mkdirSync(CODEX_HOME, {recursive: true});
|
|
248
|
+
backupOnce(CONFIG);
|
|
249
|
+
fs.writeFileSync(CONFIG, upsertBlock(cfg, TOML_BEGIN, TOML_END, mcpBlock()));
|
|
250
|
+
console.log(args.has('--allow-tools') ? ' tools pre-approved (default_tools_approval_mode = "approve")' : ' Codex will ask before browser steps (use --allow-tools to skip the prompts)');
|
|
251
|
+
|
|
252
|
+
step(`Linking the skill at ${SKILL_LINK}`);
|
|
253
|
+
linkSkill();
|
|
254
|
+
|
|
255
|
+
if (args.has('--agents-md')) {
|
|
256
|
+
step(`Adding the rules block to ${AGENTS_MD}`);
|
|
257
|
+
backupOnce(AGENTS_MD);
|
|
258
|
+
fs.writeFileSync(AGENTS_MD, upsertBlock(read(AGENTS_MD), MD_BEGIN, MD_END, agentsBlock()));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const ff = spawnSync('ffmpeg -hide_banner -version', {stdio: 'ignore', shell: true});
|
|
262
|
+
console.log(`\nffmpeg: ${ff.status === 0 ? 'found (recordings saved as mp4)' : 'not found (recordings fall back to .avi; install ffmpeg for mp4)'}`);
|
|
263
|
+
|
|
264
|
+
console.log(`
|
|
265
|
+
Done. Two one-time steps:
|
|
266
|
+
1. Add the extension to Chrome: install "Codex in Chrome" from the Chrome Web Store (when listed), or
|
|
267
|
+
open chrome://extensions, turn on Developer mode, click "Load unpacked" and pick:
|
|
268
|
+
${EXTENSION_PATH}${process.platform === 'darwin' ? '\n (In the folder picker, press Cmd+Shift+G and paste that path: macOS hides folders starting with a dot.)' : ''}
|
|
269
|
+
2. Restart Codex (CLI session, IDE extension or desktop app) so it loads the new MCP server.
|
|
270
|
+
The extension badge shows ON once Codex has connected. Verify any time with: ${FROM_REPO ? "node scripts/install.mjs --check" : "npx codex-in-chrome check"}
|
|
271
|
+
`);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codex-in-chrome
|
|
3
|
+
description: Use when the user asks Codex to browse the web in their own Chrome, search, fill forms, upload files, run multi-tab web tasks, debug a page's console or network, record a tab to video or take screenshots. Drives the user's real Chrome (with their logins) inside a dedicated green "Codex" tab group via the codex-in-chrome MCP tools (pilot_*). Not for native desktop apps.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Codex in Chrome
|
|
7
|
+
|
|
8
|
+
Drives the user's own Chrome inside a green `"Codex"` tab group through the `codex-in-chrome` MCP server (tools are named `pilot_*`). No second browser, no remote-debugging flags, and the user's other tabs are never touched.
|
|
9
|
+
|
|
10
|
+
## Setup check
|
|
11
|
+
|
|
12
|
+
If a tool says the extension is not connected, ask the user to install the Codex in Chrome extension once (Chrome Web Store, or `chrome://extensions` > Developer mode > Load unpacked on the `extension` folder), click its icon, and retry `pilot_start`. `npx codex-in-chrome check` diagnoses the rest; if its output or the server log says a connection was refused, the user has an older unpacked copy: remove it and load the folder again.
|
|
13
|
+
|
|
14
|
+
## Loop
|
|
15
|
+
|
|
16
|
+
1. `pilot_start` (agent tabs stay behind the user's tabs; `background: false` to watch, `stealth: true` to interact like a real person).
|
|
17
|
+
2. `pilot_open` / `pilot_search` reuse the current agent tab; the result includes the page snapshot.
|
|
18
|
+
3. Find: `pilot_snapshot query="..."` for a few best matches (also searches cross-origin iframes), or one full snapshot per page. An `[f7] iframe` line is a cross-origin frame: `pilot_snapshot frame=f7` lists its controls as `f7:e3` uids. A "Not found" error lists the closest controls; use one of those.
|
|
19
|
+
4. Act with `pilot_click` (also x,y, right/double click, hover), `pilot_fill` (inputs, editors, selects, checkboxes), `pilot_press` (combos), `pilot_drag`, `pilot_scroll`, `pilot_upload`, or several at once with `pilot_batch`. Each returns a diff of what changed.
|
|
20
|
+
5. Check with `pilot_wait text=...`, `pilot_read find=...` or `pilot_screenshot`. Debug with `pilot_logs` and `pilot_eval`.
|
|
21
|
+
6. Downloads: click the link, then `pilot_downloads wait=true` for the saved path.
|
|
22
|
+
7. Clean up with `pilot_close_tab` / `pilot_close_group`. Several Codex sessions can share one Chrome; each keeps its own tab and never closes another's.
|
|
23
|
+
|
|
24
|
+
## Recording and screenshots
|
|
25
|
+
|
|
26
|
+
- `pilot_record_start` records only the agent tab, from Chrome's own renderer, so it keeps working while the tab is behind others. A REC badge shows in the page.
|
|
27
|
+
- `pilot_record_stop` encodes the video (mp4 with ffmpeg, `format: "gif"` for a shareable GIF, otherwise .avi) and returns its path.
|
|
28
|
+
- `pilot_screenshot` works on background tabs: `fullPage`, `uid` (one element), `region` (zoom into [x0,y0,x1,y1]), `clean` (hide the cursor), `png`. Files go to `~/Pictures/codex-in-chrome`; videos to `~/Videos/codex-in-chrome`.
|
|
29
|
+
|
|
30
|
+
## Token rules
|
|
31
|
+
|
|
32
|
+
- One snapshot per page; uids stay stable, so reuse them.
|
|
33
|
+
- Prefer `viewportOnly`, `snapshot: "none"`, `pilot_batch`, `pilot_read find=`.
|
|
34
|
+
- Ask for `inline` screenshots only when you must look at the page.
|