+
    jHàjI  ã                  óâ   € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H	t	 ^ RI
Ht ^ RIHtHt ^ RIHt ^ RIHt ^ R	IHt ]P*                  ! R
4      tR R ltRtR R lt ! R R4      tR# )an  ``hermes update --gateway`` progress/completion notifications for GatewayRunner.

Split out of ``gateway/run_notifications.py``; ``GatewayNotificationsMixin`` inherits it, so
these stay bound onto ``GatewayRunner`` via the MRO. ``gateway.run`` internals are imported
lazily inside method bodies (import cycle), so ``patch("gateway.run.X")`` keeps intercepting them.
)ÚannotationsN)Úsuppress)Údatetime)ÚPath)ÚAnyÚOptional©Út)ÚPlatform)Ú_log_suppressedzgateway.runc               ó   € V ^8„  d   QhRR/# )é   ÚreturnÚstr© )Úformats   "ÚE/home/ubuntu/.hermes/hermes-agent/gateway/run_notifications_update.pyÚ__annotate__r      s   € ÷ -ñ -˜sñ -ó    c                 ó   € \        R 4      # )zgateway.update.failed_noticer   r   r   r   Ú_update_failed_noticer      s   € ÜÐ+Ó,Ð,r   ç      ¬@c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úoutputr   ÚlimitÚintr   r   )r   s   "r   r   r   &   s&   € ÷ Gñ G ð G¨Cð G°Cñ Gr   c                ó>   € \        V 4      V8:  d   V # RW) R ,           # )zJLast ``limit`` chars of an update log, prefixed with an ellipsis when cut.u   â€¦N)Úlen)r   r   s   &&r   Ú_update_output_tailr   &   s#   € ä˜“[ EÔ)ˆ6ÐF¨u°v¸f¸g°Õ/FÐFr   c                  ó\  € ] tR t^+tRt]P                   ! R R4      4       t]P                   ! R R4      4       tR R lt	]
R R	 l4       t]R
 R l4       t]R R l4       tR R ltR R ltR R lt]R R l4       t]R R l4       tR R ltR R ltR R ltR$R R lltR  R! ltR"tR## )%ÚGatewayUpdateNotificationsMixinzeUpdate watcher: streams ``hermes update --gateway`` output, forwards prompts, sends the final notice.c                  óp   € ] tR t^.t$ RtR]R&   R]R&   R]R&   R]R&   R]R&   R]R&   R	 R
 ltR R ltRtR# )Ú,GatewayUpdateNotificationsMixin._UpdatePathszTMarker files ``hermes update --gateway`` and its watcher exchange under HERMES_HOME.r   ÚpendingÚclaimedr   Ú	exit_codeÚpromptÚresponsec               ó   € V ^8„  d   QhRR/# ©r   r   Úboolr   )r   s   "r   r   Ú9GatewayUpdateNotificationsMixin._UpdatePaths.__annotate__9   s   € ÷ 	Bñ 	B ñ 	Br   c                	óz   € V P                   P                  4       ;'       g    V P                  P                  4       # ©N)r#   Úexistsr$   )Úselfs   &r   Úany_pendingÚ8GatewayUpdateNotificationsMixin._UpdatePaths.any_pending9   s*   € Ø—<‘<×&Ñ&Ó(×AÐA¨D¯L©L×,?Ñ,?Ó,AÐAr   c               ó   € V ^8„  d   QhRR/# ©r   r   ÚNoner   )r   s   "r   r   r+   <   s   € ÷ 	*ñ 	* ñ 	*r   c                	óÀ   € V P                   V P                  V P                  V P                  V P                  V P
                  3 F  pVP                  R R7       K  	  R# )T©Ú
