Repository navigation
feat(desktop): keep an agentenv computer up and drive it through REA's MCP tools - #9041
Conversation
[Medium impact] The PR adds a locally configured desktop-computer workflow to REA's MCP server. Fix the request-build launch paths before merging; valid archive names and Electron apps can leave the computer without a working application. FindingsFix with agent prompt### Issue 1
src/domain/desktop/appBuild.ts:159
`renderReaInstallScript` writes the archive's entrypoint path into the `rea` launcher without shell quoting. An otherwise valid archive with a top folder such as `REA Build` passes the file check, but the generated launcher makes Node open `/opt/rea/payload/REA` instead of `scripts/rea.mjs`. Copy the entrypoint to a fixed path, or shell-quote it when generating the launcher.
### Issue 2
src/domain/desktop/appBuild.ts:272
If an Electron app's desktop command does not include `--no-sandbox`, `renderBuildModule` launches it unchanged and the app exits. The existing export path adds that flag because the computer's container does not grant the user namespaces Chromium needs. The request path neither applies that adjustment nor offers a launch override, so installing the app can succeed while opening it from the Applications menu fails. Reuse the Electron launch policy when preparing the installed app's command.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryAdds three MCP tools that start, drive and close a local agentenv computer.
DiagramsequenceDiagram
participant A as MCP caller
participant R as REA
participant H as Python helper
participant C as agentenv computer
A->>R: start_build_computer
R->>H: "run_bundle(keep=True)"
H-->>R: Private URLs, token and sandbox id
R->>C: Connect MCP and wait for readiness
R->>C: computer_screenshot
R-->>A: computer_id and image
A->>R: act_on_build_computer
R->>C: computer action
C-->>R: Driver result
R-->>A: Result and images
A->>R: close_build_computer
R->>H: Close stdin
H->>C: Teardown
alt Teardown is unconfirmed
R->>C: Remove exact sandbox containers
end
Reviews (8) · Last reviewed commit: "fix(desktop): bound a build computer's a..." · Reviewed by Greptile |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> # Conflicts: # docs/desktop-build-computer.md # src/application/desktop/DesktopApplicationExport.ts # src/application/desktop/DesktopBuildComputers.ts
…ld witness Co-Authored-By: Claude Opus 5.5 <[email protected]>
…build witness Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
…s MCP tools - A Python helper keeps one agentenv computer up per build with run_bundle(keep=True) and reports its address, MCP URL, control token and sandbox id; it tears the computer down when stdin closes. - AgentEnvComputer owns the helper, waits for readiness, holds one MCP session to the computer's computer_* tools, records through the computer-recording routes, and removes the sandbox's containers by label when agentenv cannot confirm teardown. The token never leaves it. - start_build_computer starts a computer from a request (archive package, apt repository or .deb, opened on demand with REA in /opt/rea) or from a bundle folder; act_on_build_computer forwards screenshot, click, drag, scroll, type, key and wait and returns the driver's images unchanged; close_build_computer tears it down. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nv cannot confirm teardown agentenv's local provider runs an ordinary computer as agent-<sandbox id> without the agentenv.sandbox label, so the label-only fallback found nothing and reported a running computer as removed. The fallback now lists containers by exact name and by label. The real test holds its recording open long enough for a first frame, checks the container by name, and runs rea inside the computer; the guide and tool descriptions say the app opens from the Applications menu and that a screenshot after opening a menu should come from a wait. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ed screenshots, bound recordings - A start is owned from the helper's spawn. One that fails and whose teardown is unconfirmed stays held under a computer_id close can retry; closeAll refuses new starts, cancels and joins starts in progress, then closes every held computer. - When the first screenshot is too large, the error carries REA's result with the computer_id, and start_build_computer takes screenshot region, format and quality. - Recordings are refused before reading when the manifest's total exceeds the allowance, then fetched one segment at a time, each read bounded and checked against its size and sha256. - The helper keeps the tail of its output (a new tail retention mode in ProviderProcessSupervisor), so a build's own error is not crowded out. - A helper that reported no computer exits on its own before SIGTERM, so no phantom owner is kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every action kept its full arguments for the computer's whole life, so a long session grew REA's memory without limit. The log now keeps the latest 256 actions within 256 KiB, cuts each string to 1 KiB and each list to 64 items (naming what it cut), and keeps the total and the last applied index of each kind of action, so rules over the whole session hold after entries drop. Co-Authored-By: Claude Opus 5.5 <[email protected]>
f01cc95 to
d950792
Compare
| exit 1 | ||
| fi | ||
| ln -sf /opt/rea/node-v${BUILD_NODE_VERSION}-linux-*/bin/node /usr/local/bin/node | ||
| printf '#!/bin/sh\\nexec /usr/local/bin/node %s "$@"\\n' "$1" > /usr/local/bin/rea |
There was a problem hiding this comment.
renderReaInstallScript writes the archive's entrypoint path into the rea launcher without shell quoting. An otherwise valid archive with a top folder such as REA Build passes the file check, but the generated launcher makes Node open /opt/rea/payload/REA instead of scripts/rea.mjs. Copy the entrypoint to a fixed path, or shell-quote it when generating the launcher.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/desktop/appBuild.ts
Line: 159
Comment:
**Archive spaces break `rea`**
`renderReaInstallScript` writes the archive's entrypoint path into the `rea` launcher without shell quoting. An otherwise valid archive with a top folder such as `REA Build` passes the file check, but the generated launcher makes Node open `/opt/rea/payload/REA` instead of `scripts/rea.mjs`. Copy the entrypoint to a fixed path, or shell-quote it when generating the launcher.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| packages=Packages(apt=${pyList(install.packages)}),${sources} | ||
| downloads=[${install.downloads.join(", ")}], | ||
| run=[${install.scripts.map((script) => `RunScript(script=${py(script)})`).join(", ")}], | ||
| launch=Launch(at="demand", command=${pyList(["gtk-launch", entry])}${window}), |
There was a problem hiding this comment.
If an Electron app's desktop command does not include --no-sandbox, renderBuildModule launches it unchanged and the app exits. The existing export path adds that flag because the computer's container does not grant the user namespaces Chromium needs. The request path neither applies that adjustment nor offers a launch override, so installing the app can succeed while opening it from the Applications menu fails. Reuse the Electron launch policy when preparing the installed app's command.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/desktop/appBuild.ts
Line: 272
Comment:
**Electron apps cannot open**
If an Electron app's desktop command does not include `--no-sandbox`, `renderBuildModule` launches it unchanged and the app exits. The existing export path adds that flag because the computer's container does not grant the user namespaces Chromium needs. The request path neither applies that adjustment nor offers a launch override, so installing the app can succeed while opening it from the Applications menu fails. Reuse the Electron launch policy when preparing the installed app's command.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Summary
This lets Claude Code drive an agentenv computer through REA's own MCP tools. It is the second of four PRs for "a bundle from a request", where the requester's Claude builds a computer-app environment by using the app inside a computer. Claude Code can't attach a new MCP server mid-session, so REA forwards the computer's actions itself.
Problem and expected behavior
There was no way for an agent connected to REA to act on a computer. After this change:
start_build_computerbrings up a computer, either from a request (an archive package, an apt repository or a.deb, with REA installed inside for building) or from an existing bundle folder. It returns the first screenshot.act_on_build_computerforwards screenshot, click, drag, scroll, type, key and wait to the computer's owncomputer_*tools and returns their images unchanged.close_build_computertears it down.Change and scope
bridge/agentenv/computer.py.run_bundle(keep=True)and prints one JSON line: base URL, MCP URL, control token and sandbox id.REA_AGENT_ENV_COMMAND.AgentEnvComputer.tsandAgentEnvComputerHelper.ts./agentenv/ext/computer-ready/statusand holds one MCP session to the computer's/mcp.computer-recordingroutes under REA's request id. It is internal, for the witness in PR 3.DesktopBuildComputers.tskeeps an action log per computer and closes every computer when the server closes.appBuild.tsreuses the export's install planning and Python rendering.REA_BUILD_COMPUTER_REA_ARCHIVE) or a download, unpacked by a rootRunScriptinto/opt/rea.computerActions.tstranslatesctrl+sinto W3C key names and checks each action's arguments.ToolResultDelivery.toForwardedToolResultpasses images through within the result budget.applicationfamily, a capability service, the MCP-only CLI-parity list and catalog entries.9d05a2b15):computer_idthat close can retry.closeAllrefuses new starts and joins those in progress.computer_id, andstart_build_computertakes screenshot options.tailretention mode inProviderProcessSupervisor).30d55a3f5): a computer keeps its latest 256 actions within 256 KiB, each string cut to 1 KiB and each list to 64 items, with the total and the last applied index of each kind of action.docs/desktop-build-computer.mdanddocs/specs/desktop-app-environments/build-computer/.Contract and boundary impact
applicationfamily.Expected effects:
Evidence and regression coverage
buildComputerMcp.test.ts(8 scenarios) andbuildComputerRecording.test.tsrun REA's real helper against a fakeagent_envpackage and a fake driver, with no Docker or network.appBuild.test.tsandcomputerActions.test.tscover the bundle and the actions.buildComputerReal.test.ts,REA_BUILD_COMPUTER_REAL=1): passes on an Ubuntu 24.04 amd64 VM with agentenv-framework 0.9.1431, in 24–27 s with the image cached.rea mcpover stdio):ctrl+s, chose Documents and saved.~/Documents/build-note.txtholds the line.rea --versionanswers from/opt/rea.agent-<sandbox id>without a label. So a label-only fallback reported a running computer as removed. The fallback now uses name and label, and a boundary test covers both.For evidence-bearing changes:
Validation performed
npm run typecheck,format:check,build:cachedthenknip,jscpd,docs:check,docs:build,verify:test-discovery,verify:architecture-guards,verify:module-boundariesandmcp-catalog:check.createServer.tsandtoolEffects.tsalready carry the same size warnings on main.lintfails only on main'stests/acceptance/webSourceLocationCli.test.ts.Compatibility, safety, and release
bridge/agentenv/computer.pyis added to the package'sfiles.Known gaps:
npm packplus a production install, as last night's spike did./opt/agentenv/apps/<name>, so its Save As dialog opens on build-only files./tmpstays behind.Author readiness
Human owner: @earakely-scale
Before merge
type(scope): outcome.🤖 Generated with Claude Code