+
    jHàj­g  ã                  ó  € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	H
t
HtHt ]P                  ! ]4      tRtRt]! RR04      t]R0,          t]! R	R04      t ! R
 R]4      tR tR R lt ! R R4      t ! R R4      tR# )u5  One gateway connection per classic-CLI process (CALLMAP Â§3.1, Â§4).

A daemon thread owns an asyncio loop and one ``GatewayClient``. It never calls a HermesCLI
method and never blocks: every event frame goes into a thread-safe ``queue.Queue`` that the
agent thread drains (``GatewayAgent.run_conversation``), and ``session.info``-class frames
also update the plain-attribute ``SessionState`` caches the status bar reads.

Callers on any other thread use ``call()``, which blocks on the loop's future; calling it on
the loop thread itself is a deadlock and raises.
)ÚannotationsN)ÚDEFAULT_RPC_TIMEOUTÚRESUME_KEY_MISMATCHÚGatewayClientErrorÚGatewayRPCErrorz–Gateway disconnected; turn outcome is unknown. Resume the printed session ID to check whether it completed or was interrupted; do not resend the work.zCGateway disconnected before the request was sent; nothing was sent.Ú	not_foundÚpermission_deniedÚprofile_mismatchÚadmission_conflictc                  ó   € ] tR t^'tRtRtR# )ÚCallStoppedzXThe caller stopped waiting (:meth:`GatewayConnection.call_until`); the request was sent.© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    ÚB/home/ubuntu/.hermes/hermes-agent/hermes_cli/gateway_connection.pyr   r   '   s   † Ýbr   r   c                ó¾   € V'       d!   \        V 4      R8X  d   \        \        4      RhV'       g   \        V 4      \        9  d   V h\        P                  RW4       R# )a¡  A keyed ``session.resume`` the owner refused with ``exc``: returns when the caller resumes plain,
else raises. Only a refusal in ``_KEY_NOT_TAKEN`` resumes plain (a keyed startup alias on a Desktop/TUI
session); any other is raised, not hidden by a keyless attach whose first turn fails. ``typed`` (a typed
``--api-key`` the user resumes with) never resumes plain: ``admission_conflict`` is the thin client's
refusal.r
   NzAsession.resume %s: launch key not taken (%s); resuming without it)Ústrr   r   Ú_KEY_NOT_TAKENÚloggerÚdebug)ÚexcÚ
