Skip to content

feat: add POST /tabs/:tabId/set_input_files endpoint#4164

Open
MrReasonable wants to merge 2 commits into
jo-inc:masterfrom
MrReasonable:master
Open

feat: add POST /tabs/:tabId/set_input_files endpoint#4164
MrReasonable wants to merge 2 commits into
jo-inc:masterfrom
MrReasonable:master

Conversation

@MrReasonable

@MrReasonable MrReasonable commented May 24, 2026

Copy link
Copy Markdown

Why

AI agents using camofox-browser often need to apply for jobs or submit documents on behalf of users. Many job sites and portals use <input type="file"> elements for CV/resume uploads — but browsers intentionally block JavaScript from setting file inputs, so a standard type or click action cannot attach a file. This endpoint fills that gap by exposing Playwright's privileged setInputFiles channel via the REST API.

What

Adds POST /tabs/:tabId/set_input_files to programmatically attach files to <input type="file"> elements.

  • Accepts either a snapshot ref (preferred, with automatic stale-ref refresh) or a CSS selector to target the file input
  • File paths are sandboxed to a configurable uploads directory (CAMOFOX_UPLOADS_DIR, default /home/node/cv-uploads) to prevent the endpoint being used to read arbitrary files from the container
  • Emits a tab:set_input_files plugin event consistent with the rest of the interaction surface
  • Full OpenAPI/Swagger documentation included

Test plan

  • Attaches file via CSS selector — filename appears in snapshot
  • Attaches file via element ref — filename appears in snapshot
  • Rejects paths outside the uploads directory with 400
  • Rejects request with neither ref nor selector with 400
  • Returns 404 for unknown tab ID
  • Full e2e test suite passes (npm run test:e2e)

🤖 Generated with Claude Code

MrReasonable and others added 2 commits May 24, 2026 08:40
Adds a new route for programmatically attaching files to <input type="file">
elements via Playwright's setInputFiles. File paths are restricted to a
configurable uploads directory (CAMOFOX_UPLOADS_DIR, default /home/node/cv-uploads)
to prevent arbitrary file exfiltration. Supports both ref-based and CSS
selector targeting, with auto-refresh of stale refs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers selector and ref-based file attachment, path-traversal rejection,
missing ref/selector validation, and 404 for unknown tabs. Global setup
now creates a temp uploads directory and passes CAMOFOX_UPLOADS_DIR to
the test server so the sandbox restriction is exercisable in CI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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