Files
leaf/.github/workflows
ericandClaude Opus 5.5 488ff345f3 feat(plugins): download the plugins a config names by url
A plugin outbound can now give a url instead of a path. With the new
plugin-fetch feature, a start downloads what the cache is missing into
<cache>/<sha256>/<file> before any outbound is built, and points the
outbounds at it; a reload, and testing an outbound, resolve from the cache
only and refuse what they would have to download.

- https only, redirects included, and only together with a sha256 pin.
- Downloads go to a temporary file, are hashed as they arrive, and are
  renamed into place only once the digest matches, under the url's own
  name, with the platform's library suffix added when it has no
  extension, which is what Windows needs to load it. A download past the
  declared size, or past 64 MiB without one, is stopped.
- The cache directory comes from FetchOptions or PLUGIN_CACHE_DIR, with
  no default: whether a directory is safe to load code from is the
  embedding app's call.
- prefetch() reports QUEUED/CACHED for every plugin before any download,
  then STARTED, PROGRESS (at most every 100 ms) and exactly one DONE or
  FAILED each, on the calling thread; the callback can cancel. A download
  that has not finished gets a PROGRESS heartbeat at least once a second,
  before STARTED too, so that one stuck connecting or in the handshake
  can be cancelled as well as one stuck mid-body.

conf gains a [Plugin] section that declares each plugin once (path, url,
sha256, size) and a `plugin` proxy protocol that refers to it by name,
with args= or args-b64= for arguments that contain commas. Proxy
parameters are now split at the first `=` only, which used to drop any
value that contained one.

leaf-ffi gains leaf_prefetch_plugins, so that an app can download the
plugins as soon as it has the config, and show progress, and the start
that follows finds everything in the cache. Events arrive as a
LeafFetchEvent whose first field is its size, on the calling thread and
never after the call returns. Adds ERR_PLUGIN_FETCH, ERR_CANCELLED and
ERR_UNSUPPORTED, and the plugin and plugin-fetch features. It is tested
by unit tests rather than end to end: the library is a Rust dylib, which
does not link in a Windows debug build (LNK1189).

Twenty-three fetch/ e2e cases download from a per-case https server
whose routes can announce a wrong length, omit it, fail, redirect, or
hold a body at a gate until the case opens it. Every case checks its
events against one statement of the progress contract, and every
failure, cancel and timeout case checks that the cache is left empty.
One checks that testing an outbound reads the cache, including a file
put there by hand, and never downloads.

The READMEs describe plugins in conf files and downloading them, and
plugin-test and CI run the new unit tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 22:26:22 +08:00
..