missing_okN)r#   r$   r   r%   r&   r'   Úunlink)r/   Úps   & r   Ú
unlink_allÚ7GatewayUpdateNotificationsMixin._UpdatePaths.unlink_all<   sC   € Ø—l‘l D§L¡L°$·+±+¸t¿~¹~ÈtÏ{É{Ð\`×\iÑ\iÓj�Ø—‘ D�Ö)ó kr   r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__r0   r:   Ú__static_attributes__r   r   r   Ú_UpdatePathsr"   .   s3   ‡ ábà‹Ø‹Ø‹Ø‹Ø‹Ø‹õ	B÷	*ñ 	*r   rC   c                  ó`   € ] tR t^@t$ RtR]R&   R]R&   R]R&   R]R&   R]R&   R	 tR
 R ltRtR# )Ú-GatewayUpdateNotificationsMixin._UpdateTargetz5Resolved delivery target for update watcher messages.r   ÚadapterÚchat_idúOptional[str]Úsession_keyÚmetadataÚplatformc                	óJ   € ^ RI Hp V! V P                  V P                  R7      # )é    ©Ú_non_conversational_metadata©rK   )Úgateway.runrO   rJ   rK   )r/   rO   s   & r   Úsend_metadataÚ;GatewayUpdateNotificationsMixin._UpdateTarget.send_metadataJ   s   € Ý@Ù/°·±ÈÏÉÔVÐVr   c               ó   € V ^8„  d   QhRR/# )r   Útextr   r   )r   s   "r   r   Ú:GatewayUpdateNotificationsMixin._UpdateTarget.__annotate__N   s   € ÷ 	^ñ 	^ 3ñ 	^r   c              ƒ  	óˆ   "  € V P                   P                  V P                  WP                  4       R 7      G Rj  x€L
 #  L5i)©rJ   N)rF   ÚsendrG   rR   )r/   rU   s   &&r   rY   Ú2GatewayUpdateNotificationsMixin._UpdateTarget.sendN   s2   é € ØŸ™×*Ñ*¨4¯<©<¸×HZÑHZÓH\Ð*Ó]×]Ð]Ñ]ùs   ‚9A»A ¼Ar   N)	r<   r=   r>   r?   r@   rA   rR   rY   rB   r   r   r   Ú_UpdateTargetrE   @   s1   ‡ áCà‹Ø‹Ø"Ó"Ø‹Ø‹ò	W÷	^ñ 	^r   r[   c               ó   € V ^8„  d   QhRR/# r3   r   )r   s   "r   r   Ú,GatewayUpdateNotificationsMixin.__annotate__Q   s   € ÷ Xñ X°Tñ Xr   c                ó  € \        V RR4      pV'       d   VP                  4       '       g   R#  \        P                  ! V P	                  4       4      V n        R#   \         d    \        P                  R4        R# i ; i)z;Ensure a background task is watching for update completion.Ú_update_notification_taskNz;Skipping update notification watcher: no running event loop)	ÚgetattrÚdoneÚasyncioÚcreate_taskÚ_watch_update_progressr_   ÚRuntimeErrorÚloggerÚdebug)r/   Úexisting_tasks   & r   Ú#_schedule_update_notification_watchÚCGatewayUpdateNotificationsMixin._schedule_update_notification_watchQ   se   € ä Ð&AÀ4ÓHˆß ×!3Ñ!3×!5Ò!5Ùð	XÜ-4×-@Ò-@À×A\ÑA\ÓA^Ó-_ˆDÖ*øÜô 	XÜ�L‰LÐV×Wð	Xús   ¯)A Á A>Á=A>c               ó   € V ^8„  d   QhRR/# )r   r   r"   r   )r   s   "r   r   r]   \   s   € ÷ 
ñ 
ÐJñ 
r   c           	     	ó�   € ^ RI Hp V P                  VR,          VR,          VR,          VR,          VR,          VR,          R7      # )	rM   )Ú_hermes_homez.update_pending.jsonz.update_pending.claimed.jsonz.update_output.txtz.update_exit_codez.update_prompt.jsonz.update_response)r#   r$   r   r%   r&   r'   )rQ   rm   rC   )Úclsrm   s   & r   Ú_update_pathsÚ-GatewayUpdateNotificationsMixin._update_paths[   sQ   € å,Ø×ÑØ Ð#9Õ9Ø Ð#AÕAÈ,ÐYmÕJmØ"Ð%8Õ8ØÐ"7Õ7À,ÐQcÕBcð	  ó 
ð 	
r   c               ó    € V ^8„  d   QhRRRR/# )r   ÚdataÚdictr   rH   r   )r   s   "r   r   r]   f   s   € ÷ ñ ˜dð  }ñ r   c                óf  € \        V P                  R4      ;'       g    R4      P                  4       pV'       d   V# ^ RIHp \        V P                  R4      ;'       g    R4      P                  R4      p\        V4      ^8¼  d,   V^ ,          R8X  d   V^,          R9  d   V! V^,          4      # R# )	zÔOwning profile of a persisted restart/update marker: explicit ``profile``, else the
``agent:<profile>:`` lane of its ``session_key`` (markers written before ``profile`` was
persisted); ``None`` = default profile.ÚprofileÚ )Ú"profile_from_session_key_namespacerI   Ú:ÚagentN)Úmainrv   )r   ÚgetÚstripÚgateway.sessionrw   Úsplitr   )rr   ru   rw   Úpartss   &   r   Ú_marker_profileÚ/GatewayUpdateNotificationsMixin._marker_profilee   sŒ   € ô
 �d—h‘h˜yÓ)×/Ð/¨RÓ0×6Ñ6Ó8ˆßØˆNÝFÜ�D—H‘H˜]Ó+×1Ð1¨rÓ2×8Ñ8¸Ó=ˆÜˆu‹:˜Œ?˜u Q�x¨7Ô2°u¸QµxÀ|Ô7SÙ5°e¸AµhÓ?Ð?Ùr   c               ó    € V ^8„  d   QhRRRR/# )r   rr   rs   r   zOptional[float]r   )r   s   "r   r   r]   t   s   € ÷ /ñ / $ð /¨?ñ /r   c                ó†  € \        V P                  R4      ;'       g    R4      P                  4       pV'       g   R#  \        P                  ! V4      pTP                  '       d!   \        P                  ! TP                  4      M\        P                  ! 4       pY2,
          P                  4       #   \
         d     R# i ; i)uþ   Age of a persisted update marker, from the ``timestamp`` stamped by its writer.

