pub struct ToolHandleRegistry { /* private fields */ }Expand description
Registry of live (and recently-terminal) detached tool invocations.
One per crate::executor::Runtime; cheap to share via Arc.
Implementations§
Source§impl ToolHandleRegistry
impl ToolHandleRegistry
pub fn new() -> Self
Sourcepub fn subscribe(&self) -> Receiver<ToolStreamEvent>
pub fn subscribe(&self) -> Receiver<ToolStreamEvent>
Subscribe to the live event fanout (every chunk from every handle,
wrapped in a ToolStreamEvent). Used by the WS layer to forward
tools.stream.event notifications.
Sourcepub async fn register(
&self,
tool: &str,
action_id: &str,
) -> (ToolHandle, CancellationToken)
pub async fn register( &self, tool: &str, action_id: &str, ) -> (ToolHandle, CancellationToken)
Register a new detached invocation. Returns the opaque handle and the cancel token the drain task must select on.
Sourcepub async fn push_chunk(&self, handle_id: &str, chunk: ToolStreamChunk)
pub async fn push_chunk(&self, handle_id: &str, chunk: ToolStreamChunk)
Append a chunk from the executor’s stream. A terminal chunk seals
the status (done → succeeded + result, error → failed +
message). Chunks arriving after a terminal state (e.g. a racing
executor after cancel) are dropped. Every accepted chunk is also
broadcast as a ToolStreamEvent.
Sourcepub async fn mark_stream_closed(&self, handle_id: &str)
pub async fn mark_stream_closed(&self, handle_id: &str)
The executor’s stream ended without a terminal chunk — a dropped
sender (panicked task, closed pipe). Treated as failure, unless the
entry was already sealed (normal after a done/error/cancel).
Sourcepub async fn cancel(&self, handle_id: &str) -> bool
pub async fn cancel(&self, handle_id: &str) -> bool
Request cancellation: fires the cancel token (the drain task and a
cooperative executor observe it) and seals the entry as
cancelled unless already terminal. Returns false for an unknown
handle.
Sourcepub async fn cancel_all(&self) -> usize
pub async fn cancel_all(&self) -> usize
Cancel every live invocation (linus review D3): wired into the daemon’s session teardown so a dropped WS connection doesn’t orphan running detached tools — each session’s runtime (and thus registry) is unreachable after disconnect, so anything still running would be uncancellable until daemon restart. Returns how many live invocations were cancelled.
Sourcepub async fn poll(&self, handle_id: &str) -> Option<ToolPollResult>
pub async fn poll(&self, handle_id: &str) -> Option<ToolPollResult>
Drain buffered chunks + report status. None for an unknown (or
already fully-consumed) handle. The FIRST poll that observes the
entry in a terminal state marks it consumed (it also drains any
remaining chunks); the next poll removes it — so a caller always
gets to see the terminal status at least once.
Sourcepub async fn status(&self, handle_id: &str) -> Option<ToolStatus>
pub async fn status(&self, handle_id: &str) -> Option<ToolStatus>
Current status without draining (used by tests and liveness checks).
Sourcepub async fn live_count(&self) -> usize
pub async fn live_count(&self) -> usize
Number of live (non-terminal) invocations.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ToolHandleRegistry
impl !RefUnwindSafe for ToolHandleRegistry
impl !UnwindSafe for ToolHandleRegistry
impl Send for ToolHandleRegistry
impl Sync for ToolHandleRegistry
impl Unpin for ToolHandleRegistry
impl UnsafeUnpin for ToolHandleRegistry
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more