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
impl Run
Sourcepub async fn recv(&mut self) -> Option<Event>
pub async fn recv(&mut self) -> Option<Event>
The next event, or None once the agent has finished producing them.
Sourcepub fn argv(&self) -> &[String]
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.
Sourcepub fn redacted_argv(&self) -> Vec<String>
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.
Sourcepub async fn cancel(self) -> Result<Outcome>
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.