``None`` when the marker carries no parseable stamp â€” the field is absent on markers
written before it existed, and callers keep the old retry behavior rather than guess.
Ú	timestamprv   N)	r   r{   r|   r   ÚfromisoformatÚ
ValueErrorÚtzinfoÚnowÚtotal_seconds)rr   ÚrawÚstampedrˆ   s   &   r   Ú_marker_age_secondsÚ3GatewayUpdateNotificationsMixin._marker_age_secondss   sŒ   € ô �$—(‘(˜;Ó'×-Ð-¨2Ó.×4Ñ4Ó6ˆßÙð	Ü×,Ò,¨SÓ1ˆGð /6¯n¯n¨nŒh�lŠl˜7Ÿ>™>Ô*Ä(Ç,Â,Ã.ˆØ•×,Ñ,Ó.Ð.øô	 ô 	Úð	ús   ¾B1 Â1C Â?C c               ó    € V ^8„  d   QhRRRR/# )r   ÚpathsrC   r   zOptional[_UpdateTarget]r   )r   s   "r   r   r]   …   s   € ÷ ñ ¨Lð Ð=Tñ r   c           
     ó²  € VP                   VP                  3 EF$  pVP                  4       '       g   K  \        \        4      ;_uu_ 4        \
        P                  ! VP                  RR7      4      pVP                  R4      pVP                  R4      pVP                  R4      pV'       d	   V'       g    RRR4       K¨  \        V4      pV P                  WpP                  V4      4      pV'       g    RRR4        R# V P                  WuW84      p	T P                  Y…T;'       g    V RV 2W—4      uuRRR4       u # 	  R#   + '       g   i     EK=  ; i)zQResolve adapter/chat/session for update watcher messages from the pending marker.ú	utf-8-sig©ÚencodingrK   rG   rI   Nrx   )r$   r#   r.   r   Ú	ExceptionÚjsonÚloadsÚ	read_textr{   r
   Ú_authorization_adapterr€   Ú_pending_marker_metadatar[   )
r/   r�   Úpathr#   Úplatform_strrG   rI   rK   rF   rJ   s
   &&        r   Ú_resolve_update_targetÚ6GatewayUpdateNotificationsMixin._resolve_update_target…   s  € à—]‘] E§M¡MÔ2ˆDØ—;‘;—=’=ÙÜœ)×$Õ$ÜŸ*š* T§^¡^¸[ ^Ó%IÓJ�Ø&Ÿ{™{¨:Ó6�Ø!Ÿ+™+ iÓ0�Ø%Ÿk™k¨-Ó8�ß$¯Ø÷ %Ñ$ô $ LÓ1�ð ×5Ñ5°h×@TÑ@TÐU\Ó@]Ó^�ßØ÷ %Ò$ð  ×8Ñ8¸ÈGÓ]�à×)Ñ)Ø k×&PÐ&P¸°~ÀQÀwÀiÐ5PÐRZó÷ %Ô$ñ 3ñ* ÷% %×$Ñ$ús   ÁA)EÂ6EÃ4EÄ 3EÅEc               ó   € V ^8„  d   QhRR/# )r   rr   rs   r   )r   s   "r   r   r]   ž   s   € ÷ 
ñ 
Àñ 
r   c           	     óˆ   € V P                  WVP                  R4      VP                  R4      VP                  R4      VR7      # )z\Thread metadata for a persisted update/restart marker (thread_id/chat_type/message_id keys).Ú	thread_idÚ	chat_typeÚ
message_id)r¡   Úreply_to_message_idrF   )Ú_thread_metadata_for_targetr{   )r/   rK   rG   rr   rF   s   &&&&&r   r™   Ú8GatewayUpdateNotificationsMixin._pending_marker_metadataž   sA   € à×/Ñ/Ø˜tŸx™x¨Ó4ÀÇÁÈÓ@UØ $§¡¨Ó 6Àð 0ó 
ð 	
r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r�   rC   ÚdeadlineÚfloatÚpoll_intervalr   r4   r   )r   s   "r   r   r]   ¥   s+   € ÷ 3ñ 3¸ð 3ÐQVð 3Ðglð 3Ðquñ 3r   c              ƒ  ób  "  € \         P                  R4       \        P                  ! 4       pVP	                  4       '       dv   VP                  4       V8  da   VP                  P                  4       '       d!   V P                  4       G Rj  x€L
 '       d   R# \        P                  ! V4      G Rj  x€L
  K‹  VP	                  4       '       dZ   VP                  P                  4       '       g8   VP                  P                  RRR7       V P                  4       G Rj  x€L
  R# R# R#  L� Ly L5i)zSFallback when no adapter/chat can be resolved: wait for the exit code, then notify.zOUpdate watcher: cannot resolve adapter/chat_id, falling back to completion-onlyNÚ124úutf-8r’   )rf   Úwarningrb   Úget_running_loopr0   Útimer%   r.   Ú_send_update_notificationÚsleepÚ
