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§

CONTAINER_WORKSPACE 🔒
Where a container agent sees its workspace.
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.
container_view 🔒
What a container agent is told when a file it named is not inside its workspace: the same as for a file that isn’t there, so a link in the workspace can’t be used to ask whether a host path exists.
container_workspace 🔒
The host folder behind /workspace for the container agent on block_id.
files_for_agent 🔒
The files paths name, read for the agent on own (its block) as the objects the page is given: name, type and base64 bytes. They come from the agent’s own workspace only: where srv launched a host agent (not its block’s cmd:cwd, which any client can rewrite, spec §5.3), or the folder behind a container agent’s /workspace, whose answers never name the host folder. Up to 25 MB of file I/O and base64 happens off the async workers.
handle_path 🔒
map_container_paths 🔒
The host paths for files a container agent names: /workspace/..., or a path relative to its workspace. Anything else in the container (its home, /tmp) isn’t on the host and isn’t uploaded, and neither is a path with .. in it, which would reach the host folders beside the workspace. The result goes through check_upload_paths like a host agent’s, which resolves links on the host: a link in the workspace that leads outside it is refused.
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_container_workspace 🔒
Remember the host folder mounted at /workspace in the container of the agent on block_id, as srv started it: the mount’s source, not the block’s cmd:cwd, which any client can rewrite after the launch. Called where the container’s mounts are decided.
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 spawn_env::block_identity::carry_agent_workdir_env.