Skip to main content

Run

Struct Run 

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

A run in progress.

Yields events through Run::recv and settles into an Outcome through Run::finish.

Dropping a Run kills the agent. That is the safe default for the hosts this crate targets: closing a window or cancelling a request should stop the work, not leave an agent running invisibly, spending quota and touching files with nobody watching. Call Run::detach when background execution is genuinely what you want.

On Unix, dropping synchronously signals the run’s process group and then aborts the driver task. What it cannot do is wait: Drop cannot await, so it does not block until the child has exited or its readers have been joined. Use Run::cancel when you need to know the tree has actually gone before continuing, such as before touching the files it was working on. On Windows only the direct child is signalled.

Implementations§

Source§

impl Run

Source

pub async fn recv(&mut self) -> Option<Event>

The next event, or None once the agent has finished producing them.

Source

pub fn argv(&self) -> &[String]

The exact command line that was spawned.

This contains the prompt and any session id. Treat it as sensitive: logging it verbatim puts user content into your logs. Use Run::redacted_argv for diagnostics.

Source

pub fn redacted_argv(&self) -> Vec<String>

The command line with every non-public value replaced by a placeholder.

Prompts, system prompts, session ids and anything from crate::Request::unchecked_args are removed; flag names are kept so the command stays recognisable. Sensitivity is recorded where each argument is built rather than inferred from the finished line, so a bare positional prompt or an opaque raw argument is covered too.

Source

pub async fn finish(self) -> Result<Outcome>

Wait for the run to finish.

Drains any events still queued, so a caller that only wants the result can call this without having consumed the stream.

§Errors

Whatever the run failed with. See Error.

Source

pub async fn cancel(self) -> Result<Outcome>

Stop the run and wait until the agent is actually gone.

Cooperative rather than an abort: the driver is asked to stop, signals the process group, reaps the child and joins its readers, and only then does this return. So when it returns the tree really has exited, which matters if the next thing you do touches the files it was working on.

Returns the partial Outcome if the run happened to finish first, otherwise Error::Cancelled.

§Errors

Error::Cancelled in the normal case, or whatever the run failed with if it failed before the request arrived.

Source

pub fn detach(self)

Let the run continue after this handle goes away.

The opposite of the default. Nothing can observe or stop the agent afterwards, so reach for this only when an unsupervised background run is genuinely intended.

Trait Implementations§

Source§

impl Debug for Run

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Run

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Run

§

impl !UnwindSafe for Run

§

impl Freeze for Run

§

impl Send for Run

§

impl Sync for Run

§

impl Unpin for Run

§

impl UnsafeUnpin for Run

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, 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 = 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.