Skip to content

Sandbox script-API: binary readFile, uploadFile(), domCua ids/errors, addInitScript guard - #121

Open
ao-kamal wants to merge 4 commits into
SawyerHood:mainfrom
ao-kamal:ergo/sandbox-api
Open

Sandbox script-API: binary readFile, uploadFile(), domCua ids/errors, addInitScript guard#121
ao-kamal wants to merge 4 commits into
SawyerHood:mainfrom
ao-kamal:ergo/sandbox-api

Conversation

@ao-kamal

Copy link
Copy Markdown

Script-API ergonomics fixes from an agent-ergonomics review.

  • readFile() binary mode — hardcoded UTF-8 silently corrupted binary (a screenshot read back became replacement chars). Adds readFile(name, "base64") for lossless round-trips; default unchanged.
  • uploadFile() helper — uploads required hand-rolling canvas→File→DataTransfer because setInputFiles({path}) fails in the sandbox. Adds a daemon-side helper that calls real Playwright setInputFiles with a FilePayload buffer (which works). Verified landing a real file on a real page.
  • domCua node ids now start small/sequential (1,2,3…) matching the --help examples, via a navigation-proof per-document seed so cross-document ids never collide.
  • Split the collapsed "DOM node N is stale" error into four actionable messages (unknown id / frame gone / element gone / scroll timeout).
  • addInitScript() now fails fast with an authored message for all forms (unworkable in the sandbox — inject via page.evaluate() after navigation).
  • Doc honesty in the embedded --help guide (sandbox exceptions to "full Playwright Page objects").

New vitest coverage; full daemon suite green.

ao-kamal and others added 4 commits July 12, 2026 14:52
readFile() hardcoded UTF-8 decoding, silently corrupting binary (a screenshot
read back became replacement chars). Add an { encoding: "base64" } option
threaded through the sandbox bridge to temp-files, returning raw bytes as
base64 for lossless round-trips. Default remains utf8.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit 9b5802f)
…help (P1-2, P2-2)

skills/dev-browser/SKILL.md: replace the 19-line "run --help" stub with a
condensed agent guide (method ladder, timeout clocks, named-page/daemon rules,
sandbox limits). cli/llm-guide.txt: note DOM globals exist only inside
page.evaluate(); add an exceptions block for setInputFiles/addInitScript with
the canvas-inject upload workaround.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit 16928a3)
…ch fs limits (P2-3, P2-4)

- domCua node ids now start small and sequential (1,2,3…) matching --help,
  via a navigation-proof per-document seed block so cross-document ids never
  collide (a naive seed=1 would silently resolve stale ids to wrong elements).
- Split the one collapsed "DOM node N is stale" error into four actionable
  messages (unknown id / frame gone / element gone / scroll timeout).
- Authored error for the sandbox fs/path stubs (setInputFiles(path),
  addInitScript({path})) naming the limitation and the canvas-inject / {content}
  workarounds, replacing the opaque failure.
- Skip (not fail) the symlink test when the host can't create symlinks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit f0a85ed)
…st (P2-1, P2-3)

- uploadFile(pageName, selector, { name, mimeType, base64|buffer }) — a daemon-side
  host helper that calls real Playwright setInputFiles with a FilePayload buffer
  (which works; only the host-path form fails in the sandbox). Verified landing a
  real file on a real page. Ends the hand-rolled canvas-inject dance for uploads.
- addInitScript() now fails fast with an authored error for ALL forms
  (function/string/content/path) — every form is unworkable in the sandbox; inject
  via page.evaluate() after navigation instead.
- Shipped skill: note readFile(name, "base64") for binary.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit 11867a6)
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