write_text)r/   r�   r§   r©   Úloops   &&&& r   Ú_watch_update_completion_onlyÚ=GatewayUpdateNotificationsMixin._watch_update_completion_only¥   sÖ   é € ä�‰ÐhÔiä×'Ò'Ó)ˆØ×Ñ×!Ò! d§i¡i£k°HÔ&<Ø�‰×%Ñ%×'Ò'°$×2PÑ2PÓ2R×,RÖ,RÙÜ—-’- Ó.×.Ò.Ø×Ñ×Ò u§¡×'=Ñ'=×'?Ò'?Ø�O‰O×&Ñ& u°wÐ&Ô?Ø×0Ñ0Ó2×2Ò2ñ (@Ññ -Sá.ñ 3ùsT   ‚A D/Á4D/Á8D/ÂD)Â	D/ÂD/Â1D+Â2D/ÃD/Ã.0D/ÄD-ÄD/Ä+D/Ä-D/c               ó    € V ^8„  d   QhRRRR/# )r   r�   rC   r   r   r   )r   s   "r   r   r]   ³   s   € ÷ Sñ S ð S°#ñ Sr   c                	ó|   € \        V P                  P                  R R7      P                  4       ;'       g    R4      # )r‘   r’   Ú1)r   r%   r—   r|   )r�   s   &r   Ú_update_exit_codeÚ1GatewayUpdateNotificationsMixin._update_exit_code²   s0   € ä�5—?‘?×,Ñ,°kÐ,ÓB×HÑHÓJ×QÐQÈcÓRÐRr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rš   r   Úoffsetr   r   ztuple[str, int]r   )r   s   "r   r   r]   ·   s&   € ÷ Jñ J¨ð J°cð J¸oñ Jr   c                óÈ   €  V P                  4       p\        T4      T8:  d   R\        T4      3# Y!R P                  RRR7      \        T4      3#   \         d    RT3u # i ; i)z?Read update output defensively; logs may contain invalid UTF-8.rv   Nr¬   Úreplace©Úerrors)Ú
read_bytesÚOSErrorr   Údecode)rš   r¼   rr   s   && r   Ú_read_update_output_sinceÚ9GatewayUpdateNotificationsMixin._read_update_output_since¶   sm   € ð	Ø—?‘?Ó$ˆDô ˆt‹9˜ÔØ”s˜4“y�=Ð Ø�Gˆ}×#Ñ# G°IÐ#Ó>ÄÀDÃ	ÐIÐIøô	 ô 	Ø�v�:Òð	ús   ‚A ÁA!Á A!c               ó$   € V ^8„  d   QhRRRRRR/# )r   Útargetr[   rU   r   r   r4   r   )r   s   "r   r   r]   Á   s&   € ÷ 	Iñ 	I°ð 	IÀSð 	IÈTñ 	Ir   c           
   ƒ  ód  "  € ^ RI Hp V! V4      P                  4       pV'       g   R# Rp\        ^ \	        V4      V4       FS  p\        \        P                  R4      ;_uu_ 4        VP                  RWFWe,             R24      G Rj  x€L
  RRR4       KU  	  R#  L  + '       g   i     Kl  ; i5i)zVSend buffered update output as fenced chunks that fit message limits (Telegram: 4096).©Ú
