+
    lHàjÔ  ã                  óþ   a € 0 t $ R t^ RIHt ^ RIt^ RIt^ RIt^ RIHtH	t	H
t
HtHt ]P                  ! ]4      t/ tR]R&   ]P$                  ! 4       tRtR R ltR	 R
 ltR R ltR R lt]3R R llt]3R R lltR# )aO  Generic slash-command confirmation primitive (gateway-side).

Slash commands with an expensive side effect (currently only ``/reload-mcp``, which invalidates
the provider prompt cache) route through here. Button-UI adapters render Approve Once / Always
Approve / Cancel and call ``resolve()``; text-only adapters get a prompt and the gateway
intercepts ``/approve``, ``/always``, ``/cancel``. State is module-level (like ``tools.approval``)
so adapters can resolve without a ``GatewayRunner`` backreference. The CLI has its own
synchronous variant (``_prompt_slash_confirm`` in ``cli.py``).
)ÚannotationsN)ÚAnyÚ	AwaitableÚCallableÚDictÚOptionalzdict[str, dict[str, Any]]Ú_pendingi,  c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	é   Úsession_keyÚstrÚ
confirm_idÚcommandÚhandlerz)Callable[[str], Awaitable[Optional[str]]]ÚreturnÚNone© )Úformats   "Ú8/home/ubuntu/.hermes/hermes-agent/tools/slash_confirm.pyÚ__annotate__r      s8   € ÷ Pñ P˜#ð P¨3ð P¸ð PØ?ðPØDHñPó    c                ó¤   € \         ;_uu_ 4        RVRVRVR\        P                  ! 4       /\        V &   RRR4       R#   + '       g   i     R# ; i)zFRegister a pending confirm, superseding any prior one for the session.r   r   r   Ú
created_atN)Ú_lockÚtimer   )r   r   r   r   s   &&&&r   Úregisterr      s:   € ÷ 
ŽØ!-¨z¸9ÀgØ!*¨G°\Ä4Ç9Â9Ã;ð!PŒ�Ñ÷ 
��Šús	   �%>¾A	c               ó    € V ^8„  d   QhRRRR/# )r
   r   r   r   zOptional[dict[str, Any]]r   )r   s   "r   r   r   %   s   € ÷ .ñ .˜Sð .Ð%=ñ .r   c                ó°   € \         ;_uu_ 4        \        P                  V 4      pV'       d   \        V4      MRuuRRR4       #   + '       g   i     R# ; i)zAReturn a copy of the pending confirm dict for a session, or None.N)r   r   ÚgetÚdict)r   Úentrys   & r   Úget_pendingr!   %   s,   € ç	ŽÜ—‘˜[Ó)ˆß#Œt�EŒ{¨÷ 
��‹ús   �*AÁA	c               ó    € V ^8„  d   QhRRRR/# )r
   r   r   r   r   r   )r   s   "r   r   r   ,   s   € ÷ (ñ (�sð (˜tñ (r   c                óˆ   € \         ;_uu_ 4        \        P                  V R4       RRR4       R#   + '       g   i     R# ; i)z@Drop the pending confirm for ``session_key`` without running it.N)r   r   Úpop)r   s   &r   Úclearr%   ,   s!   € ç	ŽÜ�‰�[ $Ô'÷ 
��Šús	   �0°A	c               ó$   € V ^8„  d   QhRRRRRR/# )r
   r    zdict[str, Any]ÚtimeoutÚfloatr   Úboolr   )r   s   "r   r   r   2   s&   € ÷ Jñ J�^ð J¨eð J¸ñ Jr   c                ó†   € \         P                   ! 4       \        V P                  R ^ 4      ;'       g    ^ 4      ,
          V8„  # )r   )r   r(   r   )r    r'   s   &&r   Ú	_is_staler+   2   s0   € Ü�9Š9‹;œ˜uŸy™y¨°qÓ9×>Ð>¸QÓ?Õ?À'ÑIÐIr   c               ó$   € V ^8„  d   QhRRRRRR/# )r
   r   r   r'   r(   r   r)   r   )r   s   "r   r   r   6   s"   € ÷ ñ  ð ¨eð ÐRVñ r   c                ó  € \         ;_uu_ 4        \        P                  V 4      p\        T;'       d    \	        W!4      4      pV'       d   \        P                  V R4       VuuRRR4       #   + '       g   i     R# ; i)zLDrop the pending confirm if older than ``timeout`` seconds; True if dropped.N)r   r   r   r)   r+   r$   )r   r'   r    Ústales   &&  r   Úclear_if_staler/   6   sL   € ç	ŽÜ—‘˜[Ó)ˆÜ�U×8Ð8œy¨Ó8Ó9ˆßÜ�L‰L˜ dÔ+Ø÷ 
��‹ús   �;A-ÁA-Á-A>	c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r
   r   r   r   Úchoicer'   r(   r   zOptional[str]r   )r   s   "r   r   r   @   s1   € ÷ 7ñ 7˜sð 7°ð 7¸Sð 7Ø ð7Ø?Lñ7r   c              ƒ  ó^  "  € \         ;_uu_ 4        \        P                  V 4      pV'       d   VP                  R4      V8w  d    RRR4       R# \        P                  V R4       \	        WC4      '       d    RRR4       R# VP                  R4      pVP                  RR4      pRRR4       X'       g   R#  V! V4      G Rj  x€L
 p\        T\        4      '       d   T# R#   + '       g   i     LE; i L1  \
         d)   p\        P                  RXTRR7       R	T 2u Rp?# Rp?ii ; i5i)
z×Run the pending handler with ``choice`` ("once" / "always" / "cancel").

Returns the handler's output string, or None if the confirm was stale, already resolved,
or the confirm_id doesn't match (superseded prompt).
r   Nr   r   Ú?z(Slash-confirm handler for /%s raised: %sT)Úexc_infou!   â�Œ Error handling confirmation: )
r   r   r   r$   r+   Ú	ExceptionÚloggerÚerrorÚ
isinstancer   )	r   r   r1   r'   r    r   r   ÚresultÚexcs	   &&&&     r   Úresolver;   @   sò   é € ÷ 
ŽÜ—‘˜[Ó)ˆß˜Ÿ	™	 ,Ó/°:Ô=Ø÷ 
‰ô
 	�‰�[ $Ô'Ü�U×$Ò$Ø÷ 
‰ð —)‘)˜IÓ&ˆØ—)‘)˜I sÓ+ˆ÷ 
÷ Ùð9Ù˜v“×&ˆô   ¬×,Ò,ˆ6Ð6°$Ð6÷% 
�úñ 'øÜô 9Ü�‰Ð?ÀÈ#ÐX\ˆÔ]Ø2°3°%Ð8Õ8ûð9üs|   ‚D-‘5C"Á
D-Á(C"Á8
D-Â#C"Â%D-Â5D-Â8C7 ÃC5ÃC7 ÃD-Ã"C2	Ã-D-Ã5C7 Ã7D*ÄD%ÄD*Ä D-Ä%D*Ä*D-)Ú__conditional_annotations__Ú__doc__Ú
__future__r   ÚloggingÚ	threadingr   Útypingr   r   r   r   r   Ú	getLoggerÚ__name__r6   r   Ú__annotations__ÚRLockr   ÚDEFAULT_TIMEOUT_SECONDSr   r!   r%   r+   r/   r;   )r<   s   @r   Ú<module>rG      s€   øðôõ #ã Û Û ß ;Õ ;à	×	Ò	˜8Ó	$€ð ')€Ð
#Ó (Ø�ŠÓ€ð Ð õPõ.õ(õJð 7N÷ ð $;÷7ñ 7r   