session_idÚtypeds   &&&r   Ú_resume_plainr   +   sD   € ÷ ”�S“Ð1Ô1Ü Ô!4Ó5¸4Ð?ß”�C“¤Ô.Øˆ	Ü
‡L�LÐTÐV`Öfr   c               ó   € V ^8„  d   QhRR/# ©é   ÚreturnÚboolr   )Úformats   "r   Ú__annotate__r%   8   s   € ÷ dñ d ñ dr   c                ó„   € \        V RR4      p\        V \        4      ;'       d    VRJ;'       d    VRJ;'       d    W!8  # )z—``frame`` is a transport error from a connection older than ``epoch``: a reconnect replaced it,
so it is no outcome of anything submitted on ``epoch``.Úconnection_epochN)ÚgetattrÚ
isinstanceÚ	Exception)ÚframeÚepochÚlosts   && r   Úlost_beforer.   8   sF   € ô �5Ð,¨dÓ3€DÜ�eœYÓ'×cÐc¨D¸Ð,<×cÐcÀÈdÐAR×cÐcÐW[ÑWcÐcr   c                  ó<   € ] tR t^?tRtR tR tR	R ltR tR t	Rt
R# )
ÚSessionStatezœWhat the gateway last told this viewer about one session (plain attributes, GIL-atomic
reads from the prompt_toolkit render thread; never an RPC per paint).c                	óH  € Wn         / V n        R V n        R V n        R V n        R V n        R V n        . V n        / V n        . V n	        . V n
        R V n        . V n        / V n        / V n        R V n        ^ V n        / V n        ^ V n        \'        4       V n        ^ ;V n        V n        R # ©N)r   ÚinfoÚtitleÚ
todo_stateÚrevisionÚsubscription_idÚexecution_generationÚmessagesÚusageÚusage_listenersÚrequest_listenersÚadmitted_turnÚpendingÚqueued_inputsÚadoptedÚarmed_admissionÚpending_seqÚ	queued_atÚrecovered_seqÚsetÚmissedÚgapsÚattached_gaps)Úselfr   s   &&r   Ú__init__ÚSessionState.__init__C   s´   € Ø$ŒØˆŒ	Ø!%ˆŒ
Ø'+ˆŒØˆŒØ#ˆÔØ$(ˆÔ!Ø ˆŒØˆŒ
ð &(ˆÔð (*ˆÔà*.ˆÔð  ˆŒØ#%ˆÔð  ˆŒØ+/ˆÔð ˆÔð  "ˆŒØˆÔÜ›5ˆŒð *+Ð*ˆŒ	�DÖ&r   c                	ó   € \        VP                  R 4      ;'       g    / 4      V n        VP                  RV P                  4      V n        VP                  RV P                  4      V n        VP                  RV P
                  4      V n        \        VP                  R4      ;'       g    . 4      V n        RV9   d2   VR,          p\        V\         4      '       d   \        V4      MRV n	        \        VP                  R4      \        4      '       d1   \        VR,          4      V n
        V ;P                  ^,          un        V P                  P                  R4      '       d   V P                  R,          V n        R# R# )	r3   r6   r7   r8   r9   r5   Nr>   r4   )ÚdictÚgetr3   r6   r7   r8   Úlistr9   r)   r5   r>   rB   r4   )rI   Úsnapshotr5   s   && r   Úadopt_snapshotÚSessionState.adopt_snapshotk   s  € Ü˜Ÿ™ fÓ-×3Ð3°Ó4ˆŒ	Ø Ÿ™ Z°·±Ó?ˆŒØ'Ÿ|™|Ð,=¸t×?SÑ?SÓTˆÔØ$,§L¡LÐ1GÈ×IbÑIbÓ$cˆÔ!Ü˜XŸ\™\¨*Ó5×;Ð;¸Ó<ˆŒØ˜8Ô#Ø! ,Õ/ˆJÜ2<¸ZÌ×2NÒ2Nœd :Ô.ÐTXˆDŒOÜ�h—l‘l 9Ó-¬t×4Ò4Ü ¨Õ 3Ó4ˆDŒLØ×Ò Õ!ÕØ�9‰9�=‰=˜×!Ò!ØŸ™ 7Õ+ˆDŽJñ "r   c                óä   € V P                   P                  R4      V P                   P                  R4      rC\        V4      ;'       d*    W8H  ;'       d    T;'       d    T;'       d    W$8g  '       * # )zPWhether the session runs ``model`` (and ``provider``, when both sides name one).ÚmodelÚprovider)r3   rN   r#   )rI   rT   rU   ÚcurrentÚcurrent_providers   &&&  r   Ú
runs_routeÚSessionState.runs_routez   sk   € à$(§I¡I§M¡M°'Ó$:¸D¿I¹I¿M¹MÈ*Ó<UÐ!Ü�G‹}÷ Lð L Ñ!1÷ Lð LØ×JÐJÐ)×JÐJ¨hÑ.Jô7Lð 	Lr   c                	ób  € VR9   dÛ   \        V\        4      '       dÅ   V P                  P                  VP	                  4        UUu/ uF  w  r4VR8w  g   K  W4bK  	  upp4       \        VP                  R4      \        4      '       d1   \        VR,          4      V n        V ;P                  ^,          un        VP                  R4      '       d   VR,          V n	        R# R# VR8X  dU   \        V\        4      '       d?   R\        VP                  R4      ;'       g    . 4      RVP                  R4      /V n
        R# VR8X  d�   \        V\        4      '       dk   VP                  R4      p\        VP                  R	4      \        4      ;'       g    \        V\        4      '       * pT P                  V'       d   TMT4       R# VR
8X  d=   \        V\        4      '       d'   \        V P                  4       F  pV! V4       K  	  R# VR8X  d   V ;P                  ^,          un        R# R# u uppi )úsession.infor   r>   r4   ztodo.updatedÚtodosr6   zsession.usager:   Ú	api_callszrequest.cancelzsession.replay_gapN)r[   zsession.updated)r)   rM   r3   ÚupdateÚitemsrN   rO   r>   rB   r4   r5   ÚintÚapply_usager<   rG   )rI   ÚkindÚpayloadÚkÚvÚnestedÚflatÚlisteners   &&&     r   Úapply_eventÚSessionState.apply_event€   s›  € ØÐ6Ô6¼:ÀgÌt×;TÒ;TØ�I‰I×Ñ¨w¯}©}¬ÔT©¡t qÀ!À|ÑBSœd˜ašd©ÒTÔUÜ˜'Ÿ+™+ iÓ0´$×7Ò7Ü# G¨IÕ$6Ó7�”Ø× Ò  AÕ%Õ Ø�{‰{˜7×#Ò#Ø$ WÕ-�–
ñ $à�^Ô#¬
°7¼D×(AÒ(AØ&¬¨W¯[©[¸Ó-A×-GÐ-GÀRÓ(HÈ*ÐV]×VaÑVaÐblÓVmÐnˆDŽOØ�_Ô$¬°G¼T×)BÒ)Bð —[‘[ Ó)ˆFÜ˜gŸk™k¨+Ó6¼Ó<×\Ð\ÄJÈvÔW[ÓD\Ô@\ˆDØ×Ñ¯™W°&Ö9ØÐ%Ô%¬*°W¼d×*CÒ*CÜ  ×!7Ñ!7Ö8�Ù˜Ö!ó 9àÐ)Ô)Ø�IŠI˜�N�Iñ *ùó# Us   ÁH+
ÁH+
c                ó²   € \        V\        4      '       g   R# \        V4      V n        \        V P                  4       F  pV! V P                  4       K  	  R# )zZOne session-cumulative usage dict (``session.usage`` payload or ``session.stats`` result).N)r)   rM   r:   rO   r;   )rI   r:   rh   s   && r   ra   ÚSessionState.apply_usage–   s>   € ä˜%¤×&Ò&ÙÜ˜%“[ˆŒ
Ü˜T×1Ñ1Ö2ˆHÙ�T—Z‘ZÖ ó 3r   )r=   r@   rA   rH   r8   rG   r3   r9   rF   r>   rB   rC   r?   rD   r<   r6   r   r7   r4   r5   r:   r;   N)Ú )r   r   r   r   r   rJ   rQ   rX   ri   ra   r   r   r   r   r0   r0   ?   s#   † ñMò&+òP,ôLòö,!r   r0   c                  ó  € ] tR t^ŸtRt]P                  ! 4       tR!R lt]	R 4       t
]R R l4       tR R ltR"R ltR	 tR
 tR tR tRR/R ltR tR tR tR R ltR tR tR tRRRR/R ltR!R ltR tR tR tRRRR/R lt R t!R# )#ÚGatewayConnectionNc                	ó¶  € Wn         \        P                  ! 4       V n        / V n        R V n        R V n        R V n        R V n        \        P                  ! 4       V n        R V n        R V n        \        P                  ! 4       V n        RV n        RV n        ^ V n        / V n        \        P                  ! 4       V n        \+        4       V n        R V n        RV n        R # )NF)Ú_connectÚqueueÚQueueÚeventsÚstatesÚclientÚ_liveÚloopÚ_threadÚ	threadingÚEventÚ_readyÚ_errorÚ_stopÚLockÚ_start_lockÚclosedÚ	_detachedr,   Ú_sideÚ
_side_lockrE   Ú	_commandsÚlaunch_api_keyÚlaunch_api_key_typed)rI   Úconnects   &&r   rJ   ÚGatewayConnection.__init__£   s¯   € ØŒÜ#(§;¢;£=ˆŒØ/1ˆŒØˆŒð ˆŒ
ØˆŒ	ØˆŒÜ—o’oÓ'ˆŒØˆŒØˆŒ
Ü$Ÿ>š>Ó+ˆÔØˆŒð ˆŒØˆŒ
ð .0ˆŒ
Ü#Ÿ.š.Ó*ˆŒä/2«uˆŒð #ˆÔð %*ˆÖ!r   c                	óì   € V P                   ;_uu_ 4        V P                  e   V P                  P                  '       d   V ! 4       V n        V P                  uuR R R 4       #   + '       g   i     R # ; ir2   )Ú_shared_lockÚ_sharedÚfinal)Úclss   &r   ÚsharedÚGatewayConnection.sharedÃ   sF   € à××ÓØ�{‰{Ò" c§k¡k×&7×&7Ð&7Ù!›e�”Ø—;‘;÷ ××Óús   •*A"Á A"Á"A3	c               ó   € V ^8„  d   QhRR/# r    r   )r$   s   "r   r%   ÚGatewayConnection.__annotate__Ë   s   € ÷ Nñ N�tñ Nr   c                óx   € V P                   ;'       g(    V P                  RJ;'       d    V P                  '       * # )z¬No call dials again: the viewer closed it, or its first connect failed. ``closed`` is also
true while the gateway is hung up, which the next ``call()``/``start()`` redials.N)r‚   r}   r,   )rI   s   &r   r�   ÚGatewayConnection.finalÊ   s-   € ð �~‰~×MÐM $§+¡+°TÐ"9×"LÐ"LÀ$Ç*Á*¼nÐMr   c               ó   € V ^8„  d   QhRR/# )r!   r"   r0   r   )r$   s   "r   r%   r’   Ð   s   € ÷ ñ  <ñ r   c                	óv   € V P                   P                  V4      pVf   \        V4      ;q P                   V&   V# r2   )ru   rN   r0   )rI   r   Ústates   && r   r—   ÚGatewayConnection.stateÐ   s4   € Ø—‘—‘ 
Ó+ˆØŠ=Ü.:¸:Ó.FÐFˆE—K‘K 
Ñ+Øˆr   c           	     	óÔ  € \         P                  ! 4       V,           p V P                  ;_uu_ 4        V P                  '       d&   V P                  e   V P                  h RRR4       R# V P
                  pVew   V P                  '       de   VP                  4       '       dO   V\        P                  ! 4       Jd6   VP                  \        V\         P                  ! 4       ,
          ^ 4      4       Ve   VP                  4       '       g]   ^ RIHp Ve)   RV n        V P                  P                  4        RV n        V! V P                   RR7      ;q0n        VP#                  4        RRR4       V P                  P%                  \        V\         P                  ! 4       ,
          ^ 4      4      '       g   \'        R4      hV P                  e   V P                  hV P(                  f   V P                  '       d   R# XP                  \        V\         P                  ! 4       ,
          ^ 4      4       \         P                  ! 4       V8¼  g   EK/  \'        R4      h  + '       g   i     Lù; i)TN©Úspawn_context_threadFzhermes-gateway-loop©Únamez/Gateway connection timed out; no local fallback)ÚtimeÚ	monotonicr€   r�   r}   ry   r�   Úis_aliverz   Úcurrent_threadÚjoinÚmaxÚagent.memory_providerr›   r|   ÚclearÚ_runÚstartÚwaitr   rv   )rI   ÚtimeoutÚdeadlineÚthreadr›   s   &&   r   r§   ÚGatewayConnection.start×   s¢  € Ü—>’>Ó# gÕ-ˆØØ×!×!Ó!Ø—:—:�:Ø—{‘{Ò.Ø"Ÿk™kÐ)Ø÷	 "Ñ!ð
 Ÿ™�ØÒ%¨$¯+¯+¨+¸&¿/¹/×:KÒ:KÐPVÔ^g×^vÒ^vÓ^xÓPxð —K‘K¤ H¬t¯~ª~Ó/?Õ$?ÀÓ CÔDØ’>¨¯©×):Ò):ÝJàÒ)ð '+˜œØŸ™×)Ñ)Ô+Ø&+˜œÙ,@ÀÇÁÐQfÔ,gÐg�Fœ\Ø—L‘L”N÷) "ð, —;‘;×#Ñ#¤C¨´4·>²>Ó3CÕ(CÀQÓ$G×HÒHÜ(Ð)ZÓ[Ð[Ø�{‰{Ò&Ø—k‘kÐ!Ø�{‰{Ò&¨$¯*¯*¨*Ùà�K‰Kœ˜H¤t§~¢~Ó'7Õ7¸Ó;Ô<Ü�~Š~Ó 8×+Ü(Ð)ZÓ[Ð[÷? "×!ús%   ².IÁ*!IÂIÂ"A'IÄ
AIÉI'	c                	óz  €  \         P                  ! V P                  4       4       RV n        V P                  P                  4        R #   \         dA   pT P                  f)   \        T\        4      '       d   TM
\        R4      T n         R p?LiR p?ii ; i  RT n        T P                  P                  4        i ; i)Nz,Gateway connection failed; no local fallbackT)
ÚasyncioÚrunÚ_mainÚBaseExceptionr}   r)   r   r�   r|   rE   )rI   r   s   & r   r¦   ÚGatewayConnection._runû   sˆ   € ð	Ü�KŠK˜Ÿ
™
›Ô%ð ˆDŒKØ�K‰K�O‰OÖøô ô 	DØ�{‰{Ò"Ü%/°Ô5G×%HÒ%H™cÔN`ØBóOD�”ÿøð	Dûð
 ˆDŒKØ�K‰K�O‰OÕús)   ‚$A	 Á	BÁ6BÂ
