Imported from cppalliance/promptforge (
crates/harness/models/AGENTS.md). Install upstream withnpx skills add cppalliance/promptforge --skill models. Copyright stays with the author.
harness-models
This crate owns the harness's model transport: the HTTP client that performs the engine's Chat effects against the bound gateway, and the catalog fetch a host resolves model selections against. The dependency rules and the core invariants are in the ## Invariants block of src/lib.rs; this file holds only what that block does not say.
- Other protocols use separate clients; this one speaks only the always-streaming
/chat/completionsSSE shape andGET /v1/models. - The request body builder, the SSE reassembly, and the read loop (
read_body_capped,read_completion_streamover aChunkSource) are shared seams behind thepromptforge_api_runtime::modeldoor; this crate never rebuilds the body shape, re-judges a turn, or grows its own copy of the byte cap, the[DONE]rule, or the timing arithmetic. It owns only what touches the wire: sending, the request timeout, the response as a chunk source, the clock it hands the read loop, and environment loading. - Every
reqwest::Errorthis crate erases into the substrate (Http,BackendBodyRead) is boxed throughtransport_source, which applies the timeout marker, sois_timeoutholds under every variant. - The shared bearer key is wrapped in
SecretStringat the boundary;Debugredacts to a fixed marker so no presence or length signal leaks, and the key never appears inDisplayor error text. - A keyless client is an explicit choice (
GatewayClient::keyless, orfrom_envagainst a loopback URL); nothing here checks the endpoint's host on the caller's behalf. - A backend error body is bounded and control-escaped before it is kept, and rides only in the opt-in
backend_bodyaccessor, never inDisplay. A success stream is refused once it exceeds the run's byte cap, before decoding.