Conversation

Struct Conversation 

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

Fluent builder that produces a ConversationSpec; sugar over the spec.

(Not Debug: resolve_slot bindings hold async closures. The serializable ConversationSpec is Debug via spec.)

Implementations§

Source§

impl Conversation

Source

pub fn new(name: impl Into<String>) -> Self

Start a new conversation.

Source

pub fn stage(self, id: impl Into<String>) -> Self

Begin authoring a new stage; subsequent setters apply to it. Routes to the active overlay when between .overlay(..) and .done_overlay().

Source

pub fn overlay(self, name: impl Into<String>) -> Self

Begin authoring a digression/overlay; subsequent .stage(..) calls (until .done_overlay()) populate it. Set its activation guard with .trigger(..) (an overlay with no trigger never fires — fail-closed).

Source

pub fn trigger(self, guard: Guard) -> Self

Set the activation guard of the overlay currently being authored.

Source

pub fn resume(self, resume: Resume) -> Self

Set the resume policy of the overlay currently being authored.

Source

pub fn done_overlay(self) -> Self

Finish the current overlay; subsequent .stage(..) calls target the main flow again.

Source

pub fn add_stage(self, stage: StageSpec) -> Self

Append a pre-built StageSpec (e.g. from a Motif). Routes to the active overlay when authoring one, else the main flow. Subsequent stage setters (next, say, …) apply to it.

Source

pub fn add_overlay(self, overlay: OverlaySpec) -> Self

Append a pre-built OverlaySpec (e.g. a Motif::faq_digression). Leaves overlay-authoring mode (the overlay is already complete).

Source

pub fn policy(self, policy: impl Into<Policy>) -> Self

Attach a cross-cutting Policy aspect.

Source

pub fn say(self, text: impl Into<String>) -> Self

Set the stage’s steering instruction.

Source

pub fn ground(self, template: impl Into<String>) -> Self

Set the stage’s grounding template.

Source

pub fn collect<I, S>(self, fields: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Collect the given slots in this stage (drives default completion).

Source

pub fn collect_frame<F: Frame>(self) -> Self

Collect the slots of a typed gemini_adk_rs::frame::Frame in this stage. The frame’s slot state-keys drive the captured completion; its metadata (prompts/confirm/pii) is available via F::frame() for confirmation and repair.

Source

pub fn allow<I, S>(self, tools: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Allow the given tools while this stage is active.

Source

pub fn done(self, guard: Guard) -> Self

Set an explicit completion guard for this stage.

Source

pub fn commit(self, tool: impl Into<String>, when: Guard) -> Self

Commit a confirm-before-act tool in this stage, gated by when.

Source

pub fn next(self, to: impl Into<String>, when: Guard) -> Self

Add a forward transition to to when when holds.

Source

pub fn resolve_slot<I, S, F, Fut>( self, name: impl Into<String>, args: I, ttl: Option<Duration>, fetch: F, ) -> Self
where I: IntoIterator<Item = S>, S: Into<String>, F: Fn(Value) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Value, String>> + Send + 'static,

Fill a slot in the current stage from an async resolver — a tool call, HTTP fetch, MCP request, or agent. args names the State keys bound into the JSON object passed to fetch; the returned value fills name. With a ttl, results are memoized by (field, canonical args).

The slot is added to the stage’s collect, so its captured completion waits for the resolution. The closure lives only in the builder; the serializable spec is unaffected.

Source

pub fn after(self, dep: impl Into<String>) -> Self

Add an explicit dependency on another stage.

Source

pub fn terminal(self) -> Self

Mark the current stage terminal.

Source

pub fn repair(self, policy: RepairPolicy) -> Self

Attach a RepairPolicy to the current stage.

Source

pub fn require<I, S>(self, steps: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Require these stages for completion (lowers to a Flow require). Targets the active overlay when authoring one, else the main flow.

Source

pub fn spec(&self) -> &ConversationSpec

The spec built so far.

Source

pub fn into_spec(self) -> ConversationSpec

Consume into the underlying spec.

Source

pub fn from_spec( spec: ConversationSpec, ) -> Result<CompiledConversation, ConversationError>

Compile from a ConversationSpec (e.g. parsed from YAML). Resolver-slot bindings are builder-only, so a spec loaded this way has none.

Source

pub fn compile(self) -> Result<CompiledConversation, ConversationError>

Lower and validate into a CompiledConversation.

Trait Implementations§

Source§

impl Clone for Conversation

Source§

fn clone(&self) -> Conversation

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Default for Conversation

Source§

fn default() -> Conversation

Returns the “default value” for a type. 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<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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: 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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

§

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

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

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