B ÂBÂB Â#B:c              ƒ  	óê  "  € \         P                  ! 4       V n        \         P                  ! 4       V n        V P
                  pVf	   ^ RIHp Tp V! 4       ;_uu_4       GR j  x€L
 pV P                  '       d   V P                  V4      G R j  x€L
  V ;P                  ^,          un        W0n
        W0P                  3V n        V P                  P                  4        \         P                  ! V P                  V4      4      p\         P                  ! V P                  P!                  4       4      p\         P                   ! WE0\         P"                  R7      G R j  x€L
  VP%                  4        VP%                  4        R R R 4      GR j  x€L
  R T n
        R T n        R #  EL= EL LJ L  + GR j  x€L 
 '       g   i     L3; i  \&         d�   pT P                  P)                  4       '       gE   \+        T\,        4      '       d   TM!\-        R\/        T4      P0                   R24      T n         R p?L¥T P5                  \-        \6        4      4        R p?LÈR p?ii ; i  R T n
        R T n        i ; i5i)N©Úconnect_gateway)Úreturn_whenz.Gateway connection failed; no local fallback (Ú))r®   Úget_running_looprx   r{   r~   rq   Úhermes_cli.gateway_clientrµ   r,   Ú_resubscriberv   rw   r|   rE   Úcreate_taskÚ_pumpr¨   ÚFIRST_COMPLETEDÚcancelr*   Úis_setr)   r   Útyper   r}   Ú	_put_lossÚDISCONNECTED)rI   rˆ   rµ   rv   ÚpumpÚstopr   s   &      r   r°   ÚGatewayConnection._main  s«  é € Ü×,Ò,Ó.ˆŒ	Ü—]’]“_ˆŒ
