Skip to main content

Module browser_uploads

Module browser_uploads 

Source
Expand description

Which files an agent may upload into a browser pane (docs/specs/SPEC_AGENT_DRIVEN_BROWSER_PANES_2026_10_07.md §5.3): only files inside its own workspace, so a page (or a tricked agent) can’t use an upload field to carry off anything else on the machine.

Structs§

UploadFile 🔒
A file ready to hand to the page: its name, a content type from its extension, and its bytes.

Constants§

MAX_UPLOAD_BYTES 🔒
At most this many bytes in one upload, all files together. Bigger files are for the user to pick (BrowserHandoff).
MAX_UPLOAD_FILES 🔒
At most this many files per upload.

Functions§

agent_workspace 🔒
The workspace the agent on block_id was launched in, if srv started it as a host agent.
canonical 🔒
canonicalize without Windows’ \\?\ verbatim prefix, which the browser doesn’t expect in a file path.
check_upload_paths 🔒
Check paths (absolute, or relative to the workspace) and return their canonical forms: each must be an existing file inside workspace after resolving .. and symlinks.
handle_path 🔒
launch_workspaces 🔒
mime_for 🔒
A content type for the file, from its extension, as a browser’s own file picker would give it. An extension not known here gets no type at all (empty), as the picker gives one it doesn’t know, rather than a forced generic one a page might reject.
read_upload_files 🔒
Read the files check_upload_paths approved. Each is opened once, and the check is repeated on the open handle: the file it really refers to must be a regular file inside the workspace. The bytes are read from that same handle and the page is given the bytes, never a path, so replacing a checked file with a link afterwards changes nothing.
record_launch_workspace 🔒
Remember the workspace the agent on block_id was started in: the AGENTMUX_AGENT_WORKDIR srv just put in its spawn env (host agents only; a container agent has none). Called by every spawn path right after agent_handlers::input::carry_agent_workdir_env.