strip_ansiNé¬  zUpdate stream send failed: %sz```
ú
```)	Útools.ansi_striprÊ   r|   Úranger   r   ÚloggingÚDEBUGrY   )r/   rÇ   rU   rÊ   ÚcleanÚ	max_chunkÚis   &&&    r   Ú_send_update_outputÚ3GatewayUpdateNotificationsMixin._send_update_outputÁ   sŠ   é € å/Ù˜4Ó ×&Ñ&Ó(ˆßÙØˆ	Ü�qœ#˜e›* iÖ0ˆAÜ ¤§¡Ð0O×PÕPØ—k‘k E¨%°!µ-Ð*@Ð)AÀÐ"GÓH×HÐH÷ QÑPó 1áH÷ Q×PÐPüs0   ‚A$B0Á&!BÂB
ÂBÂB0ÂBÂB-Â'	B0c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   rÇ   r[   Úprompt_textr   Údefaultr   r4   r   )r   s   "r   r   r]   Ì   s0   € ÷ _ñ _°=ð _Èsð _Ð]`ð _Ðeiñ _r   c           
   ƒ  ó¦  "  € RpVP                   p\        \        V4      RR4      em   \        \        P
                  R4      ;_uu_ 4        VP                  VP                  W#VP                  VP                  4       R7      G Rj  x€L
  RpRRR4       V'       gJ   V'       d   \        RVR7      MR	p\        VR
R4      pVP                  \        RW&VR7      4      G Rj  x€L
  RV P                  VP                  4      P                  n        \        P!                  RVP                  VR,          4       R#  L³  + '       g   i     L·; i Lm5i)zWForward an update prompt: platform-native buttons first (Discord, Telegram), else text.FÚsend_update_promptNz%Button-based update prompt failed: %s)rG   r&   rØ   rI   rJ   Tzgateway.update.prompt_default)rØ   rv   Útyped_command_prefixÚ/zgateway.update.prompt)r&   Údefault_hintÚprefixz!Forwarded update prompt to %s: %s:NéP   N)rF   r`   Útyper   rÏ   rÐ   rÚ   rG   rI   rR   r	   rY   Ú_session_stateÚ
persistentÚupdate_prompt_pendingrf   Úinfo)r/   rÇ   r×   rØ   Úsent_buttonsrF   rÝ   Ú_ps   &&&&    r   Ú_forward_update_promptÚ6GatewayUpdateNotificationsMixin._forward_update_promptÌ   s  é € àˆØ—.‘.ˆÜ”4˜“=Ð"6¸Ó=ÒIÜ ¤§¡Ð0W×XÕXØ×0Ñ0Ø"ŸN™N°;Ø &× 2Ñ 2¸V×=QÑ=QÓ=Sð 1ó ÷ ð ð  $�÷ Y÷ ßRYœ1Ð<ÀgÕNÐ_aˆLÜ˜Ð"8¸#Ó>ˆBØ—+‘+œaÐ 7ÀÐoqÔrÓs×sÐsàSWˆ×Ñ˜F×.Ñ.Ó/×:Ñ:ÔPÜ�‰Ð7¸×9KÑ9KÈ[ÐY\ÕM]Ö^ñ÷ Y×Xúñ tùsI   ‚A	EÁ;D<ÂD:ÂD<ÂEÂEÂ%<EÃ!EÃ"AEÄ:D<Ä<E	Å	Ec               ó$   € V ^8„  d   QhRRRRRR/# )r   r�   rC   rI   rH   r   r4   r   )r   s   "r   r   r]   ß   s"   € ÷ ;ñ ;¨<ð ;Àmð ;ÐX\ñ ;r   c                	óv   € VP                  4        V P                  V4      pVe   RVP                  n        R # R # )NF)r:   Ú_peek_session_staterâ   rã   )r/   r�   rI   Ústates   &&& r   Ú_clear_update_markersÚ5GatewayUpdateNotificationsMixin._clear_update_markersß   s7   € Ø×ÑÔØ×(Ñ(¨Ó5ˆØÒØ5:ˆE×ÑÖ2ñ r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r©   r¨   Ústream_intervalÚtimeoutr   r4   r   )r   s   "r   r   r]   å   s2   € ÷ E;ñ E;Ø"ðE;Ø;@ðE;ØQVðE;à	ñE;r   c              ƒ  ó<  a aaaaaa"  € S P                  4       o\        P                  ! 4       oSP                  4       V,           pS P	                  S4      oSf   S P                  SWA4      G Rj  x€L
  R# SP                  p^ oSP                  4       oRoR VVVV V3R llpR VVVV 3R llpSP                  4       V8  Ed   SP                  P                  4       '       d°   V! 4        V! 4       G Rj  x€L
  \        \        P                  R4      ;_uu_ 4        S P                  S4      pSP                  V^ 8X  d   \        R4      M	\        4       4      G Rj  x€L
  \         P#                  R	W…4       RRR4       S P%                  SV4       R# V! 4        SP'                  4       '       d,   SP                  4       S,
          V8¼  d   V! 4       G Rj  x€L
  V'       d   S P)                  V4      MRp	SP*                  P                  4       '       d«   V'       d£   \-        \-        V	R
R4      RR4      '       g…    \.        P0                  ! SP*                  P3                  RR7      4      p
V
P5                  RR4      pV'       d:   V! 4       G Rj  x€L
  S P7                  SWºP5                  RR4      4      G Rj  x€L
  \        P>                  ! V4      G Rj  x€L
  EK3  SP                  P                  4       '       g™   \         PA                  RV4       SP                  PC                  RRR7       V! 4       G Rj  x€L
  \E        \F        4      ;_uu_ 4        SP                  \        R4      4      G Rj  x€L
  RRR4       S P%                  SV4       R# R#  EL- EL© ELE  + '       g   i     EL6; i ELâ EL* EL  \.        P8                  \:        3 d"   p\         P=                  RT4        Rp?EL8Rp?ii ; i EL' LÄ LŒ  + '       g   i     L’; i5i)a  Watch ``hermes update --gateway``, streaming output + forwarding prompts.