Ø—-‘-ˆØŠ?ÝAØ%ˆGð	Ù—y—y”y FØ—:—:�:Ø×+Ñ+¨FÓ3×3Ð3Ø—
’
˜a••
Ø$”Ø$§j¡jÐ1�”
Ø—‘—‘Ô!Ü×*Ò*¨4¯:©:°fÓ+=Ó>�Ü×*Ò*¨4¯:©:¯?©?Ó+<Ó=�Ü—l’l D <¼W×=TÑ=TÔU×UÐUØ—‘”Ø—‘”÷ !—yð& ˆDŒKØˆDŽJò) !â3ñ V÷ !—y—y’yûô ô 	AØ—;‘;×%Ñ%×'Ò'Ü%/°Ô5G×%HÒ%H™cÔN`ØDÄTÈ#ÃY×EWÑEWÐDXÐXYÐZóO\�—‘ð —‘Ô1´,Ó?×@Ñ@ûð	Aûð ˆDŒKØˆD�JüsÈ   ‚AI3ÁG Á#F Á$G Á''F*ÂF#ÂCF*ÅF&Å$F*Æ G ÆF(ÆG ÆI3Æ G Æ#F*Æ&F*Æ(G Æ*G	Æ0F3Æ1
G	Æ<G	Æ>G ÇI  ÇG ÇIÇAIÈ0I  È5IÉI  ÉIÉI  É I0É0I3c                	ó^   € V P                   Vn        V P                  P                  V4       R # r2   )r,   r'   rt   Úput)rI   Úerrors   &&r   rÁ   ÚGatewayConnection._put_loss$  s   € Ø!%§¡ˆÔØ�‰�‰˜Ör   c              ƒ  ór  "  € \        V P                  P                  4       4       F>  w  r#VP                  f   K   TP	                  V P                  W4      G Rj  x€L
 4       K@  	  R#  L  \         d>   p\        T4      \        9  d   h \        P                  RY$4       RTn         Rp?K‰  Rp?ii ; i5i)ai  A new socket is a new viewer: the gateway streams a session's frames only to connections
that resumed it. Resume each session this viewer had open; one gone meanwhile is dropped. Any
other failure fails the reconnect: ready without the subscription, every prompt is refused on a
live socket that never redials, while a failed redial is retried by the next call.Nz%session.resume %s after reconnect: %s)rO   ru   r_   r7   rQ   Ú_resumer   r   ÚRESUME_GONEr   r   )rI   rv   r   r—   r   s   &&   r   rº   ÚGatewayConnection._resubscribe(  s’   é € ô
 "& d§k¡k×&7Ñ&7Ó&9Ö!:ÑˆJØ×$Ñ$Ò,Ùð-Ø×$Ñ$¨4¯<©<¸Ó+K×%KÖLó	 ";ñ &LøÜ%ô -Ü�s“8¤;Ô.ØÜ—‘ÐDÀjÔVØ(,�×%Ò%ûð	-üs@   ‚9B7¼A,ÁA*
ÁA,Á$B7Á*A,Á,B4Á72B/Â)B7Â/B4Â4B7r   Fc               óœ   € V P                   pV'       d    V! RW$R7      # V! RVR7      #   \         d   p\        YRT4        Rp?L&Rp?ii ; i)zÚ``session.resume`` through ``call`` (the store's attach), re-supplying :attr:`launch_api_key`;
a refusal of the keyed resume is :func:`_resume_plain`'s to decide. ``typed``: the user resumes with
a typed ``--api-key``.úsession.resume©r   Úapi_keyN©r   )r†   r   r   )rI   Úcallr   r   Úkeyr   s   &&&$  r   ÚresumeÚGatewayConnection.resume8  sT   € ð ×!Ñ!ˆßð6ÙÐ,¸ÔQÐQñ Ð$°Ô<Ð<øô #ô 6Ü˜c¨u×5Ñ5ûð6ús   –	* ªAµAÁAc              ƒ  óò   "  € V P                   pV'       d    VP                  RW#R7      G Rj  x€L
 # VP                  RVR7      G Rj  x€L
 #  L  \         d   p\        YBRR7        Rp?L:Rp?ii ; i L+5i)z—:meth:`resume` for :meth:`_resubscribe`, awaited on this loop so a cancelled reconnect cancels
its request. A reconnect types nothing: never ``typed``.rÏ   rÐ   NF)r   rÒ   )r†   Úrpcr   r   )rI   rv   r   rÔ   r   s   &&&  r   rË   ÚGatewayConnection._resumeD  sp   é € ð ×!Ñ!ˆßð<Ø#ŸZ™ZÐ(8ÀZ˜ZÓ]×]Ð]ð —Z‘ZÐ 0¸Z�ZÓH×HÐHñ ^øÜ"ô <Ü˜c°U×;Ò;ûð<úáHùsI   ‚A7˜A ®A¯A ²A7Á	A5Á
A7ÁA ÁA2ÁA-Á(A7Á-A2Á2A7c              ƒ  	óÖ  "  €  VP                   P                  4       G Rj  x€L
 p\        V\        4      '       d   V P	                  V4       R# \        V\
        4      '       d   VP                  R4      MRp\        V\
        4      '       d   V P                  V4      '       d   K¤  \        V\
        4      '       dd   VP                  R4      pW@P                  9   dC    V P                  V,          P                  VP                  R4      VP                  R4      4       V P                   P                  V4       EK;   EL  \         d    \        P                  RR R7        LEi ; i5i)TNÚparamsr   rÀ   rc   zsession state update failed)Úexc_info)rt   rN   r)   r*   rÁ   rM   Ú
_take_sideru   ri   r   r   rÇ   )rI   rv   r+   rÛ   Úsids   &&   r   r¼   ÚGatewayConnection._pumpO  s  é € ØØ Ÿ-™-×+Ñ+Ó-×-ˆEÜ˜%¤×+Ò+Ø—‘˜uÔ%ÙÜ,6°u¼d×,CÒ,C�U—Y‘Y˜xÔ(ÈˆFÜ˜&¤$×'Ò'¨D¯O©O¸F×,CÒ,CÙÜ˜&¤$×'Ò'Ø—j‘j Ó.�ØŸ+™+Ô%ðSØŸ™ CÕ(×4Ñ4°V·Z±ZÀÓ5GÈÏÉÐT]ÓI^Ô_ð �K‰K�O‰O˜E×"ò .øô %ô SÜŸ™Ð%BÈT˜ÖRðSüs;   ‚E)¡D>¢BE)Â%9E)ÃAE Ä E)Å"E&Å#E)Å%E&Å&E)c                	ó  € ^ RI Hp VP                  R4      pVP                  R4      V9  g.   \        V\        4      '       d   VP                  R4      '       g   R# V P                  VR,          4      P                  V4       R# )é    )ÚSIDE_EVENTSrc   rÀ   Útask_idFT)Úhermes_cli.gateway_siderâ   rN   r)   rM   Úside_waiterrÇ   )rI   rÛ   râ   rc   s   &&  r   rÝ   ÚGatewayConnection._take_sidea  sf   € Ý7Ø—*‘*˜YÓ'ˆØ�:‰:�fÓ [Ô0¼
À7ÌD×8QÒ8QÐY`×YdÑYdÐen×YoÒYoÙØ×Ñ˜ Õ+Ó,×0Ñ0°Ô9Ùr   c               ó   € V ^8„  d   QhRR/# )r!   r"   zqueue.Queuer   )r$   s   "r   r%   r’   i  s   € ÷ Añ A kñ Ar   c                	óÆ   € V P                   ;_uu_ 4        V P                  P                  V\        P                  ! 4       4      uuR R R 4       #   + '       g   i     R # ; ir2   )r„   rƒ   Ú
setdefaultrr   rs   ©rI   rã   s   &&r   rå   ÚGatewayConnection.side_waiteri  s1   € Ø�_�_‹_Ø—:‘:×(Ñ(¨´%·+²+³-Ó@÷ �_�_‹_ús   •/AÁA 	c                	ó    € V P                   ;_uu_ 4        V P                  P                  VR 4       R R R 4       R #   + '       g   i     R # ; ir2   )r„   rƒ   Úpoprê   s   &&r   Údrop_side_waiterÚ"GatewayConnection.drop_side_waiterm  s)   € Ø�_�_‹_Ø�J‰J�N‰N˜7 DÔ)÷ �_�_Š_ús	   •<¼A	c                	ó  € R V n         V P                  ;_uu_ 4        V P                   F  pVP                  4        K  	  RRR4       V P                  V P
                  r2Ve3   Ve/   V P                  '       g    VP                  VP                  4       V P                  e?   V P                  \        P                  ! 4       Jd   V P                  P                  ^4       R V n        R#   + '       g   i     L²; i  \         d     Lui ; i)TN)r‚   r„   r…   rE   rx   r~   r�   Úcall_soon_threadsafeÚRuntimeErrorry   rz   r¡   r¢   )rI   Úwakerx   rÄ   s   &   r   ÚcloseÚGatewayConnection.closeq  s½   € ØˆŒØ�_�_‹_ØŸœ�Ø—‘–
