pub struct ResumeBuilder { /* private fields */ }Expand description
Answering interrupts, one call per decision.
A run can pause on several interrupts at once — three tool approvals, say — and they are answered together, in one request. This collects the answers.
use ag_ui::client::interrupts::ResumeBuilder;
use ag_ui::{Interrupt, ResumeStatus};
let approve = Interrupt::new("i-1", "tool_approval");
let deny = Interrupt::new("i-2", "tool_approval");
let entries = ResumeBuilder::new()
.resolve(&approve, serde_json::json!({ "approved": true }))
.cancel(&deny)
.build();
assert_eq!(entries[0].interrupt_id, "i-1");
assert_eq!(entries[1].status, ResumeStatus::Cancelled);Implementations§
Source§impl ResumeBuilder
impl ResumeBuilder
Sourcepub fn resolve(self, interrupt: &Interrupt, payload: impl Into<Value>) -> Self
pub fn resolve(self, interrupt: &Interrupt, payload: impl Into<Value>) -> Self
Answers an interrupt.
Sourcepub fn resolve_with_edits(
self,
interrupt: &Interrupt,
edited_args: impl Into<Value>,
) -> Self
pub fn resolve_with_edits( self, interrupt: &Interrupt, edited_args: impl Into<Value>, ) -> Self
Approves a tool call after editing its arguments.
Agents that advertise approveWithEdits expect the edited arguments
under an editedArgs key; this writes that shape so callers do not have
to remember it.
Sourcepub fn cancel(self, interrupt: &Interrupt) -> Self
pub fn cancel(self, interrupt: &Interrupt) -> Self
Declines an interrupt — the user said no, or the request expired.
Sourcepub fn entry(self, entry: ResumeEntry) -> Self
pub fn entry(self, entry: ResumeEntry) -> Self
Answers an interrupt with a status the caller picked.
Sourcepub fn entries(&self) -> &[ResumeEntry]
pub fn entries(&self) -> &[ResumeEntry]
The answers collected so far.
Sourcepub fn build(self) -> Vec<ResumeEntry>
pub fn build(self) -> Vec<ResumeEntry>
Consumes the builder and returns the answers.
Trait Implementations§
Source§impl Clone for ResumeBuilder
impl Clone for ResumeBuilder
Source§fn clone(&self) -> ResumeBuilder
fn clone(&self) -> ResumeBuilder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ResumeBuilder
impl Debug for ResumeBuilder
Source§impl Default for ResumeBuilder
impl Default for ResumeBuilder
Source§fn default() -> ResumeBuilder
fn default() -> ResumeBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ResumeBuilder
impl RefUnwindSafe for ResumeBuilder
impl Send for ResumeBuilder
impl Sync for ResumeBuilder
impl Unpin for ResumeBuilder
impl UnsafeUnpin for ResumeBuilder
impl UnwindSafe for ResumeBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more