Polls ``.update_output.txt`` for new content and sends chunks to the user periodically;
detects ``.update_prompt.json`` (written when the update process needs input) and forwards it.
Nrv   c               ó   € V ^8„  d   QhRR/# r3   r   )r   s   "r   r   ÚLGatewayUpdateNotificationsMixin._watch_update_progress.<locals>.__annotate__ù   s   € ÷ 	=ñ 	= Tñ 	=r   c               “  ó¢   <"  € SR up oV P                  4       '       d-   SP                  4       oSP                  SV 4      G Rj  x€L
  R# R#  L5i)rv   N)r|   r¯   rÔ   )rU   ÚbufferÚlast_stream_timer³   r/   rÇ   s    €€€€€r   Ú_flush_bufferÚMGatewayUpdateNotificationsMixin._watch_update_progress.<locals>._flush_bufferù   sF   øé € à! 2ˆLˆD�&Ø�z‰z�|Š|Ø#'§9¡9£;Ð Ø×.Ñ.¨v°tÓ<×<Ò<ñ á<ùs   ƒAAÁAÁ	Ac               ó   € V ^8„  d   QhRR/# r3   r   )r   s   "r   r   rô      s   € ÷ 	$ñ 	$ $ñ 	$r   c                 ó  <€ SP                   P                  4       '       dK   \        \        4      ;_uu_ 4        SP	                  SP                   S4      w  p oSV ,          oR R R 4       R # R #   + '       g   i     R # ; ir-   )r   r.   r   rÂ   rÄ   )Úchunkrö   Ú
