Skip to main content

IntelClient

Struct IntelClient 

Source
pub struct IntelClient { /* private fields */ }
Expand description

A resolved intelligence client over an ordered endpoint list.

Implementations§

Source§

impl IntelClient

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn endpoint_count(&self) -> usize

The number of configured endpoints; one means no fallback exists.

Source

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.

Source

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.

Source

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 (IntelErrorLoopAbort::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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more