ñ '÷ ð —Y‘Y §
¡
ˆdØÒ Ò 0¸¿¿¸ðØ×)Ñ)¨$¯(©(Ô3ð �<‰<Ò#¨¯©¼I×<TÒ<TÓ<VÓ(VØ�L‰L×Ñ˜aÔ ØˆŽ÷ �_ûô  ô Ùðús   œ$C*Á:C= Ã*C:	Ã=DÄ
Dc                ó\  € ^ RI pV P                  V P                  rTVe   Vf   R# VP                  RRRVRV/4      p \        P
                  ! VP                  P                  V4      V4      P                  ^
4       R#   \         d"   p\        P                  RT4        Rp?R# Rp?ii ; i)	u³   Answer one of the gateway's serverâ†’client requests (the ``sudo`` prompt): a JSON-RPC
response frame with the request's own id. Never raises; a lost reply times out gateway-side.NFÚjsonrpcz2.0ÚidÚresultzserver request reply failed: %sT)Újsonrv   rx   Údumpsr®   Úrun_coroutine_threadsafeÚ	websocketÚsendrù   r*   r   r   )rI   Ú
request_idrù   rú   rv   rx   r+   r   s   &&&     r   ÚreplyÚGatewayConnection.reply�  s˜   € ó 	Ø—{‘{ D§I¡I�ØŠ>˜Tš\ÙØ—
‘
˜I u¨d°JÀÈ&ÐQÓRˆð	Ü×,Ò,¨V×-=Ñ-=×-BÑ-BÀ5Ó-IÈ4ÓP×WÑWÐXZÔ[ñ øô ô 	Ü�L‰LÐ:¸CÔ@Ýûð	ús   ¾?A? Á?B+Â
B&Â&B+r©   Úabandonc               	ó>   € V P                   ! V3R VRV/VB ^ ,          # )r©   r  )Úcall_tagged)rI   Úmethodr©   r  rÛ   s   &&$$,r   rÓ   ÚGatewayConnection.call�  s(   € Ø×Ò ÑS°ÐSÀÐSÈFÑSÐTUÕVÐVr   c                ó”   € V P                  V4      pVP                  pV P                  RWR7      pVP                  V4       WCn        V# )zU``session.resume`` after a replay gap; its snapshot names the subscription to detach.rÏ   )r   r  )r—   rG   rÓ   rQ   rH   )rI   r   r  r—   rG   rP   s   &&&   r   ÚreattachÚGatewayConnection.reattach“  sE   € à—
‘
˜:Ó&ˆØ�z‰zˆØ—9‘9Ð-¸*�9ÓVˆØ×Ñ˜XÔ&Ø"ÔØˆr   c                óV  € V P                   e/   \        P                  ! 4       V P                   J d   \        R4      hV P	                  4        V P
                  V P                  rTVe   Vf   \        \        4      hVw  rg\        P                  ! VP                  ! V3RV/VB V4      V3# )zU``(future, epoch)`` of one request sent on the live socket (see :meth:`call_tagged`).zBGatewayConnection.call() on the gateway loop thread would deadlockÚ_timeout)ry   rz   r¡   rò   r§   rw   rx   r   ÚNOT_SENTr®   rü   rØ   )rI   r  ÚbudgetrÛ   Úliverx   rv   r,   s   &&&&    r   Ú_sendÚGatewayConnection._sendœ  s�   € à�<‰<Ò#¬	×(@Ò(@Ó(BÀdÇlÁlÓ(RÜÐcÓdÐdØ�
‰
ŒØ—Z‘Z §¡ˆdØŠ<˜4š<Ü$¤XÓ.Ð.Ø‰ˆÜ×/Ò/°·
²
¸6Ñ0]ÈFÐ0]ÐV\Ñ0]Ð_cÓdÐfkÐkÐkr   c           	     óê  a aaaaa€ ^ RI p^ RIHp S P                  e/   \        P
                  ! 4       S P                  J d   \        R4      hS P                  4        S P                  '       d   \        \        4      hVP                  P                  4       \        P                  ! 4       uooSP                  V3R l4       V! VVVV VV3R lRR7      pS P                  ;_uu_ 4        S P                   P#                  S4       RRR4       VP                  4         SP%                  4        SP'                  4        VP)                  ^
4       S P                  ;_uu_ 4        S P                   P+                  S4       RRR4       SP-                  4       '       d   SP/                  4       # SP1                  4       '       d   \3        S4      h\        \        4      h  + '       g   i     Là; i  + '       g   i     Ly; i  SP'                  4        TP)                  ^
4       S P                  ;_uu_ 4        S P                   P+                  S4       RRR4       i   + '       g   i     i ; i; i)a¿  ``call`` with no answer deadline, for a verb that lasts as long as the work it runs (a plugin
command's handler), on a socket of its own to this connection's gateway: the gateway answers a
socket's requests one at a time, in arrival order (``tui_gateway/ws.py``), so a handler still
running never holds this connection's reads, prompts and interrupts. One dial and one send,
never retried. Waits for the answer or the transport's error, unless *wake* (a
``threading.Event``, set by Ctrl+C or :meth:`close`) is set first: then raises
:class:`CallStopped`; the request was sent and its work goes on, but its answer is dropped. The
socket closes on any of these, and its thread is gone before this returns.Nrš   zHGatewayConnection.call_until() on the gateway loop thread would deadlockc                ó$   <€ SP                  4       # r2   )rE   )Ú_doneró   s   &€r   Ú<lambda>Ú.GatewayConnection.call_until.<locals>.<lambda>¸  s   ø€ ¨t¯x©x¬zr   c            	     óV   <€ \         P                  ! SP                  SSSS S4      4      # r2   )r®   r¯   Ú_command)Úanswerr  rÛ   rI   Úsentró   s   €€€€€€r   r  r  ¹  s#   ø€ ¬g¯kªk¸$¿-¹-ÈÐPVÐX\Ð^dÐfjÓ:kÔ.lr   zhermes-gateway-commandrœ   )Úconcurrent.futuresr¤   r›   ry   rz   r¡   rò   r§   r�   r   r  ÚfuturesÚFuturer{   Úadd_done_callbackr„   r…   Úaddr¨   rE   r¢   ÚdiscardÚdonerù   r¿   r   )	rI   r  ró   rÛ   Ú
concurrentr›   r«   r  r  s	   fffl   @@r   Ú
call_untilÚGatewayConnection.call_until§  s†  ý€ ó 	"Ý>Ø�<‰<Ò#¬	×(@Ò(@Ó(BÀdÇlÁlÓ(RÜÐiÓjÐjØ�
‰
ŒØ�:�:ˆ:Ü$¤XÓ.Ð.Ø!×)Ñ)×0Ñ0Ó2´I·O²OÓ4Eˆˆ�Ø× Ñ Ô!9Ô:Ù%×&lÑ&lØ+CôEˆà�_�_‹_Ø�N‰N×Ñ˜tÔ$÷ à�‰Œð	-Ø�I‰IŒKà�H‰HŒJØ�K‰K˜ŒOØ——“Ø—‘×&Ñ& tÔ,÷ !à�;‰;�=Š=Ø—=‘=“?Ð"Ø�;‰;�=Š=Ü˜fÓ%Ð%Ü ¤Ó*Ð*÷ �_ú÷ !—ûð �H‰HŒJØ�K‰K˜ŒOØ——“Ø—‘×&Ñ& tÔ,÷ !——�ýs<   Ã*GÄH Å$G1ÇG.	Ç1H	È6I2È:I	É	I2ÉI/É*I2c              ƒ  óð  aa"  € V P                   pVf	   ^ RIHp Tp\        P                  ! 4       o\        P
                  ! \        P                  ! VP                  4      4      pVP                  VV3R l4        V! 4       ;_uu_4       GRj  x€L
 p	VP                  4        SP                  V	P                  ! V3R\        R4      /VB G Rj  x€L
 4       RRR4      GRj  x€L
  TP                  4        \        P*                  ! TRR7      G Rj  x€L
  R#  L‹ LL L:  + GRj  x€L 
 '       g   i     LQ; i  \        P                   d     Lk\         d]   p