bytes_sentr�   r/   s    €€€€r   Ú_read_new_outputÚPGatewayUpdateNotificationsMixin._watch_update_progress.<locals>._read_new_output   s]   ø€ à�|‰|×"Ñ"×$Ò$Üœg×&Õ&Ø(,×(FÑ(FÀuÇ|Á|ÐU_Ó(`Ñ%�E˜:Ø˜e•O�F÷ 'Ñ&ñ %ß&×&Ð&ús   ¹)A.Á.A?	z$Update final notification failed: %szgateway.update.finishedz&Update finished (exit=%s), notified %srâ   rã   Fr‘   r’   r&   rØ   z Failed to read update prompt: %sz$Update watcher timed out after %.0fsr«   r¬   zgateway.update.timed_out)$ro   rb   r®   r¯   rœ   r´   rI   r%   r.   r   rÏ   ÚWARNINGr¹   rY   r	   r   rf   rä   rí   r|   rë   r&   r`   r•   r–   r—   r{   rç   ÚJSONDecodeErrorrÂ   rg   r±   r­   r²   r   r”   )r/   r©   rð   rñ   r§   rI   rø   rþ   r%   Ú_pending_stateÚprompt_datar×   Úerö   rý   r÷   r³   r�   rÇ   s   f&&&         @@@@@@r   rd   Ú6GatewayUpdateNotificationsMixin._watch_update_progresså   s$  þé € ð ×"Ñ"Ó$ˆÜ×'Ò'Ó)ˆØ—9‘9“; Õ(ˆØ×,Ñ,¨UÓ3ˆØŠ>Ø×4Ñ4°U¸HÓT×TÐTÙØ×(Ñ(ˆØˆ
ØŸ9™9›;ÐØˆ÷	=ô 	=÷	$ó 	$ð �i‰i‹k˜HÕ$Ø�‰×%Ñ%×'Ò'Ù Ô"Ù#“o×%Ð%Ü$¤W§_¡_Ð6\×]Õ]Ø $× 6Ñ 6°uÓ =�IØ Ÿ+™+Ø8AÀQ¼œÐ3Ô4ÔLaÓLcó÷ ð ô —K‘KÐ HÈ)Ôa÷ ^ð ×*Ñ*¨5°+Ô>ÙÙÔØ�|‰|�~Š~ 4§9¡9£;Ð1AÕ#AÀoÔ"UÙ#“o×%Ð%çFQ˜T×5Ñ5°kÔBÐW[ˆNØ�|‰|×"Ñ"×$Ò$¯¼WÜ˜¨°dÓ;Ð=TÐV[÷>ò >ðHÜ"&§*¢*¨U¯\©\×-CÑ-CÈ[Ð-CÓ-YÓ"Z�KØ"-§/¡/°(¸BÓ"?�Kß"Ù+›o×-Ð-Ø"×9Ñ9¸&À+ÏÉÐ_hÐjlÓOmÓn×nÐnô —-’- Ó.×.Ó.Ø�‰×%Ñ%×'Ò'Ü�N‰NÐAÀ7ÔKØ�O‰O×&Ñ& u°wÐ&Ô?Ù“/×!Ð!Üœ)×$Õ$Ø—k‘k¤!Ð$>Ó"?Ó@×@Ð@÷ %à×&Ñ& u¨kÖ:ñ (òe Uò0 &ò÷ ^×]Ð]úò &ò .ÚnøÜ×,Ñ,¬gÐ6ô HÜ—L‘LÐ!CÀQ×GÒGûðHúâ.ñ "á@÷ %×$üs  ‰A'PÁ0NÁ1A4PÃ&PÃ7N Ã8&PÄA N&ÅN#ÅN&Å98PÆ2&PÇN:ÇPÇ%2PÈPÈ PÈ?A	O Ê	
O ÊN=Ê)O Ê=O Ê>O ËPËPË&PÌ=PÍ PÍPÍP	Í:PÍ;P	Í?PÎ PÎ#N&Î&N7	Î1
PÎ=O Ï O ÏO?ÏO:Ï4PÏ:O?Ï?PÐPÐP	Ð	P	ÐPc               ó   € V ^8„  d   QhRR/# r)   r   )r   s   "r   r   r]   ,  s   € ÷ Jñ J°ñ Jr   c           	   ƒ  ó°
  aaa"  € ^ RI Hp V P                  4       oSP                  4       '       g   R# RoSP                  oR VVV3R llp SP
                  P                  4       '       d(    SP
                  P                  SP                  4       MjSP                  P                  4       '       gK    S'       d@   SSP                  SP                  SP                  3 F  pVP                  RR7       K  	  R# R# \        P                  ! SP                  P                  RR7      4      pVP                  R	4      pVP                  R
4      pSP                  P                  4       '       gO   V! R4      S'       d?   SSP                  SP                  SP                  3 F  pVP                  RR7       K  	  # # V P!                  S4      pSP                  P                  4       '       d,   SP                  P#                  4       P%                  RRR7      MRp\'        V4      p	V P)                  W�P+                  V4      4      p
V'       Ed   V
'       gú   V P-                  V4      pVe–   V\.        8”  d‹   \0        P3                  RWVVR,          V4       V P5                  SVP                  R4      4        S'       d@   SSP                  SP                  SP                  3 F  pVP                  RR7       K  	  R# R# V! RV4      S'       d?   SSP                  SP                  SP                  3 F  pVP                  RR7       K  	  # # V'       d¿   T P7                  W–WJ4      p^ RIHp V! V4      P=                  4       pV^ 8X  d'   \?        R4      pV'       d   V R\A        VR4       R2pM*\C        4       pV'       d   \?        RV\A        VR4      R7      pV
PE                  WnV! WÉR7      R7      G Rj  x€L
  \0        PG                  RWVV4       S'       d>   SSP                  SP                  SP                  3 F  pTP                  RR7       K  	  R#   \         do    SP                  P                  4       '       gK    S'       d@   SSP                  SP                  SP                  3 F  pTP                  RR7       K  	  R# R#  ELØi ; i LÞ  \H         d!   p\0        P3                  R T4        Rp?LëRp?ii ; i  S'       d?   SSP                  SP                  SP                  3 F  pTP                  RR7       K  	  i i ; i5i)!zˆIf an update finished, notify the user.

False while the update is still running (caller may retry); True after a definitive send/skip.
rN   FTc               ó    € V ^8„  d   QhRRRR/# )r   Úreasonr   r   r*   r   )r   s   "r   r   ÚOGatewayUpdateNotificationsMixin._send_update_notification.<locals>.__annotate__8  s   € ÷ 	ñ 	˜3ð 	¨$ñ 	r   c                óž   <€ \         P                  ! V .VO5!   R oSP                  oSP                  P	                  SP                  4       R # )F)rf   rä   r#   r$   r¾   )r	  ÚargsÚactive_pending_pathÚcleanupr�   s   &*€€€r   Ú_deferÚIGatewayUpdateNotificationsMixin._send_update_notification.<locals>._defer8  s<   ø€ ä�KŠK˜Ð& Ô&ØˆGØ"'§-¡-ÐØ�M‰M×!Ñ! %§-¡-Ô0Ùr   r6   r‘   r’   rK   rG   z2Update notification deferred: update still runningr¬   r¾   r¿   rv   NzRPost-update notification for %s:%s dropped after %.1fh: %s adapter never connectedr   rI   z:Update notification deferred: %s adapter not connected yetrÉ   zgateway.update.finished_successz

```
rË   rÌ   zgateway.update.last_linesi   )ÚmsgÚtailrP   rX   z0Sent post-update notification to %s:%s (exit=%s)z#Post-update notification failed: %s)%rQ   rO   ro   r0   r$   r#   r.   r¾   ÚFileNotFoundErrorr   r%   r8   r•   r–   r—   r{   r¹   rÁ   rÃ   r
   r˜   r€   rŒ   Ú'_UPDATE_NOTIFY_MAX_ADAPTER_WAIT_SECONDSrf   r­   rí   r™   rÍ   rÊ   r|   r	   r   r   rY   rä   r”   )r/   rO   r  r9   r#   r›   rG   r%   r   rK   rF   ÚagerJ   rÊ   r  r  r  r  r�   s   &               @@@r   r°   Ú9GatewayUpdateNotificationsMixin._send_update_notification,  s`  úé € õ
 	=Ø×"Ñ"Ó$ˆØ× Ñ ×"Ò"ÙØˆØ#Ÿm™mÐ÷	ò 	ð5	.Ø�}‰}×#Ñ#×%Ò%ð$Ø—M‘M×)Ñ)¨%¯-©-Õ8ð —]‘]×)Ñ)×+Ò+Ø÷V Ø-¨u¯}©}¸e¿l¹lÈEÏOÉOÓ\�AØ—H‘H¨�HÖ-ó ]ñ ôU —j’j §¡×!8Ñ!8À+Ð!8Ó!NÓOˆGØ"Ÿ;™; zÓ2ˆLØ—k‘k )Ó,ˆGØ—?‘?×)Ñ)×+Ò+ÙÐRÓS÷L Ø-¨u¯}©}¸e¿l¹lÈEÏOÉOÓ\�AØ—H‘H¨�HÖ-ò ]ð ðK ×.Ñ.¨uÓ5ˆIØTY×T`ÑT`×TgÑTg×TiÒTi�U—\‘\×,Ñ,Ó.×5Ñ5°gÀiÐ5ÔPÐoqˆFÜ Ó-ˆHØ×1Ñ1°(×<PÑ<PÐQXÓ<YÓZˆGßˆwŸwØ×.Ñ.¨wÓ7�Ø’? sÔ-TÔ'Tô —N‘Nð$Ø%1¸CÀ&½LÈ,ôXð ×.Ñ.¨u°g·k±kÀ-Ó6PÔQØ÷* Ø-¨u¯}©}¸e¿l¹lÈEÏOÉOÓ\�AØ—H‘H¨�HÖ-ó ]ñ ñ% ÐZÐ\hÓi÷$ Ø-¨u¯}©}¸e¿l¹lÈEÏOÉOÓ\�AØ—H‘H¨�HÖ-ò ]ð ÷# Ø×8Ñ8¸ÈGÓ]�Ý7Ù# FÓ+×1Ñ1Ó3�Ø ”>ÜÐ=Ó>�CßØ!$  YÔ/BÀ6È4Ó/PÐ.QÐQVÐW˜øä/Ó1�CßÜÐ ;ÀÔK^Ð_eÐgjÓKkÔl˜Ø—l‘l 7Ñ:VÐW_Ô:s�lÓt×tÐtÜ—‘ÐNÐP\ÐgpÔq÷ Ø-¨u¯}©}¸e¿l¹lÈEÏOÉOÓ\�AØ—H‘H¨�HÖ-ñ ]áøôe )ô $Ø Ÿ=™=×/Ñ/×1Ò1Ø#÷Z Ø-¨u¯}©}¸e¿l¹lÈEÏOÉOÓ\�AØ—H‘H¨�HÖ-ó ]ñ ò] 2ð$úñT uøäô 	EÜ�N‰NÐ@À!×DÑDûð	Eû÷ Ø-¨u¯}©}¸e¿l¹lÈEÏOÉOÓ\�AØ—H‘H¨�HÖ-ò ]ð üsÑ   …AUÁ S Á/%Q Â S Â6A	UÃ?A1S Å1S Å8AUÆ?0S Ç0A(S ÉA S Ê:A	UÌS ÌAUÍS ÍB"S Ï<SÏ=S ÐAUÑ*SÒ
S ÒUÒAUÓS ÓSÓS ÓTÓ(TÓ>T ÔTÔT ÔAUÕU)r_   N)g       @g      @g      œ@)r<   r=   r>   r?   r@   ÚdataclassesÚ	dataclassrC   r[   ri   Úclassmethodro   Ústaticmethodr€   rŒ   rœ   r™   r´   r¹   rÄ   rÔ   rç   rí   rd   r°   rB   r   r   r   r    r    +   så   † Ùoà×Ñ÷*ð *ó ð*ð" ×Ñ÷^ð ^ó ð^õ Xð ô
ó ð
ð ôó ðð ô/ó ð/õ"õ2
õ3ð ôSó ðSð ôJó ðJõ	Iõ_õ&;÷E;÷NJñ Jr   r    )r@   Ú
__future__r   rb   r  r•   rÏ   Ú
contextlibr   r   Úpathlibr   Útypingr   r   Ú
agent.i18nr	   Úgateway.configr
   Úgateway.run_shutdownr   Ú	getLoggerrf   r   r  r   r    r   r   r   Ú<module>r#     sa   ðñõ #ã Û Û Û Ý Ý Ý ß  å Ý #Ý 0ð 
×	Ò	˜=Ó	)€õ-ð +1Ð 'õG÷
Kó Kr   