codex-cu
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCodex computer use
Codex 电脑使用
cua_replcodex-cuThe long write-up is the Claude artifact . Open it in Arc
when this file does not answer a case.
codex-cu 接線手冊cua_replcodex-cu详细说明文档是 Claude 工件 。当本文档无法解答某个问题时,请在 Arc 中打开它。
codex-cu 接線手冊Setup (once per machine)
安装设置(每台机器只需执行一次)
Codex does not need this: is native there. For Claude Code, Cursor
and agy, run the check first:
cua_replbash ~/.agents/skills/codex-cu/scripts/check-codex-cu.shPASS: setup is done. Skip this section. The check never opens an app, so a
PASS is not proof that an app call works. SKIP with :
the user must install the ChatGPT Mac app and its Computer Use plugin, then use
computer use there once (that grants Screen Recording and Accessibility). A
FAIL (the installer says SKIP ): show the user the reason text after the colon.
Only a missing or empty plugin cache means "still downloading, try later". In both
cases stop and tell them. Any other FAIL, or no tool: ASK the user
which mode. Never pick for them:
no Computer Use pluginlauncher cannot resolve a usable versionno usable Computer Use version yetcodex-cu- : accept every prompt from codex-cu with no question, including any that is not an app prompt. Logged-in pages in a browser app become readable.
all - : auto-accept Calculator, TextEdit, Preview, Freeform. It is an auto-accept list, not a sandbox: Claude still asks the user for other apps and the user may accept them; agy and Cursor are refused for other apps. The browser surface has no per-app approval in either mode.
safe
Then run:
bash ~/.agents/skills/codex-cu/scripts/install-codex-cu.sh all # or: safeIt installs into , registers at user scope for Claude
Code and Cursor when their config file exists and for agy when the command
exists (the check prints a line per registered runtime), writes , and ends with the
check. If you cannot ask (print mode, worker), stop and show the user both
commands. After setup, tell the user to start a new session: MCP servers load
at session start. To switch mode later, run the installer with the other word,
or edit the policy file (it takes effect at the next prompt, no restart).
~/.local/bincodex-cuagy~/.config/codex-cu/approveThe installer skips the first gate on purpose. Terminal, system settings and
Codex itself stay until the user runs
themselves.
forbiddendefaults write -g ComputerUseAllowForbiddenTargets -bool YESCodex 无需此操作: 是其原生内置的。对于 Claude Code、Cursor 和 agy,请先运行检查脚本:
cua_replbash ~/.agents/skills/codex-cu/scripts/check-codex-cu.shPASS:设置已完成,可跳过本节。该检查不会打开任何应用,因此 PASS 不代表应用调用一定能正常工作。
检查结果为 SKIP 且提示 :用户必须安装 ChatGPT Mac 应用及其 Computer Use 插件,然后在其中使用一次电脑使用功能(这会授予屏幕录制和辅助功能权限)。
检查结果为 FAIL 且提示 (安装程序会显示 SKIP ):向用户展示冒号后的原因文本。
只有插件缓存缺失或为空时才意味着「仍在下载,请稍后再试」。出现以上两种情况都请停止操作并告知用户。
其他任何 FAIL 情况,或不存在 工具时:询问用户要使用哪种模式,切勿替用户选择:
no Computer Use pluginlauncher cannot resolve a usable versionno usable Computer Use version yetcodex-cu- :无疑问地接受 codex-cu 的所有提示,包括非应用类提示。浏览器应用中的登录态页面将变为可读取状态。
all - :自动接受计算器(Calculator)、文本编辑(TextEdit)、预览(Preview)、无边记(Freeform)。这是一个自动接受列表,而非沙箱限制:Claude 仍会就其他应用向用户请求授权,用户可以选择接受;但 agy 和 Cursor 会被拒绝访问其他应用。两种模式下,浏览器层面都没有按应用审批的机制。
safe
然后运行:
bash ~/.agents/skills/codex-cu/scripts/install-codex-cu.sh all # or: safe该脚本会安装到 目录;当 Claude Code 和 Cursor 的配置文件存在时,会在用户作用域为它们注册 ;当 命令存在时,会为 agy 注册(检查脚本会为每个已注册的运行时打印一行信息)。脚本还会写入 文件,最后以检查步骤结束。
如果你无法询问用户(如打印模式、worker 模式),请停止操作并向用户展示这两条命令。
设置完成后,告知用户需要启动新会话:MCP 服务器会在会话启动时加载。
后续如需切换模式,可使用另一个模式参数重新运行安装脚本,或编辑策略文件(更改会在下一次提示时生效,无需重启)。
~/.local/bincodex-cuagy~/.config/codex-cu/approve安装程序会故意跳过第一道门禁。终端、系统设置和 Codex 本身会保持「禁止」状态,直到用户自行运行 命令。
defaults write -g ComputerUseAllowForbiddenTargets -bool YESTwo surfaces
两个操作层面
Computer surface treats the target as an app. Read the AX tree, then click or
type. This surface does not need turn metadata. is the
launcher.
scripts/codex-cu-mcpBrowser surface enters the page. Read the DOM, run JS, use Playwright locators.
Each needs Codex turn metadata. injects
. Computer surface does not need the metadata,
but its app approvals also go through the proxy (see below).
tools/callscripts/codex-cu-proxy_meta["x-codex-turn-metadata"]cua.getState()appsbrowsersbrowsers电脑层面(Computer surface) 将目标视为应用。读取 AX 树,然后执行点击或输入操作。该层面不需要轮次元数据(turn metadata)。启动器为 。
scripts/codex-cu-mcp浏览器层面(Browser surface) 会进入页面内部。读取 DOM、运行 JS、使用 Playwright 定位器。每次 都需要 Codex 轮次元数据。 会注入 。
电脑层面不需要元数据,但其应用授权也会通过代理处理(见下文)。
tools/callscripts/codex-cu-proxy_meta["x-codex-turn-metadata"]cua.getState()appsbrowsersbrowsersPick Chrome, not Arc
选择 Chrome,而非 Arc
Arc and Chrome both report . The numeric is not stable.
can be absent. Do not use either as the only test.
name: "Chrome"idprofileName- Call .
cua.listBrowsers() - Read .
metadata.extensionInstanceId - Confirm the host parent before a long call.
sh
ps -o ppid= -p $(pgrep -f "ChatGPT for Chrome")The parent path is Arc or Google Chrome. Sample from 2026-10-05. Re-check
after a reload. Do not reuse these values once the parent check disagrees.
- Arc:
33f909be-429f-479e-b1c2-20bba462cbf3 - Chrome:
75ef88d3-a921-455b-b39e-b40ed5ec2771
createBrowserTabnameSessionabout:blankArc 和 Chrome 都会返回 。数字 不稳定, 可能不存在。请勿将这两者作为唯一判断依据。
name: "Chrome"idprofileName- 调用 。
cua.listBrowsers() - 读取 。
metadata.extensionInstanceId - 进行长时间调用前确认宿主父进程。
sh
ps -o ppid= -p $(pgrep -f "ChatGPT for Chrome")父进程路径为 Arc 或 Google Chrome。以下是 2026-10-05 的示例值。重新加载后请再次检查。一旦父进程检查结果不一致,请勿再复用这些值。
- Arc:
33f909be-429f-479e-b1c2-20bba462cbf3 - Chrome:
75ef88d3-a921-455b-b39e-b40ed5ec2771
在 Arc 实例上调用 和 不会返回结果。即使等待 120 秒仍会失败,且调用可能会留下 空白页。
createBrowserTabnameSessionabout:blankBrowser surface
浏览器层面
Use the Chrome instance from the parent check. One call per step.
js- .
cua.getBrowser({ extensionInstanceId }) - with a short name, before any new tab.
browser.nameSession - Record ids from .
browser.user.openTabs() - Open one new tab and go to the URL.
- Check the page. On example.com, is visible.
getByRole("link", { name: "Learn more", exact: true }) - Close only that tab.
- Read again. Prior ids match. The new id is gone.
openTabs()
A tab stays on the that created it. A refused
can still leave . Close it in that same session. Set on
the proxy when you must reuse the session.
session_idcreateBrowserTababout:blankCU_SIDdocument.cookiechrome://Rehearsal that passed 2026-10-05: select , returns
at once, , , the new tab is
closed, the prior tab ids are unchanged.
75ef88d3-…nameSessionURL=https://example.com/learnMoreVisible=true使用通过父进程检查确认的 Chrome 实例。每步执行一次 调用。
js- 调用 。
cua.getBrowser({ extensionInstanceId }) - 在打开任何新标签页前,使用短名称调用 。
browser.nameSession - 记录 返回的标签页 ID。
browser.user.openTabs() - 打开一个新标签页并访问目标 URL。
- 检查页面。在 example.com 上,元素应可见。
getByRole("link", { name: "Learn more", exact: true }) - 仅关闭该新标签页。
- 再次读取 。之前的 ID 应保持一致,新的 ID 已消失。
openTabs()
标签页会归属于创建它的 。即使 被拒绝,仍可能留下 页面,请在同一会话中关闭它。如需复用会话,请在代理上设置 。
session_idcreateBrowserTababout:blankCU_SID不支持 操作。不允许访问 开头的 URL。没有悬停方法。浏览器层面不会发起按应用授权的请求。
document.cookiechrome://2026-10-05 通过的演练流程:选择 实例, 立即返回,,,新标签页被关闭,原有标签页 ID 保持不变。
75ef88d3-…nameSessionURL=https://example.com/learnMoreVisible=trueComputer surface
电脑层面
Arc on this surface is an app, not a browser target.
- Open a URL with . Command-T is less stable.
open -a Arc "<url>" - . Use the display name. Do not use a bundle id.
cua.getApp("Arc") - After a page change, . The first read can show the old page.
getAXState({ disableDiffing: true }) - Click by element index. Use when
setValuechanges case.typeText
cua.computer.launch_appcua.listWindowsgetAppAllow Computer Use to use X?~/.config/codex-cu/approve- on its own line: accept every prompt (full mode, the deploy default).
all - One display name per line: accept only those apps (safe mode).
- mixed with names means only those names.
all - Any other app, or no policy file: the prompt goes to the client. agy and cursor-agent cannot answer, so the proxy declines it for them. With no file, every app is refused in agy and Cursor.
- A Claude hook that accepts codex-cu prompts overrides
Elicitationfor forwarded apps. Remove such a hook; the policy file is the single source.safe
scripts/test-codex-cu-proxyShutdown: once the proxy has seen the client close stdin, it drops (and logs)
an approval prompt instead of answering or forwarding it. A prompt already
forwarded can still meet the close. in the log means the
reply was queued to the child. After the child exits, the proxy waits while
output still reaches the client; after 30 s with no progress it ends non-zero
(output may be incomplete), at most 5 s later if stderr is blocked.
elicitation acceptA refusal reads . Add the display name
to the file; the next prompt reads it, no restart. The Chrome display name is
.
Computer Use was not approved to use XGoogle Chrome该层面下的 Arc 是一个应用,而非浏览器目标。
- 使用 打开 URL。Command-T 快捷键的稳定性较差。
open -a Arc "<url>" - 调用 。请使用显示名称,不要使用 bundle ID。
cua.getApp("Arc") - 页面变更后,调用 。首次读取可能仍显示旧页面。
getAXState({ disableDiffing: true }) - 通过元素索引进行点击。当 会改变大小写时,请使用
typeText。setValue
该运行时中不包含 和 。
cua.computer.launch_appcua.listWindowsgetApp~/.config/codex-cu/approve- 单独一行写 :接受所有提示(完整模式,部署默认值)。
all - 每行一个显示名称:仅接受这些应用(安全模式)。
- 与应用名称混合存在时,仅接受列出的应用。
all - 其他任何应用,或不存在策略文件时:提示会转发给客户端。agy 和 cursor-agent 无法应答,因此代理会替它们拒绝请求。没有策略文件时,agy 和 Cursor 会被拒绝访问所有应用。
- 若 Claude 有一个接受 codex-cu 提示的 钩子,会覆盖转发应用的
Elicitation模式限制。请移除这类钩子;策略文件是唯一的可信来源。safe
scripts/test-codex-cu-proxy关闭逻辑:一旦代理检测到客户端关闭了标准输入,它会丢弃(并记录)授权提示,而不是应答或转发。已经转发的提示仍可能遇到关闭事件。日志中的 表示回复已排入子进程的队列。子进程退出后,代理会继续等待,直到输出全部送达客户端;若 30 秒内无进展,代理会以非零状态退出(输出可能不完整);如果标准错误流被阻塞,最多再等待 5 秒后退出。
elicitation accept拒绝提示的内容为 。将应用的显示名称添加到策略文件中即可,下一次提示时会自动读取,无需重启。Chrome 的显示名称是 。
Computer Use was not approved to use XGoogle ChromeDo not
禁止事项
WARNING: returns the window text. Do not bind Notes, Mail, Messages,
Keychain Access, a password manager, or a terminal unless the user names that
app in the current message.
getApp- Do not treat a metadata error as a dead computer surface.
- Do not pick a browser by numeric id.
- Do not call or
nameSessionon the Arc instance.createBrowserTab - Do not close tabs that were already open.
警告: 会返回窗口文本。除非用户在当前消息中明确指定了应用,否则不要绑定备忘录(Notes)、邮件(Mail)、信息(Messages)、钥匙串访问(Keychain Access)、密码管理器或终端。
getApp- 不要将元数据错误视为电脑层面操作失效。
- 不要通过数字 ID 选择浏览器。
- 不要在 Arc 实例上调用 或
nameSession。createBrowserTab - 不要关闭已经打开的标签页。
Not tested
未测试场景
Logged-in Chrome pages, a Stop hook that sends , many Chrome
profiles, Arc and Chrome at the same time, Freeform drag, AppleScript JS
inside Arc, and over SSH.
turn_endedclaude setup-tokenChrome 登录态页面、发送 的 Stop 钩子、多 Chrome 配置文件、Arc 和 Chrome 同时运行、Freeform 拖拽、Arc 内的 AppleScript JS、通过 SSH 运行 。
turn_endedclaude setup-token