feat(web): add public agent-binary download endpoint that proxy-streams from Forgejo (VS-56) #74
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/VS-56-public-agent-binary-download"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add GET /api/v1/agent/binary/:id on the API server, which opens a live read of the configured upstream source (settings.agentbinaryfetcher, normally a Forgejo Generic Package registry) and streams the vervainagent- blob straight through to the client. This lets agents fetch their binary directly from the API instead of via the session-gated frontend proxy (parent VS-54), while keeping the read-only service-account token server-side: it is only sent in the outbound Authorization header to the registry, never echoed in a response header, body, or redirect.
Bytes are streamed chunk by chunk rather than buffered: a new BinarySource::stream_binary returns a StreamedBinary (boxed byte stream plus optional upstream Content-Length). The default impl buffers via fetch_binary so non-streaming sources and test doubles need no extra code; HttpSource and ForgejoSource override it to forward reqwest's bytes_stream without reading the body into memory. The handler reuses the hot-swappable refresher's source, so a live settingsupdate that swaps the source is picked up automatically.
Unknown ids surface as SourceError::BadStatus{404} and map to a clean 404; any other upstream error logs server-side and returns 502 without leaking the registry URL. The path is published as wire_paths::AGENT_BINARY_DOWNLOAD_PATH for the frontend repoint (VAPP-35) to mirror. Client-facing authorization is tracked in VS-57 and is required before public exposure.
#VS-56
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Add GET /api/v1/agent/binary/:id on the API server, which opens a live read of the configured upstream source (settings.agentbinaryfetcher, normally a Forgejo Generic Package registry) and streams the vervainagent-<id> blob straight through to the client. This lets agents fetch their binary directly from the API instead of via the session-gated frontend proxy (parent VS-54), while keeping the read-only service-account token server-side: it is only sent in the outbound Authorization header to the registry, never echoed in a response header, body, or redirect. Bytes are streamed chunk by chunk rather than buffered: a new BinarySource::stream_binary returns a StreamedBinary (boxed byte stream plus optional upstream Content-Length). The default impl buffers via fetch_binary so non-streaming sources and test doubles need no extra code; HttpSource and ForgejoSource override it to forward reqwest's bytes_stream without reading the body into memory. The handler reuses the hot-swappable refresher's source, so a live settingsupdate that swaps the source is picked up automatically. Unknown ids surface as SourceError::BadStatus{404} and map to a clean 404; any other upstream error logs server-side and returns 502 without leaking the registry URL. The path is published as wire_paths::AGENT_BINARY_DOWNLOAD_PATH for the frontend repoint (VAPP-35) to mirror. Client-facing authorization is tracked in VS-57 and is required before public exposure. #VS-56 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>