\        T
\         4      '       g,   \!        TP#                  4       '       d   \$        M\&        4      p
SP)                  T
4        Rp
?
LÌRp
?
ii ; i L¨  TP                  4        \        P*                  ! TRR7      G Rj  x€L 
  i ; i5i)z´The command socket of :meth:`call_until`: dial, send once, settle ``answer`` with the reply or
the transport's error; a set ``wake`` without an answer cancels the dial or the wait.Nr´   c                óT   <€ SP                  4       ;'       g    SP                  4       # r2   )r   r¾   )r~   r  Útasks   &€€r   r  Ú,GatewayConnection._command.<locals>.<lambda>Ô  s   ø€ ¨V¯[©[«]×-KÐ-K¸d¿k¹k»mÐ-Kr   r  ÚinfT)Úreturn_exceptions)rq   r¹   rµ   r®   Úcurrent_taskÚensure_futureÚ	to_threadr¨   r  rE   Ú
set_resultrØ   ÚfloatÚCancelledErrorr*   r)   r   r¿   rÂ   r  Úset_exceptionÚgather)rI   r  rÛ   ró   r  r  rˆ   rµ   rÄ   rv   r   r&  s   &&&&f&     @r   r  ÚGatewayConnection._commandË  sR  ùé € ð —-‘-ˆØŠ?ÝAØ%ˆGÜ×#Ò#Ó%ˆÜ×$Ò$¤W×%6Ò%6°t·y±yÓ%AÓBˆØ×ÑÕKÔLð	?Ù—y—y”y FØ—‘”
Ø×!Ñ!¨¯
ª
°6Ñ([ÄEÈ%ÃLÐ([ÐTZÑ([×"[Ô\÷ !—yð �H‰HŒJÜ—.’. ¸Ô>×>Ò>ñ !á"[÷ !—y—y’yûô ×%Ñ%ô 	ÙÜô 	&Ü˜cÔ#5×6Ò6Ü(¸¿¹¿º­ÌHÓU�Ø× Ñ  ×%Ñ%ûð	&úñ ?øð �H‰HŒJÜ—.’. ¸Ô>×>Ò>üsÙ   „A8G6Á=D> ÂDÂD> Â=D"ÃDÃD"ÃD> Ã%D Ã&D> Ã*+G6ÄF>ÄG6ÄD> ÄD"Ä D> Ä"D;	Ä(D+Ä)
D;	Ä4D;	Ä6D> Ä:G  Ä;D> Ä>F;ÅG  ÅF;ÅF;ÅAF6Æ1G  Æ6F;Æ;G  Æ>G6Ç ,G3Ç,G/Ç-G3Ç3G6c               óD  € ^ RI Hp Vf   \        MTpVe   V! 4       '       d   \        V4      hV P	                  WV4      w  rx\
        P                  ! 4       V,           ^,           p	 VeO   V! V.R4      P                  '       g5   \
        P                  ! 4       V	8  d   V! 4       '       g   KG  \        V4      hVP                  \        V	\
        P                  ! 4       ,
          ^ 4      4      V3#   \         d%   p
TP                  4        \        RT 24      T
hRp
?
ii ; i)a  ``(result, epoch)``: the epoch of the socket that carried the request, so work it admitted
is tied to that gateway life even if another caller redials before this one reads ``epoch``.
``abandon`` (polled) true stops the wait with :class:`CallStopped`; the answer is dropped.)r¨   Ngš™™™™™¹?zGateway did not answer )r  r¨   r   r   r  rž   rŸ   r   rù   r£   ÚTimeoutErrorr¾   r   )rI   r  r©   r  rÛ   r¨   r  Úfuturer,   rª   r   s   &&$$,      r   r  ÚGatewayConnection.call_taggedã  sê   € õ 	,Ø(/ªÕ$¸WˆØÒ¡7§9¢9Ü˜fÓ%Ð%ØŸ
™
 6°6Ó:‰ˆÜ—>’>Ó# fÕ,¨qÕ0ˆð	RØÒ%©d°F°8¸SÓ.A×.F×.FÐ.FÌ4Ï>Ê>ÓK[Ð^fÔKfÙ—9”9Ü% fÓ-Ð-Ø—=‘=¤ X´·²Ó0@Õ%@À!Ó!DÓEÀuÐLÐLøÜô 	RØ�M‰MŒOÜ$Ð'>¸v¸hÐ%GÓHÈcÐQûð	Rús%   Á'C0 Â$C0 Â.AC0 Ã0DÃ;DÄD)r…   rq   r‚   r}   rw   r|   rƒ   r„   r€   r~   ry   rv   r�   r,   rt   r†   r‡   rx   ru   r2   )éZ   )"r   r   r   r   rŒ   rz   r   r‹   rJ   Úclassmethodr�   Úpropertyr�   r—   r§   r¦   r°   rÁ   rº   rÕ   rË   r¼   rÝ   rå   rî   rô   r   rÓ   r  r  r"  r  r  r   r   r   r   ro   ro   Ÿ   sÜ   † Ø€GØ—>’>Ó#€Lô*ð@ ñó ðð ôNó ðNõ
ô"\òH	òò<ò-ð 
=°ô 
=ò	Iò#ò$õAò*òò ðW dð W°Dô Wôò	lò"+òH?ð0R¨Tð R¸4÷ Rð Rr   ro   )r   Ú
__future__r   r®   Úloggingrr   rz   rž   r¹   r   r   r   r   Ú	getLoggerr   r   rÂ   r  Ú	frozensetÚRESUME_REFUSALSrÌ   r   r   r   r.   r0   ro   r   r   r   Ú<module>r?     s¯   ðñ	õ #ã Û Û Û Û ç sÓ sà	×	Ò	˜8Ó	$€ðS€ð Q€ñ ˜[Ð*=Ð>Ó?€ð Ð!3Ð 4Õ4€ñ Ð0Ð2EÐFÓG€ôcÐ$ô cò
gõd÷]!ñ ]!÷@URó URr   