+
    .pÐj  ã                  óh  € R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHtH	t	H
t
HtHtHt ^ RIHt ^ RIHt ^ RIHtHt RtR	tR
tRtRtRtRtRt]	]]]3,          .]],          3,          t] ! R R4      4       t RR/R R llt!R R lt"RRRR/R R llt#RR/R R llt$RR/R R llt%R R  lt&R! R" lt'R# )#a3  The one lifecycle every ``manage_connections`` operation follows, whatever the target kind.

``run_operation`` mints the op, registers it in ``live``, lets the kind prepare its targets (a
managed mint, an MCP catalog check), emits the card through the session callback, then loops:
sleep on ``op.wake`` for at most one tick, run the kind's ``observe`` hook, settle when every
target is resolved or the deadline passes. ``connection.respond`` reaches the loop by transitioning
the op through ``live`` and setting ``wake``; ``/stop`` sets the thread interrupt flag.)ÚannotationsN)Ú	dataclass)ÚAnyÚCallableÚDictÚListÚOptionalÚSequence)Úlive)ÚSettleReason)ÚConnectionOperationÚTargetÚunknown_targetÚmixed_kindsÚlink_still_validÚsettledÚnot_allowedÚrefusedg      @g      Ð?c                  óH   € ] tR t^"t$ RtR]R&   R]R&   R]R&   RtR]R	&   R
tR# )ÚKindz´Per-kind hooks. ``prepare`` runs once before the card; ``observe`` runs every tick and may
transition targets; ``note`` is the model-facing guidance appended to the settled result.z%Callable[[ConnectionOperation], None]ÚprepareÚobserveÚstrÚnoteNz9Optional[Callable[[ConnectionOperation], dict[str, Any]]]Úresult© )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__r   Ú__static_attributes__r   ó    Ú#/opt/hermes/tools/connectors/run.pyr   r   "   s&   ‡ ñað 3Ó2Ø2Ó2Ø
ƒIàHL€FÐE×Lr#   r   Ú	initiatorc               ó(   € V ^8„  d   QhRRRRRRRR/# )é   Ú	operationr   ÚnameszSequence[str]r%   úOptional[str]Úreturnr   )Úformats   "r$   Ú__annotate__r-   .   s+   € ÷ 8ñ 8Ð*ð 8°=ð 8ÐP]ð 8Ðivñ 8r#   c               ó*  aa€ ^ RI HpHoHo V Uu. uF  q@P	                  V4      NK  	  pp\
        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   \        # \        V Uu0 uF  qfP                  kK  	  up4      ^8w  d   \        # V Uu. uF7  qfP                  SP                  SP                  39   g   K+  VP                  NK9  	  pp\        V4      \        V4      8w  d   \        # V P                  '       d   \         # \
        ;QJ d     VV3R lV 4       F  '       g   K   RM	  RM! VV3R lV 4       4      '       d   \"        # V^ ,          P                  R8X  dA   ^ RIHpHp	Hp
 T	! T;'       g    TV P,                  R7      pV
! W°VRVP.                  R	7       R
# ^ RIHp ^ RIHp VP9                  V P:                  4      '       d   VP6                  MTpV! W4      '       d   \<        # R
# u upi u upi u upi )é    )ÚActorÚTargetStateÚallowedc              3  ó(   "  € T F  qR J x € K
  	  R # 5i©Nr   )Ú.0Útargets   & r$   Ú	<genexpr>Úreissue.<locals>.<genexpr>2   s   é € Ð
