pub struct IntelClient { /* private fields */ }Expand description
A resolved intelligence client over an ordered endpoint list.
Implementations§
Source§impl IntelClient
impl IntelClient
Sourcepub fn from_parts(
uri: &str,
default_token: Option<String>,
) -> Result<IntelClient, IntelError>
pub fn from_parts( uri: &str, default_token: Option<String>, ) -> Result<IntelClient, IntelError>
Build from explicit parts — the subagent path, driven by the spawn
payload rather than the CLI Config. uri is the endpoint list, which
may hold a single element. default_token is endpoint 1’s resolved
credential, used only when its own env override is unset; every later
endpoint resolves its own _<N>-suffixed token instead of inheriting
this one, so a fallback never dials with the primary’s credential.
Sourcepub fn with_headers(self, headers: Vec<(String, String)>) -> IntelClient
pub fn with_headers(self, headers: Vec<(String, String)>) -> IntelClient
Attach the configured intelligence.headers, applied to every endpoint
dial. Builder-style; call before use. An empty list leaves every endpoint
with only the dialect’s own headers.
Sourcepub fn with_signer(self, signer: Option<Arc<dyn RequestSigner>>) -> IntelClient
pub fn with_signer(self, signer: Option<Arc<dyn RequestSigner>>) -> IntelClient
Attach a per-request signer — AWS SigV4 — applied to every dial. The signature covers the method, host, request-target and body of the dial that is about to go out, so it is computed after the effective path is resolved rather than from the configured path. Builder-style; call before use.
Sourcepub fn with_dialect(self, dialect: Option<&str>) -> IntelClient
pub fn with_dialect(self, dialect: Option<&str>) -> IntelClient
Select the wire dialect from intelligence.dialect, applied to every
endpoint in the list. None or an unrecognised value keeps the
OpenAI-compatible default; config validation rejects unknown dialects
earlier, so reaching here with one is not a user-visible path.
Builder-style; call before use.
Sourcepub fn set_health_reporter(&mut self, reporter: Box<dyn Fn(IntelHealthReport)>)
pub fn set_health_reporter(&mut self, reporter: Box<dyn Fn(IntelHealthReport)>)
Install the edge-triggered all-down reachability reporter: the child
wires this to send an AgentMsg::IntelHealth up to the supervisor on
each all-down ENTER/EXIT transition. The callback fires only when the
list’s all-down state changes, never once per call, so a steady state
emits nothing. It sits off the data path entirely — a client with no
reporter selects and dials identically.
Sourcepub fn set_trace_id(&mut self, trace_id: Option<String>)
pub fn set_trace_id(&mut self, trace_id: Option<String>)
Stamp the run’s trace id so each completion carries a traceparent
header and the model call joins the run’s distributed trace.
Sourcepub fn enable_alldown_backoff(&mut self, policy: AllDownPolicy)
pub fn enable_alldown_backoff(&mut self, policy: AllDownPolicy)
Enable the all-endpoints-down backoff for a long-lived loop or
reactive daemon: on all-down, re-arm the failover sweep with bounded
jittered backoff instead of surfacing the terminal immediately.
once-mode leaves this unset, so a single sweep leads to exit 4. The run
deadline still bounds the total wait — backoff never extends it, so a
daemon cannot outlive its deadline by retrying.
Sourcepub fn endpoint_count(&self) -> usize
pub fn endpoint_count(&self) -> usize
The number of configured endpoints; one means no fallback exists.
Sourcepub fn trace_id(&self) -> Option<&str>
pub fn trace_id(&self) -> Option<&str>
The run’s trace id, if stamped. A hot-swap reads it to re-stamp the rebuilt client, so the run’s trace survives a repoint unbroken.
Sourcepub fn alldown_enabled(&self) -> bool
pub fn alldown_enabled(&self) -> bool
Whether the all-endpoints-down backoff is enabled, which it is for a long-lived loop or reactive daemon. A hot-swap reads it so the rebuilt client preserves the daemon’s resilience posture across a repoint rather than silently reverting to one-shot semantics.
Sourcepub fn complete(&self, req: &Request) -> Result<Response, IntelError>
pub fn complete(&self, req: &Request) -> Result<Response, IntelError>
One completion round-trip, driven through the failover policy. Every
error returned here feeds the exit-code path
(IntelError → LoopAbort::Intel → exit 4).
When all endpoints are down and the all-down backoff is enabled (loop and
reactive daemons), the sweep is re-armed with bounded jittered backoff so
a transient host-model roll recovers without killing the daemon;
once-mode surfaces the terminal immediately and exits 4. A fatal auth
failure (401/403) is NEVER backed off: it is a misconfiguration that
retrying cannot repair, and retrying it would only delay the operator’s
signal.
Sourcepub fn with_list<R>(&self, f: impl FnOnce(&EndpointList) -> R) -> R
pub fn with_list<R>(&self, f: impl FnOnce(&EndpointList) -> R) -> R
Borrow the endpoint list for the read-only agentd://intelligence
resource body. The caller serializes transport, index and health only —
never the URL or any credential, since that body is exposed to whoever
can read the resource.