Skip to main content

Module file_manager

Module file_manager 

Source
Expand description

File manager — file_manager:download / file_manager:upload virtual tools. Registered automatically with no TOML manifest so sandboxed agents can move binary bytes through the proxy (network egress is otherwise confined to the proxy host).

In proxy mode the proxy performs the fetch/upload; bytes travel over the /call JSON wire as base64. The sandbox-side CLI materializes them to disk (--out) or ships them (--path). Local mode does the work inline.

Structs§

DownloadArgs
Parsed download arguments.
DownloadResult
Result of a successful download — the bytes plus discovered metadata. Intentionally NOT Clonebytes can be up to DEFAULT_MAX_BYTES.
UploadArgs
Parsed upload arguments — what the caller needs to send to the proxy. Intentionally NOT Clonebytes can be up to MAX_UPLOAD_BYTES and cloning it would be a costly footgun. Each sink consumes args by value.
UploadResult
Outcome of a successful upload — what the proxy returns to the CLI.

Enums§

FileManagerError
UploadDestination
One typed sink the operator’s manifest declares as a permitted upload destination. The agent can pick from these keys via --destination <key>; anything else is refused with a typed error.

Constants§

DEFAULT_MAX_BYTES
Default ceiling on download/upload size (500 MB).
DEFAULT_TIMEOUT_SECS
Default timeout for the upstream HTTP fetch.
MAX_UPLOAD_BYTES
Hard ceiling on upload payload accepted by the proxy (1 GB).

Functions§

build_download_response
Build the JSON response payload that the proxy / local-mode core returns to the CLI. Always carries content_base64 so the CLI can write to --out or print inline depending on caller intent.
build_upload_response
enforce_download_allowlist
Reject the URL if ATI_DOWNLOAD_ALLOWLIST is set and the host doesn’t match. When the env var is unset or empty, downloads to any (non-private) host are allowed — local-mode operators who want a wide-open dev experience can leave the allowlist off; production proxies should always set it.
fetch_bytes
Perform the actual HTTP fetch. Streams the body and aborts if it exceeds max_bytes.
guess_content_type
Best-effort MIME type from a path’s extension. Shared across file_manager:* tools and CLI output capture. Falls back to octet-stream.
resolve_destination
Resolve a caller-supplied (or omitted) destination key against the operator manifest’s allowlist. Refuses any key not in the map with a typed error.
upload_to_destination
Dispatch an upload to one of the operator-allowlisted destinations. Resolves the requested key (or default) against the manifest’s destinations map, then routes to the typed sink. Refuses any key not in the map.