Function hostFetchStream

  • Stream a response through the host's parent-fetch proxy (§5.11 streaming; LLM_AND_AGENTS_SPEC §2.2) — the streaming counterpart of hostFetch, for SSE / LLM token streaming. Same net:fetch gate (manifest ∩ consent), same credential-less rule and per-hop SSRF re-check; the response body is pumped as a sequence of HostFetchStreamEvent chunks instead of a single buffered reply.

    let body = '';
    for await (const { chunk } of hostFetchStream(url, { method: 'POST', body })) {
    body += chunk; // e.g. parse SSE / token deltas as they arrive
    }

    The generator returns a HostFetchStreamResult (status + headers + truncated/bytes) when the body completes. A gate/SSRF/transport failure — or one of the host's stream bounds — throws a StreamError (from ./protocolStream) carrying a machine .code: forbidden (outside the allowlist), blocked (SSRF target), invalid (bad url/scheme), redirect (the host refuses to follow redirects), idle-timeout / total-timeout (the host's stream bounds), byte-cap, or network. The stream is bounded by the host's idle/total timeouts and a cumulative byte cap, so it cannot be used as an unbounded transfer channel.

    Requires the host to implement the protocol-fetch streaming emitter; until that lands a streaming request fails with not-streamable and callers should fall back to hostFetch (LLM_AND_AGENTS_SPEC §2.2, roadmap P3-71).

    Parameters

    Returns AsyncGenerator<HostFetchStreamEvent, HostFetchStreamResult, void>