
    Ki-                     L    d Z ddlZ ej                    ZdeddfdZdefdZdS )a  Shared interrupt signaling for all tools.

Provides a global threading.Event that any tool can check to determine
if the user has requested an interrupt. The agent's interrupt() method
sets this event, and tools poll it during long-running operations.

Usage in tools:
    from tools.interrupt import is_interrupted
    if is_interrupted():
        return {"output": "[interrupted]", "returncode": 130}
    Nactivereturnc                 r    | rt                                            dS t                                            dS )z5Called by the agent to signal or clear the interrupt.N)_interrupt_eventsetclear)r   s    ,/home/ubuntu/hermes-agent/tools/interrupt.pyset_interruptr
      s:     !         c                  4    t                                           S )zGCheck if an interrupt has been requested. Safe to call from any thread.)r   is_set r   r	   is_interruptedr      s    ""$$$r   )__doc__	threadingEventr   boolr
   r   r   r   r	   <module>r      st   
 
    "9?$$ !$ !4 ! ! ! !% % % % % % %r   