Skip to main content

AgentDialer

Struct AgentDialer 

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

Reusable handle for dialing the polychrome control plane.

Implementations§

Source§

impl AgentDialer

Source

pub fn new(addr: &str) -> Result<Self, DialError>

Build a dialer pointed at addr (expects http://host:port).

§Errors

Returns DialError::InvalidAddress if addr isn’t a valid URI.

Source

pub fn approval_dialer(addr: &str) -> Result<ApprovalDialer, DialError>

Build an ApprovalDialer for the SAME control-plane endpoint. AgentService and ApprovalService are served on one Connect port, so an approval client reuses the agent address — callers that already hold an AgentDialer don’t need to thread a second address.

§Errors

Returns DialError::InvalidAddress if addr isn’t a valid URI.

Source

pub async fn run_turn( &self, conversation_id: &str, exec_id: &str, user_text: &str, ) -> Result<String, DialError>

Run one turn against the control plane and collect the aggregated text response.

conversation_id is the stable id for the conversation (the Slack adapter derives it from the thread; the CLI takes it as an argument). user_text is the user message with any bot mention already stripped. Returns the concatenated assistant text across every batch in the response stream, or Ok(String::new()) if the turn produced no text. Non-text content variants (tool calls, tool results, thoughts) are rendered as bracketed placeholders.

§Errors

Returns DialError::Connect for any transport/stream/encoding error from the AgentService call.

Source

pub async fn run_turn_with( &self, conversation_id: &str, exec_id: &str, user_text: &str, attribution: Attribution, ) -> Result<String, DialError>

Like run_turn but attributes the turn to a caller (and participants). Non-streaming edges that resolve an identity via EdgeAdapter::caller use this so their turns populate AgentStart.caller (persona attribution) — the buffered analog of run_turn_streaming_messages_with.

§Errors

Returns DialError::Connect for any transport/stream/encoding error.

Source

pub async fn run_turn_streaming( &self, conversation_id: &str, exec_id: &str, user_text: &str, ) -> Result<impl Stream<Item = Result<TurnEvent, DialError>>, DialError>

Run one turn against the control plane and stream each meaningful step as a TurnEvent, for live surfaces that update in place.

The request is built identically to AgentDialer::run_turn; see that method for the meaning of conversation_id, exec_id, and user_text. The returned stream yields:

Tool-role result echoes and empty/non-textual blocks produce no event.

§Errors

The outer Result carries a DialError::Connect if opening the stream fails. Each item is a Result so per-message transport/decode errors surface inline without tearing down the whole stream type.

Source

pub async fn run_turn_streaming_messages( &self, conversation_id: &str, exec_id: &str, messages: Vec<Message>, ) -> Result<impl Stream<Item = Result<TurnEvent, DialError>>, DialError>

Like Self::run_turn_streaming but takes a pre-built (e.g. attributed multi-party) message list as the turn input.

§Errors

Returns DialError::Connect for any transport/stream/encoding error.

Source

pub async fn run_turn_streaming_messages_with( &self, conversation_id: &str, exec_id: &str, messages: Vec<Message>, payment_receipt: Option<PaymentReceipt>, attribution: Attribution, ) -> Result<impl Stream<Item = Result<TurnEvent, DialError>>, DialError>

The full-fidelity variant: one method carries everything a turn’s request can — a settled inbound PaymentReceipt (the control plane persists a signed payment_receipt event in the turn’s atomic batch) and the caller Attribution (resolved to durable personas and recorded as caller/participant events). One method rather than a matrix of variants, so a paid and attributed edge can’t silently drop one of the two.

§Errors

Returns DialError::Connect for any transport/stream/encoding error.

Source

pub async fn should_respond( &self, conversation_id: &str, bot_name: &str, transcript: Vec<ParticipantMessage>, ) -> Result<bool, DialError>

Ask the control plane’s participation gate whether to reply to the latest message of a (multi-party) thread. Returns true only on respond; notify / ignore map to false (stay silent). The gate runs a cheap classifier model server-side and never runs a turn.

§Errors

Returns DialError::Connect for any transport/encoding error.

Trait Implementations§

Source§

impl Clone for AgentDialer

Source§

fn clone(&self) -> AgentDialer

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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