Expand description
Foundational header primitives for the LLM router workspace.
This crate provides:
HeaderName— a case- and order-preserving header name backed by [SmolStr].HeaderValue— a header value stored asCow<'static, str>for zero-cost static defaults.HeaderMap— aVec-backed map that preserves insertion order and original case while supporting case-insensitive lookup and duplicate names.keys— a catalogue of staticHeaderNameconstants for popular headers.TemplateVars— per-request correlation metadata extracted from inbound headers, shared between header rendering and provider header construction.HeaderSchema— a trait implemented by typed (provider, client) header structs to round-trip between their typed form and aHeaderMap.HeaderNormalizer— a trait for rebuilding client-derived headers into a provider-owned wire shape.schemas— concrete client/overlay structs implementingHeaderSchema.agent— agent-specific outbound header builders.registry— runtime lookup of (AgentKind,OverlayKind) for a given(provider_id, agent_id)pair.
Phase 1 is purely additive: nothing in the workspace depends on this crate
yet. Phase 2 will swap HeaderMap in for reqwest::header::HeaderMap
workspace-wide; Phase 3 will route provider header construction through the
schema registry.
Re-exports§
pub use agent_id::AgentId;pub use error::Error;pub use map::HeaderMap;pub use name::HeaderName;pub use normalizer::HeaderNormalizeCtx;pub use normalizer::HeaderNormalizer;pub use schema::HeaderSchema;pub use value::HeaderValue;pub use vars::TemplateVars;
Modules§
- agent
- Agent-specific header builders used to synthesize outbound request headers.
- agent_
id - Logical identifier for the agent whose behavior an upstream call should impersonate. Carried end-to-end through the pipeline so downstream stages (header shaping, provider selection) can branch on it without reparsing inbound traffic.
- error
- Errors produced by the headers crate.
- inbound
- keys
- Catalogue of popular header names as compile-time
staticconstants. - map
- Vec-backed, order- and case-preserving header map.
- name
- Case- and order-preserving HTTP header name.
- normalizer
- Header normalizers rebuild client-derived maps into provider-owned wire shapes after credentials have been injected.
- registry
- Registry mapping
(provider, agent_id)to the typed header schema pair. - reqwest_
compat - Conversions between
crate::HeaderMapandreqwest::header::HeaderMapused at the wire boundary. - schema
- The
HeaderSchematrait + helper functions used by per-(persona, overlay) schema structs to round-trip between their typed Rust form and the genericHeaderMap. - schemas
- Module index for persona and overlay header schemas.
- value
- Header value storage. Values are kept as
Cow<'static, str>so static defaults (e.g."application/json") cost zero allocations while dynamic values (auth tokens, session IDs) heap-allocate on demand. - vars
- Per-request template variables resolved from inbound headers.