Skip to content

fix(execute): explain Node-side execute failures and keep extension builds loadable - #100

Open
safzanpirani wants to merge 2 commits into
anomalyco:mainfrom
safzanpirani:fix/agent-papercuts
Open

safzanpirani wants to merge 2 commits into
anomalyco:mainfrom
safzanpirani:fix/agent-papercuts

Conversation

@safzanpirani

Copy link
Copy Markdown

Summary

This PR fixes three failures that agents hit repeatedly while using Browser Control.

  • Page globals in Node-side execute code. Execute code runs in Node, and agents often write it as page code. window.location.href fails with ReferenceError: window is not defined, and fetch("/api/me") fails with TypeError: Failed to parse URL from /api/me, with no hint about the cause. Execute now adds a warning for both errors that points to page.evaluate. The Execute Interface section of the skill now states that execute code runs in Node.
  • execute --file errors without a reason. A missing or unreadable file produced only read execute file /tmp/chat_.js. The message now includes the file-system reason, as doctor already does for its read errors. For example, read execute file /tmp/chat_.js: NotFound: FileSystem.readFile (/tmp/chat_.js).
  • pnpm build:extension deleted extension/dist before building. If esbuild failed, the unpacked extension directory stayed empty and Chromium could not load it on the next worker start. The extension build now writes into a staging directory under the OS temp directory. It then copies each file into extension/dist, renames it into place, and removes stale entries. The directory and manifest.json stay in place during the build, and a failed build leaves the previous output untouched. --outdir keeps its existing fresh-directory rules, and build:cli is unchanged.

Verification

  • pnpm run ci, the runtime:prepare step from CI, and pnpm typecheck pass locally. pnpm test passes 971 tests in 69 files, and pnpm audit:duplicates finds 0 clones.
  • I did not run the browser smoke set.
  • A new unit test in test/execute-ergonomics.test.ts covers the window and relative fetch warnings. It also checks that an unrelated ReferenceError and an in-page page.evaluate error get no warning.
  • A second pnpm build:extension kept the same extension/dist inode and removed a stale file. A build with a syntax error in background.ts exited 1 and left manifest.json and the previous background.js byte-identical. No temp files remained in dist or the staging location.
  • execute --file with a missing path prints the reason shown above, before any relay contact.

…uilds loadable

Execute code runs in Node, and agents often write it as page code. A bare
`window is not defined` or `Failed to parse URL from /api/...` did not say
why. Execute now adds a warning for both errors that points to
page.evaluate, and the skill states the Node boundary.

`execute --file` errors now include the file-system reason, as doctor
already does for its read errors.

`pnpm build:extension` deleted extension/dist before building, so a failed
build left the unpacked extension directory empty. The extension build now
writes into a staging directory under the OS temp directory and replaces
extension/dist file by file. The directory and manifest stay in place, and
a failed build leaves the previous output untouched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant