Public declaration syntax from forge-rs/crates/forge-collab/src/interrupt.rs Original source SHA-256: 8782604eec0d935ab46089000c61664c2c01959fb99703d964a73cc3fb0f767a Function bodies and constant values are omitted. This is not the complete implementation. Source line 59 #[async_trait::async_trait] pub trait InterruptHandler: Send + Sync { /// Handles an incoming interrupt. /// /// The handler inspects the interrupt type and priority, then decides /// whether to acknowledge it. The response includes the agent's current /// state if applicable (e.g., for suspendable tasks). /// /// # Arguments /// /// * `interrupt` - The interrupt to handle. /// /// # Returns /// /// An [`InterruptResponse`] indicating acknowledgment and optional state. /// /// # Errors /// /// Returns [`CollabError::InterruptRejected`] if the interrupt cannot /// be handled (e.g., the agent is in a critical section). // ANVIL Spec section 11.5 -- Interrupt Handler: on_interrupt async fn on_interrupt(&self, interrupt: &Interrupt) -> Result; /// Called when the agent must be preempted by a higher-priority task. /// /// The agent should save its current state and prepare for the current /// task to be suspended or aborted. /// /// # Arguments /// /// * `interrupt` - The preemption interrupt. /// /// # Returns /// /// An [`InterruptedState`] snapshot of the agent's state at the moment /// of preemption. /// /// # Errors /// /// Returns [`CollabError::InterruptRejected`] if preemption is not /// possible. // ANVIL Spec section 11.5 -- Interrupt Handler: on_preempt async fn on_preempt(&self, interrupt: &Interrupt) -> Result; } Source line 139 pub fn create_interrupt( interrupt_type: InterruptType, source_did: &str, priority: TaskPriority, payload: serde_json::Value, ) -> Interrupt;