0©˜f�T�>«ùs   ‚TFc              3  óx   <"  € T F/  pS! VP                   VP                  SP                  4      R J x € K1  	  R # 5ir4   )ÚkindÚstateÚ	initiated)r5   r6   r1   r2   s   & €€r$   r7   r8   ;   s0   øé € Ð
cÑ[bÐQW‰7�6—;‘; §¡¨k×.CÑ.CÓDÈÕLÓ[bùs   ƒ7:Ú	connector)Ú
CARD_RETRYÚmanaged_clientÚmint)r%   Úcall)Ú
reinitiateÚactorN)Úcatalog)Úretry)Útools.connectors.contractr0   r1   r2   r6   ÚanyÚUNKNOWN_TARGETÚlenr:   ÚMIXED_KINDSr;   ÚfailedÚexpiredÚnameÚLINK_STILL_VALIDr   ÚSETTLEDÚNOT_ALLOWEDÚtools.connectors.managedr>   r?   r@   rA   ÚuserÚtools.connectorsrD   Útools.connectors.mcprE   ÚownsÚop_idÚREFUSED)r(   r)   r%   r0   rM   Útargetsr6   Ústaler>   r?   r@   ÚclientrD   rE   Úrerunr1   r2   s   &&$            @@r$   Úreissuer\   .   s~  ù€ ßEÑEá27Ó8±%¨$×Ñ Ö%±%€GÐ8ß
ƒsÑ
0©Ó
0‡s‡s‚sÑ
0©Ó
0×0Ò0ÜÐÜ
¡gÓ.¡g˜F�KŒK¡gÑ.Ó/°1Ô4ÜÐÙ'.Ól¡w˜V·,±,À;×CUÑCUÐWb×WjÑWjÐBkÑ2kŒ[ˆV�[Œ[¡w€EÐlÜ
ˆ5ƒz”S˜“\Ô!ÜÐØ××ÐÜˆß
ƒsÕ
cÑ[bÓ
c‡s‡s‚sÕ
cÑ[bÓ
c×cÒcÜÐØˆq…z‡�˜+Ô%ßMÑMá¨)×*AÐ*A°zÈ	ÏÉÔWˆÙˆV °$¸e¿j¹jÕIÙÝ(Ý*à$Ÿ\™\¨)¯/©/×:Ò:ˆG�MŠMÀ€EÙ˜I×-Ò-Œ7Ð7°4Ð7ùò- 9ùò /ùâls   ‘HÁ5HÂ(HÃHc               ó$   € V ^8„  d   QhRRRRRR/# )r'   r(   r   Úrawr   r+   ÚNoner   )r,   s   "r$   r-   r-   J   s'   € ÷ bñ bÐ/ð b°cð b¸dñ br#   c                óô   € ^ RI HpHpHp \	        WP
                  4      '       d   VP                  W4       R# VP                  V P                  4      '       d   VP                  MVP                  ! W4       R# )z³Hand the card's answer to the module running this operation (a catalog install or an MCP
one); a managed operation's card only skips and continues, which the MCP fold also covers.)rD   ÚdisplayÚmcpN)	rS   rD   ra   rb   Ú
isinstanceÚDisplayOperationÚapply_answerrU   rV   )r(   r^   rD   ra   rb   s   &&   r$   re   re   J   sX   € ÷ 7Ñ6ä�)×5Ñ5×6Ò6Ø×Ñ˜YÔ,ÙØ$Ÿ\™\¨)¯/©/×:Ò:€W×ÒÀ×@PÑ@PÐPÐR[Öar#   Útick_secondsrA   c               ó<   € V ^8„  d   QhRRRRRRRRR	R
RRRRRRRR/	# )r'   rX   zlist[Target]r:   r   Úsession_keyr   Útool_call_idr*   Úconnection_callbackúOptional[Callback]rf   úOptional[float]Úwith_urls_in_resultÚboolrA   zOptional[Any]r+   r   )r,   s   "r$   r-   r-   U   sb   € ÷ ñ Øðà
ðð ð	ð
  ðð ,ðð "ðð ðð ðð 	ñr#   c          	     ó8   € \        \        WW7R7      VVVVR7      # )zQBlock the tool thread until the operation settles; return the tool's JSON string.)rh   ri   rA   ©rj   rf   rm   )Úopen_and_driver   )rX   r:   rh   ri   rj   rf   rm   rA   s   &&$$$$$$r$   Úrun_operationrr   U   s'   € ô Ü˜GÈ<ÔcØØ/Ø!Ø/ôð r#   c               ó0   € V ^8„  d   QhRRRRRRRRR	R
RR/# ©r'   r(   r   r:   r   rj   rk   rf   rl   rm   rn   r+   r   r   )r,   s   "r$   r-   r-   j   sD   € ÷ ñ Ø"ðà
ðð ,ð	ð
 "ðð ðð 	ñr#   c               óà   €  \         P                  ! V 4       \        T TTTTR7      #   \         P                   d1   p^ RIHp T! RTP
                  P                   R24      u Rp?# Rp?ii ; i)zTRegister ``operation`` as the session's open one and drive it; one open per session.)Ú
tool_errorz8a connection operation is already open in this session (zj); it settles when the user finishes with the card, on Continue, or at its deadline. Do not start another.Nrp   )r
   ÚopenÚOperationAlreadyOpenÚtools.registryrv   ÚexistingrV   Údrive_operation)r(   r:   rj   rf   rm   Úexcrv   s   &&$$$  r$   rq   rq   j   sx   € ð
Ü�	Š	�)Ôô ØØØ/Ø!Ø/ôð øô ×$Ñ$ô 
Ý-áØFÀsÇ|Á|×GYÑGYÐFZð [kð kó
õ 	
ûð
ús   ‚( ¨A-½%A(Á"A-Á(A-c               ó0   € V ^8„  d   QhRRRRRRRRR	R
RR/# rt   r   )r,   s   "r$   r-   r-   …   sD   € ÷ 3ñ 3Ø"ð3à
ð3ð ,ð	3ð
 "ð3ð ð3ð 	ñ3r#   c               óþ  €  VP                  V 4       V P                  4        Ve)   V P                  '       g   V! V P                  4       4       \	        WV4       \
        P                  ! V 4       VP                  e(   \        P                  ! VP                  V 4      RR7      # V P                  VR7      pRVR&   VP                  VR&   \        P                  ! VRR7      #   \
        P                  ! T 4       i ; i)NF)Úensure_ascii)Ú	with_urlsr   Ústatusr   )r   Úsettle_if_all_resolvedr   Úrequest_payloadÚ_watchr
   Úcloser   ÚjsonÚdumpsr   )r(   r:   rj   rf   rm   Úpayloads   &&$$$ r$   r{   r{   …   sÇ   € ðØ�‰�YÔØ×(Ñ(Ô*ØÒ*°9×3D×3DÐ3DÙ 	× 9Ñ 9Ó ;Ô<Üˆy Ô-ä�
Š
�9ÔØ‡{�{ÒÜ�zŠz˜$Ÿ+™+ iÓ0¸uÔEÐEØ×ÑÐ)<ÐÓ=€GØ!€GˆHÑØ—i‘i€GˆF�OÜ�:Š:�g¨EÔ2Ð2øô 	�
Š
�9Õús   ‚6C$ ¹"C$ Ã$C<c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r'   r(   r   r:   r   rf   rl   r+   r_   r   )r,   s   "r$   r-   r-   �   s*   € ÷ +ñ +Ð)ð +°ð +À_ð +ÐY]ñ +r#   c                óÄ  € ^ RI Hp Vf   \        MTpV P                  '       g¼   V! 4       '       d"   V P	                  \
        P                  4       R# \        P                  ! 4       V P                  8¼  d"   V P	                  \
        P                  4       R# VP                  V 4       V P                  '       g   V P                  4       '       d   R# \        W4       KÍ  R# )r/   ©Úis_interruptedN)Útools.interruptrŒ   ÚWATCH_INTERVAL_SECONDSr   Úsettler   Ú	interruptÚtimeÚdeadline_atÚdeadliner   r‚   Ú_sleep_until_wake)r(   r:   rf   rŒ   Úticks   &&&  r$   r„   r„   �   sŸ   € Ý.à%1Ò%9Õ!¸|€DØ××ÐÙ×ÒØ×Ñœ\×3Ñ3Ô4ÙÜ�9Š9‹;˜)×/Ñ/Ô/Ø×Ñœ\×2Ñ2Ô3ÙØ�‰�YÔà××Ð 	× @Ñ @× BÒ BÙÜ˜)Ö*ñ  r#   c               ó$   € V ^8„  d   QhRRRRRR/# )r'   r(   r   r•   Úfloatr+   r_   r   )r,   s   "r$   r-   r-   ¯   s"   € ÷ ñ Ð!4ð ¸Eð Àdñ r#   c                ó�  € ^ RI Hp \        \        P                  ! 4       V,           V P                  4      pV P
                  '       gd   V! 4       '       gW   V\        P                  ! 4       ,
          pV^ 8:  d   M2V P                  P                  \        \        V4      4      '       g   Kt   V P                  P                  4        R# )zUSleep up to one tick, leaving early on ``wake``, the deadline, or the interrupt flag.r‹   N)
r�   rŒ   Úminr‘   r’   r   ÚwakeÚwaitÚ_WAKE_SLICE_SECONDSÚclear)r(   r•   rŒ   ÚuntilÚ	remainings   &&   r$   r”   r”   ¯   s€   € å.ä”—	’	“˜dÕ" I×$9Ñ$9Ó:€EØ××Ð©×(8Ò(8ØœDŸIšI›KÕ'ˆ	Ø˜Œ>ØØ�>‰>×ÑœsÔ#6¸	ÓB×CÔCØØ‡N�N×ÑÖr#   )(r    Ú
__future__r   r†   r‘   Údataclassesr   Útypingr   r   r   r   r   r	   rS   r
   rF   r   Útools.connectors.operationr   r   rH   rJ   rN   rO   rP   rW   rŽ   rœ   Údictr   ÚCallbackr   r\   re   rr   rq   r{   r„   r”   r   r#   r$   Ú<module>r¦      sá   ðñ[õ #ã Û Ý !ß @× @å !Ý 2ß Bà!€Ø€Ø%Ð Ø
€Ø€Ø
€àÐ àÐ à�T˜#˜s˜(•^Ð$ h¨s¥mÐ3Õ4€ð ÷Mð Mó ðMð8Ð`d÷ 8õ8bðð %)ðð ÷ð*ð
 %)÷ð63ð
 %)÷3õ0+÷$r#   