+
    jHàjÅ ã                  óÎ  € R t ^ RIHt ^ RIt^ RIHt ^ RIt^ RI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HtHtHt ^ RIHtHtHtHt ^ R	IHt ^ R
IHtH 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,H-t-H.t.H/t/H0t0 ]'       d   ^ RI1H2t2 ^ RI3H4t4 ]Pj                  ! R4      t6]7! 4       t8^t9RR/R R llt: ! R R4      t;];! 4       t< ! R R4      t=R# )a(  Adapter connect/disconnect, fatal-error recovery, reconnect watcher and multiplex profile
adapters for GatewayRunner (mixin bound via the MRO).

``gateway.run`` internals are imported lazily inside method bodies (import cycle), so
``patch("gateway.run.X")`` keeps intercepting them at call time.
)ÚannotationsN)ÚTYPE_CHECKING)Úsuppress)Úconsume_detached_task_result)ÚContext)ÚdatetimeÚ	timedeltaÚtimezoneÚUTC)ÚON_ALL_ADAPTERS_DOWN_POLICIESÚ SHARED_LISTENER_MIRROR_PLATFORMSÚPlatformÚplatform_binds_port)ÚBasePlatformAdapter)Úcarry_inbound_dedupÚhand_over_held_inbound)Úis_global_startup_conflict)Ú_log_suppressed)ÚSessionSource)Úrecord_platform_connectÚrecord_platform_disconnect)ÚPath)ÚAnyÚ	AwaitableÚCallableÚDictÚOptional©ÚGatewayRunner)Ú
TurnRunnerzgateway.runÚretryingTc               ó$   € V ^8„  d   QhRRRRRR/# )é   Úplatformr   r    ÚboolÚreturnÚstr© )Úformats   "Ú9/home/ubuntu/.hermes/hermes-agent/gateway/run_adapters.pyÚ__annotate__r*   /   s'   € ÷ Mñ M¨8ð MÀ$ð MÐRUñ Mó    c               ó@   € RV P                    R2pV'       d   V R2# T# )z®Actionable ``adapter_unavailable`` status text, shared by startup and the reconnect watcher so
``hermes status`` keeps the plugin/deps/credentials hint after the first retry.z!No adapter available for enabled z2; check the plugin, dependencies, and credentials.z Retrying in the background.©Úvalue)r#   r    Úmessages   &$ r)   Ú_adapter_unavailable_messager0   /   s3   € ð ,¨H¯N©NÐ+;Ð;mÐnð ÷ 8@ˆgˆYÐ2Ð3ÐLÀWÐLr+   c                  ó*   € ] tR t^8tRtRtR R ltRtR# )Ú_UnresolvedProfileHomeu  A NAMED routed profile whose home does not resolve â€” never the same thing as ``None``
("this body is the launch profile's own work"). Overloading ``None`` for both let an inbound
message on a secondary's bot run with the LAUNCH profile's ``.env`` and frozen env.c               ó   € V ^8„  d   QhRR/# ©r"   r%   r&   r'   )r(   s   "r)   r*   Ú#_UnresolvedProfileHome.__annotate__?   s   € ÷ +ñ +˜#ñ +r+   c                	ó   € R # )z<unresolved profile home>r'   ©Úselfs   &r)   Ú__repr__Ú_UnresolvedProfileHome.__repr__?   s   € Ù*r+   r'   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú	__slots__r9   Ú__static_attributes__r'   r+   r)   r2   r2   8   s   † ñ[ð €I÷+ñ +r+   r2   c                  ó¢  € ] tR t^FtRt]R R l4       tR R ltR R ltRR	/R
 R llt	]R R l4       t
R R ltR°RR/R R llltRRRR/R R lltR R ltR R ltR R ltR R ltRR /R! R" lltR# R$ ltR% R& ltR' R( ltR) R* ltR+ R, ltR- R. lt]R/ R0 l4       tR1 R2 lt]R3 R4 l4       tR5R R6^ R7R	R8R	/R9 ltR±R: R; lltR²R< R= lltR> R? ltR8R	/R@ lt RA RB lt!RC RD lt"RER	/RF RG llt#RH RI lt$RJ RK lt%RL RM lt&RN RO lt'RP RQ lt(RR RS lt)RT RU lt*RV RW lt+RX RY lt,RZ R[ lt-R\ R] lt.R^ R_ lt/R` Ra lt0]Rb Rc l4       t1Rd Re lt2RfR	RgR	/Rh Ri llt3Rj Rk lt4Rl Rm lt5Rn Ro lt6RpR	RqR	RrR	RsR	RtR	RuR	RvR	Rw]7/Rx Ry llt8Rz R{ lt9R°R| R} llt:R°R~ R llt;R€ R� lt<R‚ Rƒ lt=R„ R… lt>R† R‡ lt?]Rˆ R‰ l4       t@]RŠ 4       tA]R‹ 4       tBRŒR	R�R	/RŽ R� lltCR� R‘ ltDR’ R“ ltER” tFR• tGR– R— ltHR˜ tIR™ tJRš tKR› Rœ ltLR� Rž ltMRŸ R  ltNR¡ tOR¢ tP]R£ R¤ l4       tQ]R¥ R¦ l4       tR]R§ R¨ l4       tSR© Rª ltTR« R¬ ltUR°R­ R® lltVR¯tWR	# )³ÚGatewayAdapterLifecycleMixinz[Adapter lifecycle: connect/teardown, fatal recovery, reconnect watcher, multiplex profiles.c               ó$   € V ^8„  d   QhRRRRRR/# )r"   Útaskzasyncio.FutureÚtimeoutÚfloatr%   r$   r'   )r(   s   "r)   r*   Ú)GatewayAdapterLifecycleMixin.__annotate__J   s!   € ÷ ñ  Nð ¸Uð Àtñ r+   c              ƒ  ó*  "  € \        4       p \        P                  ! V 0VR7      G Rj  x€L
 w  r#W9  d&   V P                  4        V P	                  \
        4       W9   #  L5  Y9  d'   T P                  4        T P	                  \
        4       i i ; i5i)zþWait up to ``timeout`` for ``task``; on deadline (or our own cancellation) detach it. Not
``asyncio.wait_for``: that WAITS for the cancelled child, so a connect()/close() swallowing
``CancelledError`` blocks recovery forever. True if it finished in time.©rF   N)ÚsetÚasyncioÚwaitÚcancelÚadd_done_callbackr   )rE   rF   ÚdoneÚ_pendings   &&  r)   Ú_wait_or_detachÚ,GatewayAdapterLifecycleMixin._wait_or_detachI   s{   é € ô
 “Eˆð	EÜ#*§<¢<°°ÀÔ#H×H‰NˆDàÔØ—‘”Ø×&Ñ&Ô'CÔDØ‰|Ðñ IøàÔØ—‘”Ø×&Ñ&Ô'CÕDð  üs+   ‚BŽA" ªA «A" ±/BÁ A" Á".BÂBc               ó$   € V ^8„  d   QhRRRRRR/# )r"   Ú	awaitablezAwaitable[Any]rF   rG   r%   r$   r'   )r(   s   "r)   r*   rH   W   s#   € ÷ 	ñ 	À>ð 	Ð\að 	Ðfjñ 	r+   c              ƒ  óÂ   "  € V^ 8:  d   VG Rj  x€L
  R# \         P                  ! V4      pV P                  W24      G Rj  x€L
 '       g   R# VG Rj  x€L
  R#  LI L L
5i)zNAwait adapter cleanup with a detach-on-deadline bound; True when it completed.NTF)rL   Úensure_futurerR   )r8   rU   rF   rE   s   &&& r)   Ú#_await_adapter_cleanup_with_timeoutÚ@GatewayAdapterLifecycleMixin._await_adapter_cleanup_with_timeoutW   sT   é € à�aŒ<Ø�OˆOÙÜ×$Ò$ YÓ/ˆØ×)Ñ)¨$Ó8×8Ö8ÙØ�
ˆ
Ùñ ñ 9áùs9   ‚A�A�0AÁ AÁ	AÁAÁAÁAÁAÁAc               ó   € V ^8„  d   QhRR/# ©r"   r%   ÚNoner'   )r(   s   "r)   r*   rH   b   s   € ÷ 
ñ 
À4ñ 
r+   c              ƒ  ó^  "  € V P                  4       pVe   VP                  MRp\        \        P                  RV4      ;_uu_ 4        V P                  VP                  4       V4      G Rj  x€L
 '       g   \        P                  RW44       RRR4       R#  L*  + '       g   i     R# ; i5i)z·Call adapter.disconnect() defensively (bounded, never raises, tolerates partial-init state):
after a failed connect() partial resources (ClientSession, poll tasks, subprocesses) leak.NÚadapterz7Defensive %s disconnect after failed connect raised: %szITimed out after %.1fs while disconnecting %s adapter; continuing shutdown)	Ú _adapter_disconnect_timeout_secsr.   r   ÚloggingÚDEBUGrX   Ú
disconnectÚloggerÚwarning)r8   r^   r#   rF   Úlabels   &&&  r)   Ú_safe_adapter_disconnectÚ5GatewayAdapterLifecycleMixin._safe_adapter_disconnectb   s„   é € ð ×7Ñ7Ó9ˆØ"*Ò"6�—’¸IˆÜœWŸ]™]Ð,eÐgl×mÕmØ×AÑAÀ'×BTÑBTÓBVÐX_Ó`×`Ö`Ü—‘Ø_Øô÷ nÑmÙ`÷ n×mÐmüs6   ‚AB-Á$BÁ,BÁ-	BÁ7BÂ
B-ÂBÂB*	Â$	B-ÚprofileNc               ó    € V ^8„  d   QhRRRR/# )r"   rh   úOptional[str]r%   r\   r'   )r(   s   "r)   r*   rH   n   s   € ÷ ñ È]ð Ðfjñ r+   c             ƒ  óz  "  € V P                  4       pV'       d   RV R2MRp\        P                  ! 4       p V P                  VP	                  4       V4      G Rj  x€L
 '       g"   \
        P                  RVP                  WE4       \        \        P                  RTP                  \        P                  ! 4       T,
          T4      ;_uu_ 4        T P                  TP                  4       T4      G Rj  x€L
 '       d>   \
        P                  RTP                  \        P                  ! 4       T,
          T4       M!\
        P                  R	TP                  YE4       RRR4       R#  EL  \         d-   p\
        P                  RTP                  YW4        Rp?ELRp?ii ; i L¯  + '       g   i     R# ; i5i)
aÁ  Tear down one adapter on the shutdown path with bounded awaits (never raises). Unbounded,
a half-dead transport stalls past systemd's ``TimeoutStopSec``; the SIGKILL skips ``atexit``
PID-file cleanup and the next start dies with "PID file race lost".

Both ``cancel_background_tasks()`` and ``disconnect()`` can block indefinitely when a platform's
network state is half-dead (e.g. a wedged Feishu/Lark WebSocket thread waiting on I/O). See #14128.
z (profile: Ú)Ú NuH   âœ— %s background-task cancel timed out after %.1fs - forcing continue%su)   âœ— %s background-task cancel error%s: %su)   âœ— %s disconnect error after %.2fs%s: %su   âœ“ %s disconnected (%.2fs)%su<   âœ— %s disconnect timed out after %.1fs - forcing continue%s)r_   ÚtimeÚ	monotonicrX   Úcancel_background_tasksrc   rd   r.   Ú	ExceptionÚdebugr   r`   ÚERRORrb   Úinfo)r8   r^   r#   rh   rF   ÚsuffixÚ
started_atÚes   &&&$    r)   Ú_bounded_adapter_teardownÚ6GatewayAdapterLifecycleMixin._bounded_adapter_teardownn   sV  é € ð ×7Ñ7Ó9ˆß-4�;˜w˜i qÑ)¸"ˆÜ—^’^Ó%ˆ
ð	aØ×AÑAÀ'×BaÑBaÓBcÐelÓm×mÖmÜ—‘Ø^Ø—N‘N Gôô Ü�M‰MÐFØ�N‰NœDŸNšNÓ,¨zÕ9¸6÷
õ 
ð ×=Ñ=¸g×>PÑ>PÓ>RÐT[Ó\×\Ö\Ü—‘Ø3°X·^±^ÄTÇ^Â^ÓEUÐXbÕEbÐdjõô —‘ØRØ—N‘N Gô÷
ñ 
ò nøô
 ô 	aÜ�L‰LÐDÀhÇnÁnÐV\×`Ò`ûð	aúñ ]÷	
÷ 
ð 
üsx   ‚6F;¹#E+ ÁE(Á	E+ Á'!E+ ÂA	F;Ã$F'Ã5F%Ã6	F'Ä AF'Å
F;Å(E+ Å+F"Å6!FÆF;ÆF"Æ"F;Æ%F'Æ'F8	Æ2	F;c               ó    € V ^8„  d   QhRRRR/# )r"   Únamer&   r%   zOptional[float]r'   )r(   s   "r)   r*   rH   �   s   € ÷ 	ñ 	 Cð 	¨Oñ 	r+   c                óÜ   € \         P                  ! V R4      P                  4       pV'       g   R#  \        R\	        V4      4      #   \
         d    \        P                  RY4        R# i ; i)zRNon-negative float from env var ``name``; None when unset or unparseable (warned).rm   Nç        zIgnoring invalid %s=%r)ÚosÚgetenvÚstripÚmaxrG   Ú
ValueErrorrc   rd   )r{   Úraws   & r)   Ú_env_timeout_overrideÚ2GatewayAdapterLifecycleMixin._env_timeout_override�   sZ   € ô �iŠi˜˜bÓ!×'Ñ'Ó)ˆßÙð	Ü�sœE #›JÓ'Ð'øÜô 	Ü�N‰NÐ3°TÔ?Úð	ús   ±A Á!A+Á*A+c               ó   € V ^8„  d   QhRR/# )r"   r%   rG   r'   )r(   s   "r)   r*   rH   ›   s   € ÷ Zñ Z°%ñ Zr+   c                ó@   € ^ RI Hp V P                  R4      pVf   V# T# )z?Return the per-adapter disconnect timeout used during shutdown.)Ú(_ADAPTER_DISCONNECT_TIMEOUT_SECS_DEFAULTÚ)HERMES_GATEWAY_ADAPTER_DISCONNECT_TIMEOUT)Úgateway.runrˆ   r„   )r8   rˆ   Úoverrides   &  r)   r_   Ú=GatewayAdapterLifecycleMixin._adapter_disconnect_timeout_secs›   s(   € åHØ×-Ñ-Ð.YÓZˆØ;CÒ;KÐ7ÐYÐQYÐYr+   ÚinitialFc               ó    € V ^8„  d   QhRRRR/# )r"   r�   r$   r%   rG   r'   )r(   s   "r)   r*   rH   ¡   s   € ÷ uñ uÈð uÐY^ñ ur+   c               óŠ   € ^ RI HpHpHp V P	                  R4      pVe   V# V\
        P                  8w  d   V# V'       d   V# T# )uÊ  Per-platform connect timeout. Telegram's full 180s is NOT spent at cold start (it would
hold the gateway out of ``running``); the watcher retries with the full budget.

``initial=True`` marks the cold-start connect awaited before the gateway reaches ``running``. The
cold-start wait is capped and the platform is handed to the reconnect watcher, which retries with
the full budget (and ``is_reconnect=True``, preserving the offline update queue â€” #46621).
)Ú&_PLATFORM_CONNECT_TIMEOUT_SECS_DEFAULTÚ&_TELEGRAM_CONNECT_TIMEOUT_SECS_DEFAULTÚ._TELEGRAM_INITIAL_CONNECT_TIMEOUT_SECS_DEFAULTÚ'HERMES_GATEWAY_PLATFORM_CONNECT_TIMEOUT)rŠ   r�   r‘   r’   r„   r   ÚTELEGRAM)r8   r#   r�   r�   r‘   r’   r‹   s   &&$    r)   Ú_platform_connect_timeout_secsÚ;GatewayAdapterLifecycleMixin._platform_connect_timeout_secs¡   sM   € ÷	
ñ 	
ð ×-Ñ-Ð.WÓXˆØÒØˆOØ”x×(Ñ(Ô(Ø9Ð9ßAHÐ=ÐtÐNtÐtr+   Úis_reconnectc               ó$   € V ^8„  d   QhRRRRRR/# ©r"   r—   r$   r�   r%   r'   )r(   s   "r)   r*   rH   ´   s$   € ÷ ñ Ø26ðØIMðà	ñr+   c          	   ƒ  ó¾   "  €  V P                  WW4R7      G Rj  x€L
 p\        YT\        T4      R7       T#  L  \         d   p\        YTRTR7       h Rp?ii ; i5i)u�  Connect with a bound so one platform can't block others. ``is_reconnect``: cold boot
drops the stale server-side queue, a reconnect keeps it. ``initial``: capped budget.

``is_reconnect`` is forwarded to ``adapter.connect()`` so platform adapters can distinguish a cold
first boot (drop any stale server-side queue) from a watcher reconnect after a prolonged outage
(preserve the queue so messages sent during the outage are delivered rather than silently dropped â€”
#46621).
``initial`` selects the capped cold-start budget for platforms whose full connect budget is too long
to spend before the gateway reaches ``running`` (#85993 â€” Telegram's 180s).
)r—   r�   NF)r—   ÚokÚexc)r—   r›   )Ú_connect_adapter_boundedrq   r   r$   )r8   r^   r#   r—   r�   r›   rœ   s   &&&$$  r)   Ú_connect_adapter_with_timeoutÚ:GatewayAdapterLifecycleMixin._connect_adapter_with_timeout´   se   é € ð	Ø×4Ñ4°WÐUaÐ4Ós×sˆBô 	  ÀÔQUÐVXÓQYÕZØˆ	ñ tøÜô 	Ü# GÀLÐUZÐ`cÕdØûð	üs1   ‚A„: š8›: ŸA¸: ºAÁAÁAÁAc               ó$   € V ^8„  d   QhRRRRRR/# r™   r'   )r(   s   "r)   r*   rH   É   s)   € ÷ Uñ UÐQUð UÐ`dð UÐimñ Ur+   c             ƒ  	ód  "  € V P                  W$R 7      pV^ 8:  d   VP                  VR7      G Rj  x€L
 # \        P                  ! VP                  VR7      4      pV P	                  We4      G Rj  x€L
 '       d   \        VG Rj  x€L
 4      # \        VP                   RVR R24      h Lx L; L(5i)©r�   ©r—   Nz connect timed out after ÚgÚs)r•   ÚconnectrL   rW   rR   r$   ÚTimeoutErrorr.   )r8   r^   r#   r—   r�   rF   rE   s   &&&$$  r)   r�   Ú5GatewayAdapterLifecycleMixin._connect_adapter_boundedÉ   sœ   é € Ø×5Ñ5°hÐ5ÓPˆØ�aŒ<Ø Ÿ™°l˜ÓC×CÐCÜ×$Ò$ W§_¡_À, _Ó%OÓPˆØ×%Ñ% dÓ4×4Ö4Ü˜dŸ
Ó#Ð#Ü˜hŸn™nÐ-Ð-FÀwÈqÀkÐQRÐSÓTÐTñ	 Dá4Ù"ùs9   ‚/B0±B*²>B0Á0B,Á1	B0Á;
B0ÂB.Â%B0Â,B0Â.B0c               ó   € V ^8„  d   QhRR/# ©r"   r%   r$   r'   )r(   s   "r)   r*   rH   Ò   s   € ÷ <ñ <ÐPTñ <r+   c              ƒ  ó    "  € \        V P                  4      Vn         V P                  WRR7      G Rj  x€L
 RVn        #  L  RTn        i ; i5i)zŠCold-start connect with replace intent visible ONLY during this await, so a later
network recovery can never evict a healthy token holder.Tr¢   NF)r$   Ú _platform_lock_takeover_on_startÚ_platform_lock_takeover_allowedrž   )r8   r^   r#   s   &&&r)   Ú%_connect_initial_adapter_with_timeoutÚBGatewayAdapterLifecycleMixin._connect_initial_adapter_with_timeoutÒ   sM   é € ô 37°t×7\Ñ7\Ó2]ˆÔ/ð	<Ø×;Ñ;¸GÐW[Ð;Ó\×\à6;ˆGÕ3ñ ]øà6;ˆGÕ3üs+   ‚AžA ´A µA ¸AÁ A Á	AÁAc               ó    € V ^8„  d   QhRRRR/# )r"   Úctxzdict[str, Any]r%   r\   r'   )r(   s   "r)   r*   rH   Û   s   € ÷ 3ñ 3°ð 3À4ñ 3r+   c              ƒ  ó"  "  € \        VP                  R4      ;'       g    R4      p\        \        P                  RRR7      ;_uu_ 4        V P
                  P                  W!4      G Rj  x€L
  RRR4       R#  L  + '       g   i     R# ; i5i)zXFan a normalised reaction event out to the HookRegistry; errors never block the adapter.Ú
event_namezreaction:addedz#[Gateway] reaction hook emit failedT©Úexc_infoN)r&   Úgetr   r`   ra   ÚhooksÚemit)r8   r±   r³   s   && r)   Ú_handle_reaction_eventÚ3GatewayAdapterLifecycleMixin._handle_reaction_eventÛ   sd   é € ä˜Ÿ™ Ó.×BÐBÐ2BÓCˆ
ÜœWŸ]™]Ð,QÐ\`×aÖaØ—*‘*—/‘/ *Ó2×2Ð2÷ bÑaÙ2÷ b×aÐaüs0   ‚A	BÁA;Á*A9Á+A;Á/
BÁ9A;Á;B	Â	Bc               ó    € V ^8„  d   QhRRRR/# ©r"   r^   r   r%   r\   r'   )r(   s   "r)   r*   rH   á   s   € ÷ 
ñ 
Ð9Lð 
ÐQUñ 
r+   c           
   ƒ  óö   "  € \        V RR4      pVf   \        4       ;q n        \        P                  ! V P                  V\        P                  ! V P                  V4      4      4      4      G Rj  x€L
  R#  L5i)u  React to an adapter failure after startup (retryable â†’ background reconnect queue). Runs
detached: the notification arrives on the failing adapter's own polling task, which the
handler's disconnect can cancel mid-flight, stranding the platform half-handled.Ú_fatal_handler_tasksN)ÚgetattrrK   r¾   rL   ÚshieldÚ_track_task_inÚcreate_taskÚ$_handle_adapter_fatal_error_detached)r8   r^   Útaskss   && r)   Ú_handle_adapter_fatal_errorÚ8GatewayAdapterLifecycleMixin._handle_adapter_fatal_errorá   sg   é € ô ˜Ð4°dÓ;ˆØŠ=Ü03³Ð5ˆEÔ-ô �nŠnØ×Ñ ¤w×':Ò':¸4×;dÑ;dÐelÓ;mÓ'nÓoó
÷ 	
ô 	
ùs   ‚A.A9Á0A7Á1A9ÚqueuedTc               ó(   € V ^8„  d   QhRRRRRRRR/# )	r"   ÚattemptsÚintÚdelayrG   rÇ   r$   r%   Údictr'   )r(   s   "r)   r*   rH   î   s,   € ÷ 
ñ 
Ø?Bð
ØKPð
ØZ^ð
à	ñ
r+   c               ó°   € \         P                  ! 4       pRVRVRWu,           /V'       d   RV/M/ CRV P                  W4      RV P                  W4      RV/C# )zZBuild a ``_failed_platforms`` entry (startup failures and runtime fatals share the shape).ÚconfigrÉ   Ú
next_retryÚ	queued_atÚcredential_claimÚlistener_claimÚpredecessor)rn   ro   Ú_adapter_credential_claimÚ_adapter_listener_claim)r8   r#   r^   Úplatform_configrÉ   rË   rÇ   Únows   &&&&$$$ r)   Ú_reconnect_queue_entryÚ3GatewayAdapterLifecycleMixin._reconnect_queue_entryî   sf   € ô �nŠnÓˆà�o z°8¸\È3Í;ð
ç%+�˜SÑ!°ð
ð  × >Ñ >¸xÓ QØ˜d×:Ñ:¸8ÓMà˜7ñ
ð 	
r+   c               ó    € V ^8„  d   QhRRRR/# )r"   r^   r   r%   r$   r'   )r(   s   "r)   r*   rH   ü   s   € ÷ "ñ "Ð7Jð "Ètñ "r+   c                óÚ  € VP                   '       g   R# V P                  P                  P                  VP                  4      pV'       g   R# VP                  V P
                  9   d   V P                  4        R# V P                  VP                  W^ RR7      V P
                  VP                  &   \        P                  RVP                  P                  4       V P                  4        R# )zÜQueue a retryable fatal adapter for background reconnection (True when newly queued).

Must not await: callers run this BEFORE any disconnect so a wedged close can't strand it.

Idempotent if already queued. See #80598.
Fr}   )rÉ   rË   z%%s queued for background reconnectionT)Úfatal_error_retryablerÎ   Ú	platformsr¶   r#   Ú_failed_platformsÚ!_ensure_reconnect_watcher_runningrØ   rc   rt   r.   )r8   r^   rÖ   s   && r)   Ú_queue_retryable_fatal_platformÚ<GatewayAdapterLifecycleMixin._queue_retryable_fatal_platformü   sÂ   € ð ×,×,Ð,ÙØŸ+™+×/Ñ/×3Ñ3°G×4DÑ4DÓEˆßÙØ×Ñ˜t×5Ñ5Ô5ð ×2Ñ2Ô4ÙØ37×3NÑ3NØ×Ñ˜gÀÈ#ð 4Oó 4
ˆ×Ñ˜w×/Ñ/Ñ0ô 	�‰Ð;¸W×=MÑ=M×=SÑ=SÔTð 	×.Ñ.Ô0Ùr+   c               ó   € V ^8„  d   QhRR/# r4   r'   )r(   s   "r)   r*   rH      s   € ÷ Kñ K sñ Kr+   c                óP   € \        \        V RR4      RR4      pV\        9   d   V# R# )uN  Normalized ``GatewayConfig.on_all_adapters_down``: ``"exit"`` (default â€” a supervising
service manager restarts the process) or ``"stay_alive"`` (launchers with no supervisor,
e.g. the desktop app's direct ``hermes serve`` child, where a failure exit only severs the
UI's websockets and drops in-flight assistant messages; #118080).rÎ   NÚon_all_adapters_downÚexit)r¿   r   )r8   r.   s   & r)   Ú_on_all_adapters_downÚ2GatewayAdapterLifecycleMixin._on_all_adapters_down   s/   € ô
 œ  h°Ó5Ð7MÈtÓTˆØÔ!>Ô>ˆuÐJÀFÐJr+   c               ó    € V ^8„  d   QhRRRR/# r¼   r'   )r(   s   "r)   r*   rH   (  s   € ÷ <&ñ <&ÐBUð <&ÐZ^ñ <&r+   c              ƒ  ó¢  "  €  V P                  4       pV^ 8:  d   V P                  V4      G Rj  x€L
  MˆV\        R\        RV4      4      ,           pV P	                  V P                  V4      V4      G Rj  x€L
 '       g=   \
        P                  RVP                  P                  V4       V P                  V4       VP                  p\        V RR4      pVP                   '       dß   W@P"                  9  dÍ   V\        V R	/ 4      9  d¹   Ve   VP%                  4       '       g�   V P'                  4       R
8X  d3   \
        P)                  RVP                  4       V P+                  4        R# \
        P                  RVP                  4       VP                   R2V n        RV n        V P1                  4       G Rj  x€L
  R# R# R# R# R#  EL™ ELU  \        P                   d    T P                  TR4       h \         dA    \
        P                  RTP                  P                  4       T P                  TR4        EL‚i ; i L‰  TP                  p\        T RR4      pTP                   '       dÛ   Y@P"                  9  dÊ   T\        T R	/ 4      9  d·   Te   TP%                  4       '       gœ   T P'                  4       R
8X  d2   \
        P)                  RTP                  4       T P+                  4        i \
        P                  RTP                  4       TP                   R2T n        RT n        T P1                  4       G Rj  x€L 
  i i i i i ; i5i)z¬Run the fatal handler; a platform left stranded (not reconnected, not queued, not
intentionally disabled) exits the gateway with failure so the service manager restarts it.Nç       @gš™™™™™©?zXFatal-error handling for %s timed out after %.1fs; ensuring reconnect queue is populatedÚcancellationz/Fatal-error handling for %s raised unexpectedlyÚ	exceptionÚ_shutdown_eventrÞ   Ú
stay_aliveu˜   %s adapter was lost without entering the reconnection queue; on_all_adapters_down=stay_alive â€” gateway staying alive, reconnect watcher owns recovery.zp%s adapter was lost without entering the reconnection queue; exiting gateway so the service manager restarts it.z( adapter lost without reconnection queueT)r_   Ú _handle_adapter_fatal_error_implÚminr�   rX   rc   Úerrorr#   r.   rà   rL   ÚCancelledErrorÚ_queue_retryable_best_effortrq   rì   r¿   rÜ   ÚadaptersÚis_setræ   rd   rß   Ú_exit_reasonÚ_exit_with_failureÚstop)r8   r^   rF   Úouterr#   Úshutdown_events   &&    r)   rÃ   ÚAGatewayAdapterLifecycleMixin._handle_adapter_fatal_error_detached(  s   é € ð9	&à×;Ñ;Ó=ˆGØ˜!Œ|ð ×;Ñ;¸GÓD×DÑDð  ¤# c¬3¨t°WÓ+=Ó">Õ>�Ø!×EÑEØ×9Ñ9¸'ÓBÀEó÷ ö ô —L‘Lð@ØAH×AQÑAQ×AWÑAWÐY^ôð ×8Ñ8¸ÔAð ×'Ñ'ˆHÜ$ TÐ+<¸dÓCˆNà×-×-Ð-Ø§M¡MÔ1Ø¤G¨DÐ2EÀrÓ$JÔJØ'Ò3¸×8MÑ8M×8OÒ8Oà×-Ñ-Ó/°<Ô?ô
 —N‘Nð1à2:·.±.ôð
 ×:Ñ:Ö<ä—L‘LðUØV^×VdÑVdôð ,4¯>©>Ð*:Ð:bÐ(c�DÔ%Ø.2�DÔ+ØŸ)™)›+×%Ò%ñ) 9Pñ Kñ 2ñ .ò7 Eòøô ×%Ñ%ô 	à×-Ñ-¨g°~ÔFØÜô 	DÜ×ÑÐNÐPW×P`ÑP`×PfÑPfÔgØ×-Ñ-¨g°{×Cð	Dúñ< &øð5 ×'Ñ'ˆHÜ$ TÐ+<¸dÓCˆNà×-×-Ð-Ø§M¡MÔ1Ø¤G¨DÐ2EÀrÓ$JÔJØ'Ò3¸×8MÑ8M×8OÒ8Oà×-Ñ-Ó/°<Ô?ô
 —N‘Nð1à2:·.±.ôð
 ×:Ñ:Õ<ä—L‘LðUØV^×VdÑVdôð ,4¯>©>Ð*:Ð:bÐ(c�DÔ%Ø.2�DÔ+ØŸ)™)›+×%Ò%ð) 9Pð Kð 2ð .üs›   ‚M„+G ¯G°G ´I µAG Á6GÁ7	G Â<G Â=A&MÄ$BMÆ9IÆ:MÇG ÇG Ç0I Ç?=I È<I È?I É I ÉMÉA'MÊ-BMÍMÍ
MÍMc               ó$   € V ^8„  d   QhRRRRRR/# )r"   r^   r   Úwhyr&   r%   r\   r'   )r(   s   "r)   r*   rH   f  s#   € ÷ :ñ :Ð4Gð :Ècð :ÐVZñ :r+   c                	óÖ   € \        \        P                  R VP                  P                  VRR7      ;_uu_ 4        V P                  V4       RRR4       R#   + '       g   i     R# ; i)z)Failed to queue %s after fatal-handler %sTr´   N)r   r`   ra   r#   r.   rà   )r8   r^   rý   s   &&&r)   ró   Ú9GatewayAdapterLifecycleMixin._queue_retryable_best_effortf  sQ   € ÜÜ�M‰MÐFØ×Ñ×"Ñ" C°$÷
ö 
ð ×0Ñ0°Ô9÷	
÷ 
÷ 
ò 
ús   »AÁA(	c               ó    € V ^8„  d   QhRRRR/# r¼   r'   )r(   s   "r)   r*   rH   m  s   € ÷ ?ñ ?Ð>Qð ?ÐVZñ ?r+   c              ƒ  	ó  "  € V P                   P                  VP                  4      pVeG   W!JdB   \        P	                  RVP                  P
                  VP                  ;'       g    R4       R # \        P                  RVP                  P
                  VP                  ;'       g    RVP                  ;'       g    R4       T P                  VP                  P
                  VP                  R8X  d   RMVP                  '       d   RMRVP                  VP                  R	7       W!J dM   \        V4       V P                   P                  VP                  R 4       V P                   V P                  n         V P                  V4       W!J d$   V P                  WP                  4      G R j  x€L
  V P                   '       gï   V P                   '       gÝ   VP                  '       dR   V P#                  4       R
8X  d=   \        P%                  RVP                  P
                  4       V P'                  4        R # VP                  ;'       g    RV n        VP                  '       d   RV n        \        P                  R4       M\        P                  R4       V P-                  4       G R j  x€L
  R # V P                   '       g@   V P                   '       d,   \        P%                  R\/        V P                   4      4       R # R # R #  ELX L\5i)NzDIgnoring stale fatal error from a superseded %s adapter instance: %sÚunknownzFatal %s adapter error (%s): %szunknown errorÚrelay_disabledÚdisabledr    Úfatal©Úplatform_stateÚ
error_codeÚerror_messagerî   uŠ   No connected messaging platforms remain; on_all_adapters_down=stay_alive â€” gateway staying alive, reconnect watcher owns recovery of %s.z#All messaging adapters disconnectedTzSNo connected messaging platforms remain. Shutting down gateway for service restart.zGNo connected messaging platforms remain. Shutting down gateway cleanly.u�   No connected messaging platforms remain, but %d platform(s) queued for reconnection â€” gateway staying alive, watcher will retry in background.)rô   r¶   r#   rc   rr   r.   Úfatal_error_coderñ   Úfatal_error_messageÚ_update_platform_runtime_statusrÜ   r   ÚpopÚdelivery_routerrà   rf   rÞ   ræ   rd   rß   rö   r÷   rø   Úlen)r8   r^   Úexistings   && r)   rï   Ú=GatewayAdapterLifecycleMixin._handle_adapter_fatal_error_implm  s]  é € à—=‘=×$Ñ$ W×%5Ñ%5Ó6ˆØÒ HÓ$;Ü�L‰LØVØ× Ñ ×&Ñ&¨×(@Ñ(@×(MÐ(MÀIôñ Ü�‰Ø-¨w×/?Ñ/?×/EÑ/EØ×$Ñ$×1Ð1¨	°7×3NÑ3N×3aÐ3aÐRaô	
ð
 	×,Ñ,Ø×Ñ×"Ñ"à%×6Ñ6Ð:JÔJ‘
Ø#*×#@×#@Ð#@‘ZÀgà×/Ñ/Ø!×5Ñ5ð 	-ô 	
ð ÓÜ& wÔ/à�M‰M×Ñ˜g×.Ñ.°Ô5Ø,0¯M©MˆD× Ñ Ô)à×,Ñ,¨WÔ5ØÓð ×/Ñ/°×9IÑ9IÓJ×JÐJØ�}�}ˆ} T×%;×%;Ð%;Ø×,×,Ð,°×1KÑ1KÓ1MÐQ]Ô1]ô —‘ðTà×$Ñ$×*Ñ*ôð
 ×6Ñ6Ô8ÙØ '× ;Ñ ;× dÐ dÐ?dˆDÔØ×,×,Ð,Ø*.�Ô'Ü—‘ÐrÕsä—‘ÐfÔgØ—)‘)“+×ÒØ——� 4×#9×#9Ð#9ä�N‰Nð'ä(+¨D×,BÑ,BÓ(Cöñ $:‘ò) Kñ& ùsk   ‚A&LÁ)A LÂ*LÂ?ALÄB$LÆ/LÆ0LÇLÇLÇ*A#LÉLÉ(ALÊ-L
Ê.LËLË0LÌ
Lc               ó    € V ^8„  d   QhRRRR/# )r"   rE   úasyncio.Taskr%   r'   )r(   s   "r)   r*   rH   ®  s   € ÷ ñ ¨Lð ¸\ñ r+   c                óÄ   € \        V RR4      p\        V\        4      '       g   \        4       ;q n        VP	                  V4       VP                  VP                  4       V# )zRRegister ``task`` in ``_background_tasks`` (created lazily for bare test runners).Ú_background_tasksN)r¿   Ú
isinstancerK   r  ÚaddrO   Údiscard)r8   rE   rÄ   s   && r)   Ú_retain_background_taskÚ4GatewayAdapterLifecycleMixin._retain_background_task®  sM   € ä˜Ð1°4Ó8ˆÜ˜%¤×%Ò%Ü-0«UÐ2ˆEÔ*Ø�	‰	�$ŒØ×Ñ˜uŸ}™}Ô-Øˆr+   c               ó$   € V ^8„  d   QhRRRRRR/# )r"   rÄ   rK   rE   r  r%   r'   )r(   s   "r)   r*   rH   ¸  s!   € ÷ ñ ˜cð ¨ð ¸,ñ r+   c                ó^   € V P                  V4       VP                  V P                  4       V# )zPRegister ``task`` in an arbitrary lifecycle set with self-removal on completion.)r  rO   r  )rÄ   rE   s   &&r)   rÁ   Ú+GatewayAdapterLifecycleMixin._track_task_in·  s&   € ð 	�	‰	�$ŒØ×Ñ˜uŸ}™}Ô-Øˆr+   c               ó    € V ^8„  d   QhRRRR/# ©r"   Úreasonr&   r%   r\   r'   )r(   s   "r)   r*   rH   ¾  s   € ÷ #ñ #¨#ð #°$ñ #r+   c                	óT   € R V n         Wn        V P                  P                  4        R# )TN)Ú_exit_cleanlyrö   rí   rK   )r8   r   s   &&r)   Ú_request_clean_exitÚ0GatewayAdapterLifecycleMixin._request_clean_exit¾  s"   € Ø!ˆÔØ"ÔØ×Ñ× Ñ Ö"r+   c               ó    € V ^8„  d   QhRRRR/# )r"   ÚattemptrÊ   r%   rG   r'   )r(   s   "r)   r*   rH   Ä  s   € ÷ -ñ - Sð -¨Uñ -r+   c                ó<   € \        ^<^\        V ^4      ,          4      # )zOCapped exponential respawn delay (a method so tests can collapse the schedule).)rð   ©r&  s   &r)   Ú_supervised_backoffÚ0GatewayAdapterLifecycleMixin._supervised_backoffÃ  s   € ô �2�qœC ¨›OÕ+Ó,Ð,r+   ÚrestartÚ_attemptÚon_spawnÚ
on_give_upc               óR  a aaaaaaa	€ \         P                  ! 4       o	\        4       P                  V3R l4      pRVn        S P                  V4       Se
    S! V4       VV	VVVVVV 3R lpVP                  V4       V#   \         d    \        P                  RSRR7        LEi ; i)u¿  Launch a long-lived supervised background task: exceptions a bare ``create_task`` drops
are logged, and it respawns with capped backoff up to ``_MAX_SUPERVISED_RESTARTS`` rapid
failures (counter resets after ``_SUPERVISED_HEALTHY_SECS`` healthy). Fresh ``Context`` per
spawn (an inherited delegated-child marker would make the Kanban dispatcher reject its own
writes). ``on_spawn`` fires on EVERY spawn incl. respawns â€” handle trackers MUST pass it or a
respawn leaves a stale handle and a SECOND watcher; ``on_give_up(name)`` fires at budget end.

``on_give_up`` (optional) is invoked with ``name`` when supervision is abandoned â€” the restart
budget is spent and this task will never be respawned by the supervisor again. Supervision being
finite is correct; having no owner of the invariant afterwards is not. A task that still has queued
work depending on it needs somewhere to hand that fact to, and before this hook existed the only
thing standing between budget exhaustion and a permanent silent outage was a *later, unrelated
event* happening to call ``_ensure_...`` (#90386). This is the supervisor telling its caller "I am
done; the invariant is yours now", which is a thing only the supervisor knows.
c                 ó:   <€ \         P                  ! S ! 4       4      # ©N©rL   rÂ   )Úcoro_factorys   €r)   Ú<lambda>Ú@GatewayAdapterLifecycleMixin._spawn_supervised.<locals>.<lambda>Ý  s   ø€ ¤W×%8Ò%8¹»Ô%Hr+   Tzon_spawn callback for %s raisedr´   c                óâ  <aaa€ SP                   P                  V 4       V P                  4       '       d   R # V P                  4       pVf   R # \        P                  RS	WR7       S'       d   SP                  '       g   R # \        P                  ! 4       S,
          SP                  8¬  pV'       d   ^ MSoSSP                  8¼  d4   \        P                  RS	SSP                  4       S
e    S
! S	4       R # R # SP                  S4      oVVVV	V
VVV3R loSP                  \        4       P!                  V3R l4      4       R #   \         d    \        P                  RS	RR7        R # i ; i)NzSupervised task %s died: %rr´   uh   Supervised task %s died %d times in rapid succession (each within %ds of restart) â€” giving up restartsz!on_give_up callback for %s raisedTc            	   “  ó´   <"  € \         P                  ! S 4      G R j  x€L
  SP                  '       d!   SP                  SSSS^,           SSR7       R # R #  L85i)N)r+  r,  r-  r.  )rL   ÚsleepÚ_runningÚ_spawn_supervised)Úbackoffr3  Úeffective_attemptr{   r.  r-  r+  r8   s   €€€€€€€€r)   Ú_respawnÚOGatewayAdapterLifecycleMixin._spawn_supervised.<locals>._done.<locals>._respawn  sS   øé € Ü—m’m GÓ,×,Ð,Ø—=—=�=Ø×*Ñ*Ø$ d°GÐFWÐZ[ÕF[Ø!)°jð +ö ñ !ñ -ùs   ƒA�AžA´#Ac                 ó:   <€ \         P                  ! S ! 4       4      # r1  r2  )r=  s   €r)   r4  ÚOGatewayAdapterLifecycleMixin._spawn_supervised.<locals>._done.<locals>.<lambda>  s   ø€ ¼w×?RÒ?RÑS[ÓS]Ô?^r+   )r  r  Ú	cancelledrì   rc   rñ   r9  rn   ro   Ú_SUPERVISED_HEALTHY_SECSÚ_MAX_SUPERVISED_RESTARTSrq   rr   r)  r  r   Úrun)Útrœ   Úhealthyr=  r;  r<  r,  Ú_startedr3  r{   r.  r-  r+  r8   s   &  @@@€€€€€€€€r)   Ú_doneÚ=GatewayAdapterLifecycleMixin._spawn_supervised.<locals>._doneè  s)  û€ Ø×"Ñ"×*Ñ*¨1Ô-Ø�{‰{�}Š}ÙØ—+‘+“-ˆCØŠ{áÜ�L‰LÐ6¸¸cˆLÔPß §§ Ùä—n’nÓ&¨Õ1°T×5RÑ5RÑRˆGß%,¡°(ÐØ  D×$AÑ$AÔAÜ—‘ðJØKOØ% t×'DÑ'Dôð
 Ò)ð_Ù" 4Ô(ó Ø×.Ñ.Ð/@ÓAˆG÷ô ð ×(Ñ(¬«¯©Ô7^Ó)_Ö`øô %ô _ÜŸ™Ð%HÈ$ÐY]˜Õ^Ùð_ús   Ã/E Å#E.Å-E.)
rn   ro   r   rD  Ú_hermes_supervised_watcherr  rq   rc   rr   rO   )
r8   r3  r{   r+  r,  r-  r.  rE   rH  rG  s
   fffdddd  @r)   r:  Ú.GatewayAdapterLifecycleMixin._spawn_supervisedÈ  s”   ÿ€ ô& —>’>Ó#ˆä‹y�}‰}ÔHÓIˆà*.ˆÔ'Ø×$Ñ$ TÔ*ØÒðUÙ˜”÷%	aô %	aðN 	×Ñ˜uÔ%ØˆøôW ô UÜ—‘Ð>ÀÈt�ÖTðUús   ÁB  Â #B&Â%B&c               ó$   € V ^8„  d   QhRRRRRR/# )r"   ÚintervalrG   Údrain_timeoutr%   r\   r'   )r(   s   "r)   r*   rH     s'   € ÷ _&ñ _&¨uð _&È5ð _&Ð\`ñ _&r+   c              ƒ  óz  a aaaaa"  € ^ RI HoHpHp ^ RIHpHo \        P                  ! ^4      G Rj  x€L
   ^ RI	p\        VP                  S P                  4      P                  4      ^8¬  o/ oR VVV 3R lloRR VVV 3R lllpV3R	 lpV! S 4      G Rj  x€L
  Fk  w  rš\        \         P"                  R
RR7      ;_uu_ 4        V! V
4      ;_uu_4       GRj  x€L
  V! S 4      G Rj  x€L
  RRR4      GRj  x€L
  RRR4       Km  	   S P$                  '       d˜    V! S 4      G Rj  x€L
  Fb  w  r¼Ve!   V! S V3V3R ll4      G Rj  x€L
 '       g   K)  V! V4      ;_uu_4       GRj  x€L
  V! V4      G Rj  x€L
  RRR4      GRj  x€L
  Kd  	  \        P                  ! T4      G Rj  x€L
  K©   SP-                  4        Uu. uF  qîP/                  4       '       d   K  VNK  	  ppV'       d€   \        \         P"                  RRR7      ;_uu_ 4        \        P0                  ! WòR7      G Rj  x€L
  RRR4       V F+  pVP/                  4       '       d   K  VP3                  4        K-  	  R# R#  ELD  \         d    Ro ELi ; i ELõ ELµ EL¨ EL›  + GRj  x€L 
 '       g   i     EL³; i  + '       g   i     EK+  ; i EL  EL‚ ELd ELW ELJ  + GRj  x€L 
 '       g   i     EKÅ  ; i  \        P&                   d    h \         d$   p\(        P+                  RTRR7        Rp?EL Rp?ii ; i EL�u upi  EL  + '       g   i     EL; i  SP-                  4        Uu. uF  qîP/                  4       '       d   K  TNK  	  Mu upi ppT'       d”   \        \         P"                  RRR7      ;_uu_ 4        \        P0                  ! YòR7      G Rj  x€L 
  RRR4       M  + '       g   i     M; iT F+  pTP/                  4       '       d   K  TP3                  4        K-  	  i i ; i5i)uÔ   Process pending CLIâ†’gateway session handoffs from ``state.db``: claim atomically (pending
â†’ running), re-bind the home channel to the CLI session_id, dispatch a synthetic event, mark
``completed``/``failed``.)Ú_async_profile_runtime_scopeÚ_reclaim_staleÚ_resolve_handoff_watch_scopes)Úoff_loop_gateÚprofile_has_pending_handoffNFc               ó   € V ^8„  d   QhRR/# r[   r'   )r(   s   "r)   r*   ÚCGatewayAdapterLifecycleMixin._handoff_watcher.<locals>.__annotate__"  s   € ÷ 	/ñ 	/È$ñ 	/r+   c           	   “  óB  <"  €  SP                   ! S'       d   W3MV 3!  G Rj  x€L
  VP                  V4      G Rj  x€L
  SP                  TR4       R#  L1 L  \        P                   d    h \         dŒ   p\
        P                  RYRR7       \        \        P                  RRR7      ;_uu_ 4        TP                  T\        T4      4      G Rj  x€L 
  RRR4        Rp?K§    + '       g   i      Rp?L»; iRp?ii ; i  SP                  TR4       i ; i5i)z?Run one claimed handoff to a terminal state, off the poll path.Nz!Handoff for session %s failed: %sTr´   z Could not record handoff failure)Ú_process_handoffÚcomplete_handoffrL   rò   rq   rc   rd   r   r`   ra   Úfail_handoffr&   r  )ÚrowÚ
session_idÚ
session_dbÚprofile_namerœ   Ú_process_takes_profileÚinflightr8   s   &&&& €€€r)   Ú	_dispatchÚ@GatewayAdapterLifecycleMixin._handoff_watcher.<locals>._dispatch"  sà   øé € ð/Ø×+Ò+×E[¨sÑ.AÐbeÐagÑi×iÐiØ ×1Ñ1°*Ó=×=Ð=ð —‘˜Z¨Ö.ñ jÙ=øÜ×)Ñ)ô àÜô HÜ—‘ÐBÀJÐ^b�ÔcÜ$¤W§]¡]Ð4VÐae×fÖfØ$×1Ñ1°*¼cÀ#»hÓG×GÑG÷ g×f×f×fÑfþðHûð
 —‘˜Z¨Õ.üs�   ƒD…A ¤A¥A ½A¾A ÁDÁA ÁA ÁDÁ9DÁ:<D Â6C)ÃC
ÃC)ÃD Ã#D Ã)C=Ã4D Ã8D Ã=D Ä DÄD ÄDÄDc               ó    € V ^8„  d   QhRRRR/# )r"   r^  rj   r%   r\   r'   )r(   s   "r)   r*   rV  1  s   € ÷ 	ñ 	 mð 	¸tñ 	r+   c           	   “  óF  <"  € \        SRR4      pVf   R# VP                  4       G Rj  x€L
 pV Ff  pVP                  R4      pV'       d   VS9   d   K%  VP                  V4      G Rj  x€L
 '       g   KF  \        P
                  ! S! W4W4      4      SV&   Kh  	  R#  Lr L45i)a  One poll of the CURRENTLY-SCOPED store; ``profile_name`` (None = root) routes delivery
to that profile's OWN adapter. A closure, not a method: tests bind ``_handoff_watcher`` onto
a ``SimpleNamespace`` with only ``_session_db``/``_running``/``_process_handoff``.Ú_session_dbNÚid)r¿   Úlist_pending_handoffsr¶   Úclaim_handoffrL   rW   )r^  r]  Úpendingr[  r\  ra  r`  r8   s   &    €€€r)   Ú_tickÚ<GatewayAdapterLifecycleMixin._handoff_watcher.<locals>._tick1  s—   øé € ô !  }°dÓ;ˆJØÒ!ÙØ&×<Ñ<Ó>×>ˆGÛ�Ø ŸW™W T›]�
ß! Z°8Ô%;ÙØ'×5Ñ5°jÓA×AÖAáô (/×'<Ò'<Ù˜c¨zÓHó(�˜Ó$ó% ñ ?ñ
 Bùs'   ƒ'B!ªB«?B!Á*BÁ+	B!Á5)B!ÂB!c                ó0   <€ \         P                  SV 4      # r1  )rC   Ú_async_scope_or_null)Úprofile_homerP  s   &€r)   Ú_scopeÚ=GatewayAdapterLifecycleMixin._handoff_watcher.<locals>._scopeP  s   ø€ Ü/×DÑDÐEaÐcoÓpÐpr+   zStale-handoff reclaim failedTr´   c                ó   <€ S! V 4      # r1  r'   )ÚhomerT  s   &€r)   r4  Ú?GatewayAdapterLifecycleMixin._handoff_watcher.<locals>.<lambda>`  s   ø€ Ñ@[Ð\`Ô@ar+   zHandoff watcher tick error: %szHandoff drain raisedrJ   r1  )rŠ   rP  rQ  rR  Úgateway.run_idle_gatesrS  rT  rL   r8  Úinspectr  Ú	signaturerX  Ú
parametersrq   r   r`   ra   r9  rò   rc   rr   ÚvaluesrP   rM   rN   )r8   rM  rN  rQ  rR  rS  Ú_inspectrj  ro  Ú_pnameÚ_phomer^  rn  rœ   rE  Úpending_tasksrE   rP  ra  r_  r`  rT  s   f&&              @@@@@r)   Ú_handoff_watcherÚ-GatewayAdapterLifecycleMixin._handoff_watcher  s   ýé € ÷ 	lÑkßUÜ�mŠm˜AÓ×Ðð	+Û&Ü%(¨×);Ñ);¸D×<QÑ<QÓ)R×)]Ñ)]Ó%^ÐbcÑ%cÐ"ð -/ˆ÷	/ò 	/÷	ô 	õ>	qñ
 %BÀ$Ó$G×GÒG‰NˆFÜ ¤§¡Ð0NÐY]×^Ö^Ù! &Ÿ>Ÿ>�>Ù(¨Ó.×.Ð.÷ *Ÿ>÷ _Ñ^ñ Hð	&Ø—-—-�-ðWÙ<YÐZ^Ó<_×6_Ò6_Ñ2˜ð (Ò3Á-Ø $°,Ö&aóCc÷ =cö =cá$Ù#)¨,×#7×#7Õ#7Ù"'¨Ó"5×5Ð5÷ $8×#7Ñ#7ñ 7`ô —m’m HÓ-×-Ò-ð  ð" )1¯©Ô(9ÓJÑ(9 1ÇÁÇŸQ˜QÑ(9ˆMÐJßÜ$¤W§]¡]Ð4JÐUY×ZÖZÜ!Ÿ,š, }ÔL×LÐL÷ [ã)�DØŸ9™9Ÿ;œ;ØŸ™žó *ñ òi 	øô
 ô 	+Ø%*Ó"ð	+úòp Hâ)Ú.÷ *Ÿ>Ÿ>œ>ú÷ _×^Ñ^úò 7`ò=cò $8Ú5÷ $8×#7×#7Õ#7ûä×-Ñ-ô ØÜ ô WÜ—L‘LÐ!AÀ3ÐQU�L×VÒVûðWúâ-ùò Kò M÷ [×ZÐZûð )1¯©Ô(9ÓJÑ(9 1ÇÁÇŸQ˜QÒ(9ùÒJˆMÐJßÜ$¤W§]¡]Ð4JÐUY×ZÖZÜ!Ÿ,š, }ÔL×LÑL÷ [×Z×ZÐZúã)�DØŸ9™9Ÿ;œ;ØŸ™žò *ð üs  ˆ,P;´I8µP;º5I; Á/+P;ÂJÂ-P;ÃJ8ÃJÃJ8Ã!JÃ-JÃ.JÃ2J8Ã=J
Ã>J8ÄP;ÄM Ä"K: Ä-KÄ. K: ÅKÅ	K: ÅK: Å/K
Å0K: Å3KÅ?K
Æ KÆK: ÆKÆK: ÆM Æ1M Æ2M Æ9P;ÇMÇ'MÇ-.P;ÈMÈ6MÈ7MÈ; P;É P;É;JÊP;ÊJÊP;ÊJ8ÊJÊJ8ÊJ5Ê!J$Ê"
J5Ê-J5Ê/	J8Ê8K
Ë
P;ËK: ËK: ËK: ËKËK: ËK7Ë"K%Ë#
K7Ë.K7Ë0
K: Ë:L=ÌL=ÌL8Ì2M Ì8L=Ì=M ÍP;ÍMÍM	Í	P;ÍP8Í2NÎNÎ4P8ÏO2	Ï#O&Ï$O2	Ï)	P8Ï2PÏ= P8Ð"P8Ð8P;c               ó    € V ^8„  d   QhRRRR/# )r"   r{   r&   r%   r\   r'   )r(   s   "r)   r*   rH   s  s   € ÷ ñ °#ð ¸tñ r+   c                ó¨   € \        V RR4      '       g   R# \        V RR4      '       d   V P                  ^ R7       R# \        P                  R4       R# )u�  Own the reconnect invariant once supervision gives up: while running with queued
platforms, a watcher is live or a bounded respawn is scheduled (no later event can notice
a dead watcher). Slow-tier exhaustion logs loudly; deliberately NOT a process restart.

Before this, the only thing that noticed a dead watcher was a *later fatal error from some other
platform* reaching ``_queue_retryable_fatal_platform``. That is event-coupled recovery: it needs an
event that, by construction, may never come. #81036 moved queue publication ahead of disconnect and
drops the failed adapter from the live map, so once the watcher's budget is spent there may be no
adapter left that can emit the event recovery was waiting on. The platform stays queued, nothing
retries it, and the stranded check in ``_handle_adapter_fatal_error_detached`` treats a queued
platform as safe â€” so the process is never restarted either.
r9  FNrÞ   r(  uq   Reconnect watcher supervision exhausted with an empty retry queue â€” leaving it down until a platform is queued.)r¿   Ú(_schedule_slow_reconnect_watcher_respawnrc   rd   )r8   r{   s   &&r)   Ú_on_reconnect_watcher_gave_upÚ:GatewayAdapterLifecycleMixin._on_reconnect_watcher_gave_ups  sK   € ô �t˜Z¨×/Ò/ÙÜ�4Ð,¨d×3Ò3Ø×9Ñ9À!Ð9ÖDô �N‰NðHör+   c               ó    € V ^8„  d   QhRRRR/# )r"   r&  rÊ   r%   r\   r'   )r(   s   "r)   r*   rH   ‹  s   € ÷ Kñ KÀ3ð KÈ4ñ Kr+   c          	     ó.  a a€ SS P                   8¼  dN   \        P                  RS\        S P                  4      RP                  R S P                   4       4      4       R# R VV 3R llpS P                  \        P                  ! V! 4       4      4       R# )z3Bounded slow-tier respawn of the reconnect watcher.z¨Reconnect watcher could not be kept alive after %d slow respawns; %d platform(s) remain queued and unattended: %s. Manual intervention or a gateway restart is required.ú, c              3  ó8   "  € T F  p\        V4      x € K  	  R # 5ir1  )r&   )Ú.0Úps   & r)   Ú	<genexpr>ÚXGatewayAdapterLifecycleMixin._schedule_slow_reconnect_watcher_respawn.<locals>.<genexpr>‘  s   é € Ð?gÑPfÈ1ÄÀAÇÀÓPfùs   ‚Nc               ó   € V ^8„  d   QhRR/# r[   r'   )r(   s   "r)   r*   Ú[GatewayAdapterLifecycleMixin._schedule_slow_reconnect_watcher_respawn.<locals>.__annotate__•  s   € ÷ 	ñ 	 Tñ 	r+   c               “  ó¨  <"  € \         P                  ! SP                  4      G R j  x€L
  \        SRR 4      p \        SRR4      '       d.   \        SRR 4      '       d   V e   V P	                  4       '       g   R # \
        P                  R\        SP                  4      S^,           SP                  4       SP                  VV3R lR7       R #  L¨5i)NÚ_reconnect_watcher_taskr9  FrÞ   uN   Reconnect watcher still down with %d platform(s) queued â€” slow respawn %d/%dc                ó6   <€ SP                  S^,           R7      # )é   r(  )r�  )Ú_namer&  r8   s   &€€r)   r4  ÚnGatewayAdapterLifecycleMixin._schedule_slow_reconnect_watcher_respawn.<locals>._slow_respawn.<locals>.<lambda>£  s   ø€ ¨×)VÑ)VÐ_fÐijÕ_jÐ)VÔ)kr+   )r.  )rL   r8  Ú"_RECONNECT_WATCHER_SLOW_RETRY_SECSr¿   rP   rc   rd   r  rÞ   Ú_MAX_SLOW_WATCHER_RESPAWNSÚ_spawn_reconnect_watcher)rE   r&  r8   s    €€r)   Ú_slow_respawnÚ\GatewayAdapterLifecycleMixin._schedule_slow_reconnect_watcher_respawn.<locals>._slow_respawn•  s¨   øé € Ü—-’- × GÑ GÓH×HÐHÜ˜4Ð!:¸DÓAˆDä˜D *¨e×4Ò4Ü˜tÐ%8¸$×?Ò?ØÒ$¨T¯Y©Y¯[ª[áÜ�N‰NØ`Ü�D×*Ñ*Ó+¨W°q­[¸$×:YÑ:Yôð ×)Ñ)Ýkð *ö ñ Iùs   ƒ$C§C¨ACÁ9AC)	r•  rc   rñ   r  rÞ   Újoinr  rL   rÂ   )r8   r&  r—  s   fd r)   r�  ÚEGatewayAdapterLifecycleMixin._schedule_slow_reconnect_watcher_respawn‹  sw   ù€ à�d×5Ñ5Ô5Ü�L‰Lðcàœ˜T×3Ñ3Ó4°d·i±iÑ?gÐPT×PfÒPfÓ?gÓ6gôñ
 ÷	ñ 	ð" 	×$Ñ$¤W×%8Ò%8¹»Ó%IÖJr+   c               ó”   a € S P                  S P                  RV 3R lT;'       g    S P                  R7      S n        S P                  # )z¬Launch the reconnect watcher. ``on_spawn`` is load-bearing: without it a supervised
respawn leaves ``_reconnect_watcher_task`` dead and ``_ensure_...`` spawns a second one.Úplatform_reconnect_watcherc                ó   <€ \        SR V 4      # )r�  )Úsetattr)rE  r8   s   &€r)   r4  ÚGGatewayAdapterLifecycleMixin._spawn_reconnect_watcher.<locals>.<lambda>­  s   ø€ œw tÐ-FÈÔJr+   )r-  r.  )r:  Ú_platform_reconnect_watcherr‚  r�  )r8   r.  s   f$r)   r–  Ú5GatewayAdapterLifecycleMixin._spawn_reconnect_watcher¨  sK   ø€ ð (,×'=Ñ'=Ø×,Ñ,Ð.JÜJØ!×GÐG T×%GÑ%Gð (>ó (
ˆÔ$ð
 ×+Ñ+Ð+r+   c               ó   € V ^8„  d   QhRR/# r[   r'   )r(   s   "r)   r*   rH   ²  s   € ÷ (ñ (°4ñ (r+   c                óò   € \        V RR4      p\        V RR4      '       d   Ve   VP                  4       '       g   R# \        P                  RVe   VP                  4       MR4       V P	                  4        R# )a»  Respawn a dead reconnect watcher (called on BOTH _queue_retryable_fatal_platform paths:
the re-fatal of an already-queued platform is the only case that exhausts the budget).

If the tracked reconnect watcher task has died (e.g. from exhausting its restart budget, or a
terminal exception that _spawn_supervised could not recover), respawns it so platforms queued for
reconnection are not permanently stranded. Called from _queue_retryable_fatal_platform on BOTH paths
(#70344, #90386): after a new enqueue, and after a re-fatal for a platform that is already queued --
the latter being the only case in which the watcher can have been retrying long enough to exhaust
its supervised restart budget.
r�  Nr9  Fu7   Reconnect watcher task is dead (done=%s) â€” respawningzN/A)r¿   rP   rc   rd   r–  )r8   rE   s   & r)   rß   Ú>GatewayAdapterLifecycleMixin._ensure_reconnect_watcher_running²  sa   € ô �tÐ6¸Ó=ˆÜ�t˜Z¨×/Ò/°DÒ4DÈTÏYÉYÏ[Ê[ÙÜ�‰ØEØÒ+ˆD�I‰IŒK°ô	
ð 	×%Ñ%Ö'r+   c               ó   € V ^8„  d   QhRR/# r[   r'   )r(   s   "r)   r*   rH   Æ  s   € ÷ ñ °4ñ r+   c              ƒ  ó   a "  € RR V 3R lllp\         P                  ! ^
4      G Rj  x€L
  S P                  '       d¶   S P                  '       g   V! ^RR7      G Rj  x€L
 '       g   R# K@  \        P
                  ! 4       p\        S P                  P                  4       4       F1  pS P                  '       g    R# S P                  W24      G Rj  x€L
  K3  	  V! ^
4      G Rj  x€L
 '       d   KÅ  R# R#  LÍ L™ L( L5i)u²   Periodically retry failed platforms: backoff 30s â†’ 300s cap, retryable failures retry
forever (self-heal), non-retryable drop out. Pausing is manual only (``/platform pause``).c               ó$   € V ^8„  d   QhRRRRRR/# )r"   ÚsecondsrÊ   Úuntil_queuedr$   r%   r'   )r(   s   "r)   r*   ÚNGatewayAdapterLifecycleMixin._platform_reconnect_watcher.<locals>.__annotate__É  s!   € ÷ 	ñ 	 ð 	°Dð 	ÀTñ 	r+   c              “  óØ   <"  € \        V 4       FS  pSP                  '       g    R# V'       d   SP                  '       d    R# \        P                  ! ^4      G Rj  x€L
  KU  	  R#  L
5i)zSSleep in 1s steps; False once the runner stops (or, if asked, once work is queued).FNT)Úranger9  rÞ   rL   r8  )r¨  r©  Ú_r8   s   && €r)   Ú_idleÚGGatewayAdapterLifecycleMixin._platform_reconnect_watcher.<locals>._idleÉ  sR   øé € ä˜7–^�Ø—}—}�}Ú ß D×$:×$:Ð$:Øáô —m’m AÓ&×&Ò&ñ $ñ ñ 'ùs   ƒ+A*¯A*ÁA*ÁA(ÁA*NT)r©  )F)	rL   r8  r9  rÞ   rn   ro   ÚlistÚkeysÚ_reconnect_failed_platform)r8   r®  r×   r#   s   f   r)   r   Ú8GatewayAdapterLifecycleMixin._platform_reconnect_watcherÆ  sÄ   øé € ÷	ò 	ô �mŠm˜BÓ×ÐØ�m�mˆmØ×)×)Ð)Ù" 2°DÔ9×9Ö9ÙÙÜ—.’.Ó"ˆCÜ  ×!7Ñ!7×!<Ñ!<Ó!>Ö?�Ø—}—}�}ÚØ×5Ñ5°hÓD×DÒDñ @ñ ˜r›—?—?�?Ùñ ñ 	 ñ :ñ EÙ"ùs]   ƒ%C>¨C6©C>¿C>ÁC>ÁC8Á	C>Á)A(C>ÃC:ÃC>Ã%C<Ã&C>Ã2C>Ã8C>Ã:C>Ã<C>Ú
status_keyc               ó(   € V ^8„  d   QhRRRRRRRR/# )	r"   rt   rÌ   r×   rG   r´  rj   r%   r\   r'   )r(   s   "r)   r*   rH   á  s,   € ÷ 
ñ 
Ø"ð
Ø).ð
Ø?Lð
à	ñ
r+   c          
     óà  € ^ RI Hp VP                  R4      '       g   V! W#4      '       g   R# RVR&   W2P                  RV4      ,
          p\        P	                  RT;'       g    VP
                  VR,          VP                  R^ 4      4       T P                  T;'       g    VP
                  R	R\        P                  ! \        4      \        VR
7      ,
          P                  4       R7       R# )u  Flag NEEDS_ATTENTION (once) past the threshold â€” a signal, NOT a circuit breaker. The threshold
is the bound profile's ``agent.reconnect_attention_after``: secondaries call this inside their
``_profile_runtime_scope`` with their ``<profile>:<platform>`` status key.)Ú_reconnect_needs_attentionÚattention_flaggedNTrÐ   u  %s has been failing/reconnecting continuously for %.1f hours (%d attempts) â€” flagging NEEDS_ATTENTION. Retries continue, but this usually means a permanent problem (revoked credentials, missing intents, broken sidecar). Check `hermes status` / `/platform list`.g      ¬@rÉ   r    )r¨  )r  Úneeds_attentionÚretrying_since)rŠ   r·  r¶   rc   rd   r.   r  r   r×   r
   r   Ú	isoformat)r8   r#   rt   r×   r´  r·  Ú
queued_fors   &&&&$  r)   Ú_flag_reconnect_needs_attentionÚ<GatewayAdapterLifecycleMixin._flag_reconnect_needs_attentioná  sÃ   € õ 	;Ø�8‰8Ð'×(Ò(Ñ0JÈ4×0UÒ0UÙØ$(ˆÐ Ñ!ØŸ8™8 K°Ó5Õ5ˆ
Ü�‰ðgð ×(Ð(˜(Ÿ.™.¨*°vÕ*=¸t¿x¹xÈ
ÐTUÓ?Vô		
ð 	×,Ñ,Ø×(Ð(˜(Ÿ.™.¸ÐUYÜ$ŸLšL¬Ó-´	À*Ô0MÕM×XÑXÓZð 	-ö 	
r+   c               ó    € V ^8„  d   QhRRRR/# )r"   r´  r&   r%   r\   r'   )r(   s   "r)   r*   rH   ÷  s   € ÷ 
ñ 
¨sð 
Àñ 
r+   c                óX   € V P                  VRVP                  VP                  R7       R# )zIRecord an adapter's fatal error code/message as ``fatal`` runtime status.r  r  N)r  r
  r  )r8   r´  r^   s   &&&r)   Ú_mark_platform_fatalÚ1GatewayAdapterLifecycleMixin._mark_platform_fatal÷  s+   € à×,Ñ,Ø w¸7×;SÑ;SØ!×5Ñ5ð 	-ö 	
r+   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r"   rt   rÌ   r&  rÊ   r	  r&   r%   r'   )r(   s   "r)   r*   rH   þ  s,   € ÷ ñ Ø"ðØ-0ðØMPðà	ñr+   c                ó¤   € ^ RI Hp V P                  VP                  RWER7       V! V4      pW2R&   \        P
                  ! 4       V,           VR&   V# )zVMark the platform retrying and record the failed attempt; returns the backoff applied.)Ú_reconnect_backoffr    r  rÉ   rÏ   )rŠ   rÅ  r  r.   rn   ro   )r8   r#   rt   r&  r  r	  rÅ  r;  s   &&&&&&  r)   Ú_bump_reconnect_backoffÚ4GatewayAdapterLifecycleMixin._bump_reconnect_backoffþ  sT   € õ 	3Ø×,Ñ,Ø�N‰N¨:À*ð 	-ô 	
ñ % WÓ-ˆØ"ˆZÑÜ!Ÿ^š^Ó-°Õ7ˆˆ\ÑØˆr+   c               ó   € V ^8„  d   QhRR/# rª   r'   )r(   s   "r)   r*   rH     s   € ÷ 
ñ 
¸dñ 
r+   c                ó–   € ^ RI Hp ^ RIHpHp W9  ;'       d1    VP                  VP                  4      '       * ;'       d	    V! W4      # )aÍ  Whether a platform whose ``_create_adapter`` returned None can heal without a config change.

Only an unregistered plugin can (a plugin load can fail transiently). A builtin whose probe fails
(missing deps/creds), a registered plugin returning None, or an empty bot credential needs a config
change: retrying it re-warns forever at the backoff cap (#5196 fleet nodes). Shared by startup and
the reconnect watcher so both classify the same platform the same way.©Úplatform_registry)Ú_BUILTIN_ADAPTERSÚ_platform_has_bot_credential)Úgateway.platform_registryrË  rŠ   rÌ  rÍ  Úis_registeredr.   )r8   r#   rÖ   rË  rÌ  rÍ  s   &&&   r)   Ú_adapter_may_healÚ.GatewayAdapterLifecycleMixin._adapter_may_heal  sK   € õ 	@ßOàÑ-÷ Hð HØ%×3Ñ3°H·N±NÓCÔC÷Hð Há,¨XÓGð	
r+   c               ó    € V ^8„  d   QhRRRR/# )r"   r×   rG   r%   r\   r'   )r(   s   "r)   r*   rH     s"   € ÷ Ydñ Yd¸eð YdÈñ Ydr+   c           
   ƒ  ón  "  € ^ RI HpHp V P                  P	                  V4      pVe   VP	                  R4      '       d   R# V P                  WV4       W%R,          8  d   R# VR,          pVR,          ^,           pV! W4      '       g   V P                  VR4       R# \        P                  RVP                  V4       Rp ^ R	I
Hp	 V P                  V	P                  VP                  4      G Rj  x€L
  V P                  W4      pV'       gÿ   V P                  W4      '       g@   V P                  VP                  R
R\!        VRR7      RR7       V P                  VR4       R# ^ RIHp
 VP	                  R^ 4      pV\&        8  dF   V P                  V
! 4       P(                  VP                  4      G Rj  x€L
 '       d   V^,           VR&   V P+                  WVR\!        V4      4      p\        P                  RVP                  V4       R# \-        VP	                  R4      V4       V P/                  V4       V P1                  W�RR7      G Rj  x€L
 pV'       d   V P3                  W4      G Rj  x€L
  R# VP4                  '       dy   VP6                  '       gg   V P9                  VP                  V4       \        P;                  RVP                  VP<                  4       V! V4      G Rj  x€L
  V P                  V R# T P+                  YYxP>                  VP<                  ;'       g    R4      p\        P                  RVP                  V4       V! V4      G Rj  x€L
  \A        W…P	                  R4      4       R#  ELŽ ELÌ EL6 EL L� L.  \B         d˜   pTeK   T! T4      G Rj  x€L 
  T PD                  P	                  T4      TJd   \A        Y…P	                  R4      4       T P+                  YTR\G        T4      4      p\        P;                  RTP                  Yì4        Rp?R# Rp?ii ; i5i)zNOne watcher pass for a queued platform: gate, attempt, and record the outcome.)Ú_dispose_unused_adapterrÍ  NÚpausedrÏ   rÎ   rÉ   z"no bot credential on queued configzReconnecting %s (attempt %d)...rÊ  r  Úadapter_unavailableF)r    T)r  r  r	  r¹  zadapter creation returned None)Úget_plugin_managerÚload_rearmsz/Reconnect %s: no adapter yet, next retry in %dsrÓ   r£   zAReconnect %s: non-retryable error (%s), removing from retry queuezfailed to reconnectz&Reconnect %s failed, next retry in %dsz)Reconnect %s error: %s, next retry in %ds)$rŠ   rÔ  rÍ  rÞ   r¶   r½  Ú_drop_from_reconnect_queuerc   rt   r.   rÎ  rË  Ú_run_in_executor_with_contextÚ_create_adapterrÐ  r  r0   Úhermes_cli.pluginsr×  Ú_MAX_PLUGIN_LOAD_REARMSÚrearm_failed_platformrÆ  r   Ú_wire_adapter_handlersrž   Ú_install_reconnected_adapterÚhas_fatal_errorrÜ   rÁ  rd   r  r
  r   rq   rô   r&   )r8   r#   r×   rÔ  rÍ  rt   rÖ   r&  r^   rË  r×  Úrearmsr;  Úsuccessrw   s   &&&            r)   r²  Ú7GatewayAdapterLifecycleMixin._reconnect_failed_platform  sŽ  é € çUØ×%Ñ%×)Ñ)¨(Ó3ˆàŠ<˜4Ÿ8™8 H×-Ò-ÙØ×,Ñ,¨X¸SÔAØ�lÕ#Ô#ÙØ˜x�.ˆØ�zÕ" QÕ&ˆñ ,¨H×FÒFØ×+Ñ+¨HÐ6ZÔ[ÙÜ�‰Ð5°x·~±~ÀwÔOØˆðE	dÝCà×4Ñ4Ð5F×5JÑ5JÈHÏNÉNÓ[×[Ð[Ø×*Ñ*¨8ÓEˆGßØ×-Ñ-¨h×HÒHà×8Ñ8Ø Ÿ™°wÐK`Ü&BÀ8ÐV[Ô&\Ø(,ð 9ô ð
 ×3Ñ3°HÐ>^Ô_ÙåAØŸ™ -°Ó3�àÔ3Ô3¸d×>`Ñ>`Ù*Ó,×BÑBÀHÇNÁNó?T÷ 9Tö 9Tà*0°1­*�D˜Ñ'Ø×6Ñ6Ø GÐ-BÔD`ÐaiÓDjó�ô —‘ÐMÈxÏ~É~Ð_fÔgÙÜ §¡¨Ó 7¸ÔAØ×'Ñ'¨Ô0à ×>Ñ>¸wÐ_cÐ>Ód×dˆGßØ×7Ñ7¸ÓJ×JÒJØ×(×(Ð(°×1N×1NÐ1NØ×)Ñ)¨(¯.©.¸'ÔBÜ—‘ØWØ—N‘N G×$?Ñ$?ôñ .¨gÓ6×6Ð6Ø×*Ñ*¨8Ò4ð ×6Ñ6Ø G×-EÑ-EØ×/Ñ/×HÐHÐ3Hó�ô —‘ÐDÀhÇnÁnÐV]Ô^ñ
 .¨gÓ6×6Ð6ä& w·±¸Ó0GÖHòs \ò 9Tò eâJñ 7ñ 7øô ô 	dØÒ"á-¨gÓ6×6Ñ6Ø—=‘=×$Ñ$ XÓ.°gÓ=Ü*¨7·H±H¸]Ó4KÔLà×2Ñ2°8À7ÈDÔRUÐVWÓRXÓYˆGÜ�N‰NÐFÈÏÉÐXY×cÒcûð	düs  ‚>P5ÁBP5Ã/N Ã2N Ã3A1N Å$P5Å&AN Æ7NÆ8	N ÇA
N ÈP5ÈAN ÉNÉN ÉN É1N	É2N É6P5É8N Ê
N ÊAN Ë.NË/N Ì P5Ì)N Ì,3N ÍNÍ N Í>P5Î N ÎN ÎN Î	N ÎN ÎN ÎP2ÎP-Î*N-Î+A<P-Ð'P5Ð-P2Ð2P5c               ó    € V ^8„  d   QhRRRR/# r  r'   )r(   s   "r)   r*   rH   u  s   € ÷ -ñ -¸3ð -À4ñ -r+   c                	ób   € \         P                  R VP                  V4       V P                  V R# )z+Reconnect %s: %s, removing from retry queueN)rc   rd   r.   rÞ   )r8   r#   r   s   &&&r)   rÙ  Ú7GatewayAdapterLifecycleMixin._drop_from_reconnect_queueu  s&   € Ü�‰ÐDÀhÇnÁnÐV\Ô]Ø×"Ñ" 8Ò,r+   c               ó   € V ^8„  d   QhRR/# r[   r'   )r(   s   "r)   r*   rH   y  s   € ÷ 1ñ 1¸Tñ 1r+   c                ó¬   € W P                   V&   V\        P                  8X  d   ^ RIHp V! V4       V P                  V4       V P                  V4       R# )zcRegister a connected primary adapter and wire voice mode/input (transcription without /voice join).)Úrecover_api_turnsN)rô   r   Ú
API_SERVERÚgateway.session_api_turnrê  Ú!_sync_voice_mode_state_to_adapterÚ_bind_voice_input_callback)r8   r#   r^   rê  s   &&& r)   Ú_publish_primary_adapterÚ5GatewayAdapterLifecycleMixin._publish_primary_adaptery  sC   € à")�‰�hÑØ”x×*Ñ*Ô*ÝBÙ˜gÔ&Ø×.Ñ.¨wÔ7Ø×'Ñ'¨Ö0r+   c               ó   € V ^8„  d   QhRR/# r[   r'   )r(   s   "r)   r*   rH   ‚  s   € ÷ nñ n°$ñ nr+   c                óÖ   € ^ RI Hp V! 4       '       dV   V P                  \        P                  ! V P                  4       4      4      pVP                  V P                  R4      4       R# R# )z¤Replay the owed planned-restart notice after a reconnect, in the background: notification delivery
must not hold up adapter recovery or other platforms' reconnects.)Ú%_planned_restart_notification_pendingz*planned-restart notification replay failedN)rŠ   ró  r  rL   rÂ   Ú,_replay_pending_planned_restart_notificationrO   Ú_late_failure_callback)r8   ró  rE   s   &  r)   Ú _schedule_planned_restart_replayÚ=GatewayAdapterLifecycleMixin._schedule_planned_restart_replay‚  s[   € õ 	FÙ0×2Ò2Ø×/Ñ/´×0CÒ0CØ×AÑAÓCó1ó ˆDð ×"Ñ" 4×#>Ñ#>Ð?kÓ#lÖmñ	 3r+   c               ó   € V ^8„  d   QhRR/# r[   r'   )r(   s   "r)   r*   rH   Œ  s   € ÷ !oñ !oÀtñ !or+   c           	   ƒ  ó  "  € V P                  W4       V P                  V P                  n        \        V P                  P                  V4      P                  R4      V4       VP                  pT P                  VP                  V'       d   RMRRV'       d   VP                  MRRRR7       V'       d"   \        P                  RVP                  4       M \        P                  RVP                  4       V P                  4        \        \        P                   R	VP                  R
R7      ;_uu_ 4        V P#                  V4      G Rj  x€L
  RRR4       \%        \&        4      ;_uu_ 4        ^ RIHp V! V P                  4      G Rj  x€L
  RRR4        V P-                  VR7       R#  La  + '       g   i     Lg; i L6  + '       g   i     L<; i  \&         d'    \        P/                  RTP                  R
R7        R# i ; i5i)zSPublish a freshly reconnected primary adapter and replay what it missed while down.rÓ   r    Ú	connectedNF)r  r  r	  r¹  rº  uD   âš  %s reconnected in degraded mode (receive path not yet confirmed)u   âœ“ %s reconnected successfullyz6failed-obligation redelivery after %s reconnect failedTr´   )Úbuild_channel_directory©r#   z3resume-pending reschedule after %s reconnect failed)rï  rô   r  r   rÞ   r  r¶   Úsend_path_degradedr  r.   ÚDEGRADED_STATUS_MESSAGErc   rt   rö  r   r`   ra   Ú*_redeliver_failed_obligations_for_platformr   rq   Úgateway.channel_directoryrû  Ú!_schedule_resume_pending_sessionsrr   )r8   r#   r^   Ú	_degradedrû  s   &&&  r)   rà  Ú9GatewayAdapterLifecycleMixin._install_reconnected_adapterŒ  sŒ  é € à×%Ñ% hÔ8Ø(,¯©ˆ×ÑÔ%Ü˜t×5Ñ5×9Ñ9¸(ÓC×GÑGÈÓVÐX_Ô`ð ×.Ñ.ˆ	Ø×,Ñ,Ø�N‰N¿©:ÈÐ`dß=F˜'×9Ò9ÈDØ!°$ð 	-ô 	
÷
 Ü�K‰KÐ^Ð`h×`nÑ`nÕoä�K‰KÐ9¸8¿>¹>ÔJØ×-Ñ-Ô/äÜ�M‰MÐSØ�N‰N T÷
ö 
ð ×AÑAÀ(ÓK×KÐK÷	
ô ”i× Õ ÝIÙ)¨$¯-©-Ó8×8Ð8÷ !ð	oØ×2Ñ2¸HÐ2ÖEñ L÷	
÷ 
úñ 9÷ !× ûô ô 	oÜ�L‰LÐNÐPX×P^ÑP^ÐimˆL×nð	oüs‹   ‚BHÂHÂ6B HÄ6F/ÅF-ÅF/ÅHÅ/GÆGÆGÆHÆG Æ+HÆ-F/Æ/F?	Æ:HÇGÇG	ÇHÇ-HÈHÈHÈHc               ó   € V ^8„  d   QhRR/# r[   r'   )r(   s   "r)   r*   rH   ¯  s   € ÷ ñ Àñ r+   c           	   ƒ  óÒ  "  € V P                   p\        V\        4      '       g   R# \        P                  ! 4       pVP                  4        UUu. uFu  p\        V\        4      '       g   K  VP                  4        FF  p\        V\        P                  4      '       g   K%  WBJg   K,  VP                  4       '       d   KD  VNKH  	  Kw  	  pppV F  pVP                  4        K  	  V P                  4       pV'       dP   V^ 8”  dI   \        P                  ! WVR7      G Rj  x€L
 w  rxV'       d    \        P                  R\        V4      4       VP                  4        R# u uppi  LE5i)z£Cancel profile-scoped reconnects before tearing down their registry, so a reconnect
mid-setup cannot republish an adapter after the registry drains (bounded wait).NrJ   zLTimed out waiting for %d secondary profile reconnect task(s) during shutdown)Ú_profile_failed_platformsr  rÌ   rL   Úcurrent_taskrx  ÚTaskrP   rN   r_   rM   rc   rd   r  Úclear)	r8   ri  ÚcurrentÚprofile_pendingrE   rÄ   rF   rH  Ú
unfinisheds	   &        r)   Ú)_cancel_secondary_profile_reconnect_tasksÚFGatewayAdapterLifecycleMixin._cancel_secondary_profile_reconnect_tasks¯  s"  é € ð ×0Ñ0ˆÜ˜'¤4×(Ò(ÙÜ×&Ò&Ó(ˆð $+§>¡>Ô#3ô
á#3�Ü˜/¬4×0ô ð (×.Ñ.Ö0�Ü˜$¤§¡×-ô	 ð 37Ð2Eô	 ð OSÏiÉiÏk÷	 ˆDñ 1ñ Ù#3ð 	ñ 
ó ˆDØ�K‰KŽMñ à×7Ñ7Ó9ˆß�W˜q”[Ü&-§l¢l°5Ô&J× JÑˆEßÜ—‘ØbÔdgÐhrÓdsôð 	�‰Žùó!
ñ !Kùs=   ‚AE'ÁEÁ,0EÂ!EÂ(EÃ 
EÃ
3E'Ã>!E'ÄE%Ä AE'c               ó   € V ^8„  d   QhRR/# )r"   r%   rÊ   r'   )r(   s   "r)   r*   rH   È  s   € ÷ <ñ <¸ñ <r+   c           	   ƒ  ó  "  € ^ RI HpHp ^ RIHp V P                  4       '       g?   \        \        P                  RRR7      ;_uu_ 4        ^ RI	H
p V! . R7       RRR4       ^ #  ^ R	IHpHpHp T P                  4       '       d   \!        T R
R4      ;'       g    RpMT! 4       ;'       g    RpT! RRR7       F4  w  ršT	R8w  g   K  T! T
4      '       g   K  \"        P%                  RT	4       K6  	  ^ pT P'                  T4      pT! T P(                  4      p/ T n        \-        4       pT FG  w  ppYø8X  d   K  T! T4      p Y°P/                  TTT4      G Rj  x€L
 ,          pTT P*                  T&   KI  	  T P5                  Y�4       T F  pT P*                  P7                  TR4       K!  	  \!        T RR4      pTe?   T Uu. uF  pTT P*                  9  g   K  TNK  	  up F  pTP7                  TR4       K  	  T P9                  T4       T#   + '       g   i     ^ # ; i  \         d     ^ # i ; i LÛ  T d    h \         d7   p\"        P1                  RTTRR7       TP3                  T4        Rp?EKN  Rp?ii ; iu upi 5i)u	  Bring up adapters for every non-active profile (multiplex only); returns connected count.
Each profile connects under its own HERMES_HOME + secret scope; credential/listener collisions
are refused here â€” the only point seeing every profile's credentials together.)ÚMultiplexConfigErrorÚ_multiplex_profile_homes)Úprofile_serve_signaturezcould not clear served_profilesTr´   ©Úpublish_runtime_status©Úserved_profilesN)Úget_active_profile_nameÚprofiles_to_serveÚprofile_is_parkedÚ_primary_profile_nameÚdefault)Úinclude_parkedzCprofile '%s' is parked (gateway.parked); not served by this gatewayz-Failed to start adapters for profile '%s': %sÚ_profile_configs)rŠ   r  r  Úgateway.run_profile_reconciler  Ú_multiplex_onr   r`   ra   Úgateway.statusr  Úhermes_cli.profilesr  r  r  rq   r¿   rc   rt   Ú_primary_resource_claimsrÎ   Ú_served_profile_signaturesrK   Ú_start_one_profile_adaptersrñ   r  Ú_record_served_profilesr  Ú%_restore_secondary_completion_ledgers)r8   r  r  r  r  r  r  r  Úactiver{   rr  rú  ÚclaimedÚprofile_homesÚtransient_failedr^  rn  Úscan_signaturerw   Úconfigsr‰  s   &                    r)   Ú!_start_secondary_profile_adaptersÚ>GatewayAdapterLifecycleMixin._start_secondary_profile_adaptersÈ  sX  é € ÷ 	OÝIØ×!Ñ!×#Ò#ô !¤§¡Ð0QÐ\`×aÖaÝAÙ&°rÕ:÷ bñ ð	ßiÑið ×Ñ×Òô ˜TÐ#:¸DÓA×NÐNÀY‰Fá,Ó.×;Ð;°)ˆFÙ+¨DÀ×F‰JˆDØ�yÖ Ñ%6°t×%<Ô%<Ü—‘ÐaÐcgÖhñ Gð ˆ	Ø×/Ñ/°Ó7ˆÙ0°·±Ó=ˆØ*,ˆÔ'Ü›5ÐÛ*7Ñ&ˆL˜,ØÔ%Ùá4°\ÓBˆNð	OØ×#CÑ#CÀLÐR^Ð`gÓ#h×hÕh�	ð AO�×/Ñ/°Ó=ñ +8ð 	×$Ñ$ VÔ;ó -ˆLØ×+Ñ+×/Ñ/°¸dÖCñ -ô
 ˜$Ð 2°DÓ9ˆØÒÙ,3Ó `©G q°qÀ×@_Ñ@_Ñ7_§ ©GÔ `�Ø—‘˜L¨$Ö/ñ !aà×2Ñ2°=ÔAØÐ÷e bÖañ ûô ô 	Úð	úñ, iøØ'ô ØÜô 3Ü—‘ÐLÈlÐ\]Ðhl�Ômà ×$Ñ$ \×2Ó2ûð3üò  !aùs¶   ‚A	JÁHÁ
JÁ&
H  Á0JÂJÂJÂ,JÃJÃA(JÅ H4ÅH2Å
H4Å!AJÆ?I?ÇI?Ç/JÈH	È	JÈ H/È+JÈ.H/È/JÈ2H4È4I<ÉI<É*I7É0JÉ7I<É<Jc               ó    € V ^8„  d   QhRRRR/# )r"   r(  r&   r%   údict[tuple, str]r'   )r(   s   "r)   r*   rH     s   € ÷ ñ ¨sð Ð7Gñ r+   c                óx  € / pV P                   P                  4        FA  w  r4V P                  V4      pVe   W53MRV P                  W44      3 F  pVf   K	  WV&   K  	  KC  	  \	        V R/ 4      P                  4        F9  pR F0  pVP                  V4      p	\        V	\        4      '       g   K,  WV	&   K2  	  K;  	  V# )z¯Resource claim -> owning profile for every live or queued primary adapter (credential:
one account polled once; listener: one bind+port). A queued retryable primary owns both.NrÞ   )rÑ   rÒ   )	rô   ÚitemsÚ_adapter_credential_fingerprintrÕ   r¿   rx  r¶   r  Útuple)
r8   r(  r)  Ú_platÚ_adÚfpÚclaimÚ
retry_infoÚ
claim_nameÚretry_claims
   &&        r)   r#  Ú5GatewayAdapterLifecycleMixin._primary_resource_claims  s¸   € ð %'ˆØŸ-™-×-Ñ-Ö/‰JˆEØ×5Ñ5°cÓ:ˆBØ)+ª˜5™+¸TÀ4×C_ÑC_Ð`eÓCkÓl�ØÔ$Ø%+˜E“Nó mñ 0ô
 " $Ð(;¸RÓ@×GÑGÖIˆJÛD�
Ø(Ÿn™n¨ZÓ8�Ü˜k¬5×1Ô1Ø+1˜KÓ(ó Eñ Jð
 ˆr+   c               ó    € V ^8„  d   QhRRRR/# )r"   r(  r&   r%   r\   r'   )r(   s   "r)   r*   rH     s   € ÷ bñ b¨cð bÀTñ br+   c           
     ó,  a€ \        \        P                  RRR7      ;_uu_ 4        ^ RIHp ^ RIHp S.\        V3R lV 4       4      ,           pV P                  V4       V FH  pV'       g   K  W`P                  9  g   K  VS8X  d   V P                  MV! VR7      V P                  V&   KJ  	  V! VR7       ^ R	IHpHpHp	 V! V4      '       d)   ^ R
IHp
 V	! V\#        V4      \%        V
! 4       4      R7       RRR4       R#   + '       g   i     R# ; i)u­   Record the served set (eligible for routing/HTTP prefixes/cron/runtime scope â€” broader
than "has a connected adapter") for `hermes status`; seed per-profile PairingStores.z could not record served_profilesTr´   r  )ÚPairingStorec              3  ó>   <"  € T F  w  rVS8w  g   K  Vx € K  	  R # 5ir1  r'   )rˆ  r{   Ú_homer(  s   &  €r)   rŠ  ÚGGatewayAdapterLifecycleMixin._record_served_profiles.<locals>.<genexpr>  s   øé € Ð&_¹}±°ÐPTÐX^ÑP^§t¢t»}ùs   ƒ“
©rh   r  )ÚROLE_GATEWAYÚowns_host_lockÚpublish_record©Úget_hermes_home)Úprofilesrr  N)r   r`   ra   r!  r  Úgateway.pairingr@  ÚsortedÚ_note_served_profilesÚpairing_storesÚpairing_storeÚgateway.host_rendezvousrE  rF  rG  Úhermes_constantsrI  r5  r&   )r8   r(  r*  r  r@  Úservedr{   rE  rF  rG  rI  s   &f&        r)   r&  Ú4GatewayAdapterLifecycleMixin._record_served_profiles  sÏ   ø€ ô œWŸ]™]Ð,NÐY]×^Ö^Ý=Ý4Ø�X¤Ô&_¹}Ó&_Ó _Õ_ˆFØ×&Ñ& }Ô5Û�ß‘4˜D×(;Ñ(;Ö;à.2°f¬n˜×*Ò*Á,ÐW[ÔB\ð ×'Ñ'¨Ó-ñ ñ
 #°6Õ:÷ ]Ñ\Ù˜l×+Ò+Ý<Ù˜|´e¸F³mÌ#ÉoÓN_ÓJ`Õa÷! _×^×^Ò^ús   ¦ADÁ0DÂADÃ(DÄD	c               ó    € V ^8„  d   QhRRRR/# )r"   r^  r&   rn  r   r'   )r(   s   "r)   r*   rH   +  s   € ÷ "ñ "Àð "ÐTXñ "r+   c              ƒ  ó8  "  € ^ RI HpHpHpHp ^ RIHp ^ RIHp \        P                  ! W‚4      G Rj  x€L
  ^ RIHp	 \        P                  ! W’RR7      G Rj  x€L
  V! VRR7      ;_uu_ 4        V! 4       p
^ RIHpHp V! 4        V P!                  V! 4       W4       V P#                  R	V\$        P&                  R
7       V! 4       pV! V4      pRRR4       V P)                  VX
4       X'       d   V! RV RV R24      hX#  LÎ Lª  + '       g   i     L?; i5i)aY  Hydrate + enter ``profile_home``'s scope once; return its gateway config. Raises
``MultiplexConfigError`` (open dm/group policy). Port-binding platforms are NOT refused: the
default profile owns the single shared listener and a secondary's port-binders are built in
shared-listener mode (``/p/<profile>/...``) by ``_start_one_profile_adapters``.)r  Ú_load_gateway_configÚ"_own_policy_open_startup_violationÚ_profile_runtime_scope©Úload_gateway_config©Úhydrate_profile_secret_sourcesN)Úrecover_left_core_inF©Úhydrate_secrets)Údiscover_pluginsr×  z7shell-hook/webhook registration failed for profile '%s')Úlevelú	Profile 'z
' enables z„. Enable GATEWAY_ALLOW_ALL_USERS or the platform allow-all flag for that profile, or change dm_policy/group_policy away from 'open'.)rŠ   r  rV  rW  rX  Úgateway.configrZ  Úhermes_cli.env_loaderr\  rL   Ú	to_threadÚgateway.run_startupr]  rÜ  r`  r×  Ú_subscribe_plugin_rewireÚ_register_config_hooksr`   ÚWARNINGÚ_snapshot_profile_busy_modes)r8   r^  rn  r  rV  rW  rX  rZ  r\  r]  Úprofile_runtime_cfgr`  r×  Úprofile_cfgÚ	violations   &&&            r)   Ú_load_secondary_profile_configÚ;GatewayAdapterLifecycleMixin._load_secondary_profile_config+  s  é € ÷
	
ó 	
õ 	7ÝHä×ÒÐ >ÓM×MÐMå<Ü×ÒÐ 4ÐTYÔZ×ZÐZÙ# LÀ%×HÖHÙ"6Ó"8ÐßOÙÔØ×)Ñ)Ñ*<Ó*>ÀÔ[à×'Ñ'ØIÈ<Ô_f×_nÑ_nð (ô ñ .Ó/ˆKÙ:¸;ÓGˆI÷ Ið 	×)Ñ)¨,Ð8KÔLßÙ&Ø˜L˜>¨°I°;ð ?Wð Wóð ð
 Ðñ- 	Nñ 	[ßH×Hüs@   ‚2D´Dµ%DÁDÁDÁ1ADÃ!DÃ2DÄDÄD	ÄDc               ó(   € V ^8„  d   QhRRRRRRRR/# )r"   r^  r&   r#   r   Útokenr%   rj   r'   )r(   s   "r)   r*   rH   P  s*   € ÷ ñ ¨sð ÈHð Ð]`ð Ðerñ r+   c                óL  € ^ RI Hp VP                  V4      pV'       d-   \        V\        4      '       d   VP                  4       '       g   R# VP                  4       pRpV'       dJ    ^ RIHp V! \        V4      R,          4      P                  V4      ;'       g    RP                  4       V8H  pV'       d   V '       d   V R8w  d   RV  R	2# R# \        P                  P                  V4      ;'       g    RP                  4       V8X  d   R
V 2# R#   \         d    Rp Lqi ; i)u8  Where *token* was configured for *profile_name*: that profile's ``.env``, or ambient env.

``None`` when the value is not in either place (yaml-only, or unknown). An env label
is only returned when the profile's own ``.env`` does not contain the value â€” a shell
export that merely echoes the file is the file.
)ÚPLATFORM_TOKEN_ENV_NAMESNF)Úload_env_filez.envrm   r  z	profiles/z/.envúenv )rc  rs  r¶   r  r&   r€   Úagent.secret_scopert  r   rq   r~   Úenviron)r^  rn  r#   rq  rs  Úenv_nameÚ	in_dotenvrt  s   &&&&    r)   Ú_credential_claim_originÚ5GatewayAdapterLifecycleMixin._credential_claim_originO  sò   € õ 	<Ø+×/Ñ/°Ó9ˆßœz¨%´×5Ò5¸U¿[¹[¿]º]ÙØ—‘“ˆØˆ	ßð"Ý<Ù*¬4°Ó+=ÀÕ+FÓG×KÑKÈHÓU×[Ð[ÐY[×bÑbÓdÐhmÑm�	÷ ß °	Ô 9Ø" < .°Ð6Ð6ÙÜ�J‰J�N‰N˜8Ó$×*Ð*¨×1Ñ1Ó3°uÔ<Ø˜(˜Ð$Ð$Ùøô ô "Ø!’	ð"ús   Á)3D ÂD ÄD#Ä"D#c          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
r"   Úownerr&   r^  r#   r   r^   r   r%   r5  r'   )r(   s   "r)   r*   rH   k  s4   € ÷  &ñ  &Øð &Ø(+ð &ØEMð &ØX[ð &à	ñ &r+   c                óø  € RpVR3VR3\        VRR4      R33 FW  w  rxVe   \        WxR4      MRp	\        V	\        4      '       g   K/  V	P                  4       '       g   KG  V	P                  4       p M	  V'       g   R# V P	                  W#WF4      p
RpVR8X  d    ^ RIHp V! 4       pM ^ RIH	p V! V4      pV'       d   V P	                  WWF4      MRpWê3#   \         d    Rp L.i ; i  \         d    Rp LAi ; i)	zV``(owner_origin, incoming_origin)`` for a same-credential refusal; either may be None.Nrq  Ú	bot_tokenrÎ   r  )Úget_default_hermes_root©Úget_profile_dir©NN)
r¿   r  r&   r€   rz  rQ  r€  rq   r"  r‚  )r8   r}  r^  rn  r#   r^   rq  ÚobjÚattrÚvalÚincomingÚ
owner_homer€  r‚  Úowner_origins   &&&&&&         r)   Ú_duplicate_credential_originsÚ:GatewayAdapterLifecycleMixin._duplicate_credential_originsk  s  € ð ˆà�gÐ ¨+Ð 6Ü�W˜h¨Ó-¨wÐ7ó
‰IˆCð /2ªo”'˜# TÔ*À4ˆCÜ˜#œs×#Ô#¨¯	©	¯¬ØŸ	™	›�Ùñ
÷ ØÐØ×0Ñ0°ÈXÓ]ˆØˆ
Ø�IÔð"ÝDÙ4Ó6‘
ð"Ý?Ù,¨UÓ3�
÷ R\ˆD×)Ñ)¨%¸XÔMÐaeð 	ð Ð%Ð%øô ô "Ø!’
ð"ûô ô "Ø!’
ð"ús$   ÂC Â)C) ÃC&Ã%C&Ã)C9Ã8C9r‰  Úincoming_originc               ó4   € V ^8„  d   QhRRRRRRRRRR	R
R	RR/# )r"   r)  r1  r^  r&   r#   r   Úkindr‰  rj   rŒ  r%   r$   r'   )r(   s   "r)   r*   rH   �  sF   € ÷ %ñ %Ø.ð%Ø>Að%ØMUð%Ø]`ð%à&ð%à@Mð%ð 
ñ%r+   c          
     ó"  a€ Ve   VP                  V4      MRpVf   R# VP                  p	\        ;QJ d    R Wg3 4       F  '       g   K   RM	  RM! R Wg3 4       4      oR V3R llp
RV
! W†4       RV
! W74       R	V	 R
2pVR8X  d3   VRV	 R2,           p\        P	                  RV
! W†4      V
! W74      W™4       M-VRR w  rÞVRV R2,           p\        P	                  RWƒW�WéV4       V P                  V RVP                   2RRV 2VR7       R# )zòLog + park a secondary adapter whose credential/listener another profile owns (True when
refused). NOT disconnected: it never connected, and for a same-credential Photon adapter
disconnect() would shut down the primary profile's live sidecar.NFc              3  ót   "  € T F.  p\        V\        4      ;'       d    VP                  R 4      x € K0  	  R# 5i)ru  N)r  r&   Ú
startswith)rˆ  Úorigins   & r)   rŠ  ÚGGatewayAdapterLifecycleMixin._refuse_duplicate_claim.<locals>.<genexpr>˜  s4   é € ð 
á9�ô �vœsÓ#×AÐA¨×(9Ñ(9¸&Ó(AÔAÛ9ùs   ‚8ž8Tc               ó$   € V ^8„  d   QhRRRRRR/# )r"   r{   r&   r’  rj   r%   r'   )r(   s   "r)   r*   ÚJGatewayAdapterLifecycleMixin._refuse_duplicate_claim.<locals>.__annotate__œ  s&   € ÷ 	Lñ 	L�sð 	L Mð 	L°cñ 	Lr+   c                ó8   <€ S'       d   V'       d	   V  R V R2# T # )z (rl   r'   )r{   r’  Úenv_deriveds   &&€r)   Ú_whoÚBGatewayAdapterLifecycleMixin._refuse_duplicate_claim.<locals>._whoœ  s   ø€ ß+6¿6�d�V˜2˜f˜X QÐ'ÐKÀtÐKr+   rb  z' and 'z' both configure Ú Ú
credentialz4with the same credential. Give each profile its own z credential.u¸   Profile '%s' and '%s' both configure %s with the same credential â€” refusing to start the duplicate (one credential cannot be consumed twice). Give each profile its own %s credential.zJsidecars on the same listener. Configure a distinct listener for profile 'z'.u°   Profile '%s' and '%s' both configure %s sidecars on %s:%s â€” refusing to start the duplicate listener. Set platforms.%s.extra.sidecar_port to a distinct port for profile '%s'.Ú:r  Ú
duplicate_r  éþÿÿÿ)r¶   r.   Úanyrc   rñ   r  )r8   r9  r)  r^  r#   rŽ  r‰  rŒ  r}  Úpvr˜  Úheadr/   ÚbindÚportr—  s   &&&&&&$$       @r)   Ú_refuse_duplicate_claimÚ4GatewayAdapterLifecycleMixin._refuse_duplicate_claim�  sR  ø€ ð ',Ò&7�—‘˜EÔ"¸TˆØŠ=ÙØ�^‰^ˆß“cñ 
à'Ñ9ó
—c—c’cñ 
à'Ñ9ó
ó 
ˆ÷	Lð 	Là™4 Ó4Ð5°W¹TÀ,Ó=`Ð<aÐarÐsuÐrvÐvwÐxˆØ�<ÔØÐSÐTVÐSWÐWcÐdÕdˆGÜ�L‰Lðpá�UÓ)©4°Ó+NÐPRõð ˜r˜s˜‰JˆDØÐiÐjvÐiwÐwyÐzÕzˆGÜ�L‰Lðeà R¨t¸ôð
 	×,Ñ,Øˆn˜A˜hŸn™nÐ-Ð.¸wØ# D 6Ð*¸'ð 	-ô 	
ñ r+   c               ó$   € V ^8„  d   QhRRRRRR/# ©r"   r^  r&   r#   r   r%   r\   r'   )r(   s   "r)   r*   rH   ´  s"   € ÷ 
ñ 
¸cð 
ÈXð 
ÐZ^ñ 
r+   c                ó”  € \        V RR4      pVf   \        4       ;q0n        W3V9   d   R# VP                  W34       VP                  pV\
        P                  J d9   RV R2p\        P                  RW4       V P                  V RV 2RRVR	7       R# \        P                  R
WWDV4       V P                  V RV 2RRRR	7       R# )zòReport unpaired WhatsApp or secondary-only Relay. Log the reason and remedy and stamp a
``<profile>:<platform>`` status entry so ``hermes gateway status --profile X`` and the
dashboard show *why* the channel is dead instead of nothing at all.Ú_unserved_secondary_platformsNz+WhatsApp is not paired; pair it: hermes -p z	 whatsappz[MULTIPLEX] Profile '%s': %srœ  r  Úwhatsapp_unpairedr  uô   [MULTIPLEX] Profile '%s': %s is enabled but not served â€” %s is process-level shared ingress owned by the default profile under multiplex. Enable and configure %s on the default profile (it serves every profile), or disable it in profile '%s'.Úmultiplex_shared_ingressz<not served under multiplex (shared ingress owned by default))
r¿   rK   r©  r  r.   r   ÚWHATSAPPrc   rt   r  )r8   r^  r#   Únotedr   r/   s   &&&   r)   Ú!_note_unserved_secondary_platformÚ>GatewayAdapterLifecycleMixin._note_unserved_secondary_platform´  sê   € ô ˜Ð=¸tÓDˆØŠ=Ü9<»Ð>ˆEÔ6ØÐ# uÔ,ÙØ�	‰	�<Ð*Ô+Ø�^‰^ˆØ”x×(Ñ(Ó(ØCÀLÀ>ÐQZÐ[ˆGÜ�K‰KÐ6¸ÔNØ×0Ñ0Ø�.  " Ð&°zØ.¸gð 1ô ñ Ü�‰ðHð ˜b lô		
ð 	×,Ñ,Øˆn˜A˜b˜TÐ"°:ÐJdØXð 	-ö 	
r+   c               ó   € V ^8„  d   QhRR/# )r"   r%   r°  r'   )r(   s   "r)   r*   rH   Ò  s   € ÷ ñ °4ñ r+   c           	     óÆ  a€ \        V RR4      ;'       g    Rp. p\        V UUu0 uF  w  r4VkK	  	  uppR R7       Fš  oS\        P                  J d   K  SV P                  9   g   S\        V RR4      ;'       g    / 9   d   KH  \        V3R lV 4       4      pVP                  SP                   RRP                  V4       R	SP                   R
24       Kœ  	  V# u uppi )z´Loud ``not being served`` lines for shared-ingress platforms secondaries enabled while
NO profile (default included) actually runs them; empty when the default serves the platform.r©  Nc                ó   € V P                   # r1  r-   )r‰  s   &r)   r4  ÚPGatewayAdapterLifecycleMixin._unserved_shared_ingress_warnings.<locals>.<lambda>×  s   € ÀQÇWÂWr+   )ÚkeyrÞ   c              3  ó<   <"  € T F  w  rVSJ g   K  Vx € K  	  R # 5ir1  r'   )rˆ  Únr‰  r#   s   &  €r)   rŠ  ÚQGatewayAdapterLifecycleMixin._unserved_shared_ingress_warnings.<locals>.<genexpr>Ü  s   øé € ÐC©E¡D A°Q¸(°]Ÿaša«Eùs   ƒ
’
z is enabled in profile(s) r†  uV    but not on the default profile â€” the platform is not being served. Under multiplex zd is shared ingress: enable and configure it on the default profile, or disable it in those profiles.r'   )r¿   rL  r   r¬  rô   Úappendr.   r™  )r8   r­  ÚlinesÚ_nr‰  rJ  r#   s   &     @r)   Ú!_unserved_shared_ingress_warningsÚ>GatewayAdapterLifecycleMixin._unserved_shared_ingress_warningsÒ  sã   ø€ ô ˜Ð=¸tÓD×JÐJÈˆØˆÜ©uÔ5©u¡e b£©uÒ5Ñ;L×MˆHØœ8×,Ñ,Ó,ÙØ˜4Ÿ=™=Ô(¨H¼ÀÐGZÐ\`Ó9a×9gÐ9gÐegÔ,hÙÜÔC©EÓCÓCˆHØ�L‰LØ—>‘>Ð"Ð"<¸T¿Y¹YÀxÓ=PÐ<Qð RQØQY×Q_ÑQ_ÐP`ð alðlöñ Nð ˆùó  6s   ¥C
c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r"   r^  r&   rn  r   r)  r1  r%   rÊ   r'   )r(   s   "r)   r*   rH   ä  s2   € ÷ `ñ `Øð`Ø/3ð`Ø>Nð`à	ñ`r+   c              ƒ  ó$	  "  € ^ RI HpHp V P                  W4      G Rj  x€L
 p\	        V RR4      pVf	   / ;qpn        WgV&   V P                  4       pV P                  P                  V/ 4      p	^ p
VP                  P                  4        EFj  w  r¼VP                  '       g   K  W¹9   g6   T\	        V RR4      ;'       g    / P                  V4      ;'       g    / 9   d   KW  V! VRR7      ;_uu_ 4        V! W¼4      pRRR4       V'       dP   X'       gH   V\        P                  J d   V P                  W4       \         P#                  RWP$                  4       KÑ  V'       d)   V\        P&                  J d   V P                  W4       EK  V'       d:   VP$                  \(        9   d%   \         P#                  RWP$                  V4       EKB  Rp\+        \,        P.                  R	VVP$                  R
R7      ;_uu_ 4        V! VRR7      ;_uu_ 4        V P1                  W¼4      pRRR4       V'       g!   \         P3                  RWP$                  4       RRR4       V'       g   EKÜ  V P5                  W¾4      pV P7                  W¾4      pVe   VP                  V4      MRpRRppV'       d   V P9                  VWW¾4      w  ppV P;                  WóWRVVR7      '       g   V P;                  VW1VR4      '       d   EKp  V P=                  WáV4        V! VRR7      ;_uu_ 4        V P?                  Wë4      G Rj  x€L
 pRRR4       X'       g"   \         P3                  RVP$                  V4       T'       g/   T PE                  Yë4      G Rj  x€L
  T PG                  YT4       EK  YéT&   T PI                  T4       TT3 F  pTf   K	  YT&   K  	  T
^,          p
\         P#                  RTP$                  T4       EKm  	  V
#  ELÛ  + '       g   i     EL; i  + '       g   i     ELø; i  + '       g   i     ELÜ; i EL  + '       g   i     EL; i  \@         d0   p\         PC                  RTP$                  TT4       Rp Rp?ELRp?ii ; i EL5i)z>Create+connect one profile's adapters under its runtime scope.©rÍ  rX  Nr  r  Fr^  zS[MULTIPLEX] Profile '%s': skipping %s - no bot credential in this profile's secretsuu   [MULTIPLEX] Profile '%s': %s is served by the default profile's listener at /p/%s/ â€” not starting a second listenerz9[MULTIPLEX] Profile '%s': _create_adapter('%s') raised %sTr´   zQ[MULTIPLEX] Profile '%s': skipping platform '%s' - adapter creation returned Noner›  )r‰  rŒ  Úlisteneru&   âœ— %s failed to connect (profile: %s)u   âœ— %s error (profile: %s): %su   âœ“ %s connected (profile: %s))%rŠ   rÍ  rX  rn  r¿   r  r   Ú_profile_adaptersÚ
setdefaultrÝ   r3  Úenabledr¶   r   r¬  r®  rc   rt   r.   ÚRELAYr   r   r`   rs   rÛ  rd   rÔ   rÕ   rŠ  r¤  Ú_configure_profile_adapterr®   rq   rñ   rf   Ú-_schedule_secondary_profile_startup_reconnectrí  )r8   r^  rn  r)  rÍ  rX  rl  r-  Ú	multiplexÚprofile_maprú  r#   rÖ   Úhas_credentialr^   rÑ   rÒ   Ú
owner_namer‰  rŒ  rã  rw   r9  s   &&&&                   r)   r%  Ú8GatewayAdapterLifecycleMixin._start_one_profile_adaptersä  sô  é € ÷ 	UØ ×?Ñ?ÀÓ[×[ˆô ˜$Ð 2°DÓ9ˆØŠ?Ø.0Ð0ˆGÔ+Ø +�ÑØ×&Ñ&Ó(ˆ	Ø×,Ñ,×7Ñ7¸ÀbÓIˆØˆ	Ø)4×)>Ñ)>×)DÑ)D×)FÑ%ˆHØ"×*×*Ð*Ùð Ô&¨(Ü˜TÐ#>ÀÓE×KÐKÈ×PÑPÐQ]Ó^×dÐdÐbdô+fáá'¨Àe×LÖLÙ!=¸hÓ!X�÷ Mç§Øœx×0Ñ0Ó0Ø×:Ñ:¸<ÔRÜ—‘ð0Ø1=¿~¹~ôñ ç˜X¬¯©Ó7Ø×6Ñ6°|ÔNÚ÷ ˜XŸ^™^Ô/OÔOÜ—‘ð5Ø6BÇNÁNÐT`ôò ØˆGÜ Ü—‘ÐZÐ\hØ—‘¨÷ö ñ ,¨LÈ%×PÖPØ"×2Ñ2°8ÓM�G÷ QçÜ—N‘NØkØ$§n¡nô÷÷ Úà#×=Ñ=¸hÓPÐØ!×9Ñ9¸(ÓLˆNØ:JÒ:V˜Ÿ™Ð%5Ô6Ð\`ˆJØ-1°4˜/ˆLßØ04×0RÑ0RØ ¸Hó1Ñ-�˜oð ×+Ñ+Ø ¨<À<Ø)¸?ð ,÷ ò ð ×-Ñ-¨n¸gÐU]Ð_i×jÒjÚØ×+Ñ+¨GÀ8ÔLð Ù+¨LÈ%×PÖPØ$(×$NÑ$NÈwÓ$a×a�G÷ QçÜ—N‘NÐ#KÈXÏ^É^Ð]iÔj÷ Ø×3Ñ3°GÓF×FÐFØ×BÑBÀ<Ð[bÔcÚØ$+˜Ñ!ð ×2Ñ2°7Ô;Ø*¨NÓ;�ØÔ$Ø%1˜E“Nñ <ð ˜�NˆIÜ�K‰KÐ8¸(¿.¹.È,×Wña *Gðb Ðòw \÷& M×LÐLú÷6 Q×PÐPú÷	÷ ð úò< b÷ Q×PÐPûô ô  Ü—‘Ð=¸x¿~¹~È|Ð]^Ô_Ø–ûð úò Gùsý   ‚RŸO: BRÂ>RÃRÃ2	O=Ã;RÄRÄARÅ"/RÆA+RÇ=P%ÈPÈ"P%È2 P%ÉRÉ"B)RÌQÌP<Ì3P9
Ì4P<Ì8QÍ!QÍ)RÍ1RÎRÎ6RÏ:RÏ=PÐ	RÐP"Ð	P%Ð%P6Ð0	RÐ9P<Ð<QÑ	QÑR
Ñ$RÑ?RÒR
Ò
RÚmessage_handlerÚfatal_error_handlerÚbusy_session_handlerÚauthorization_checkÚplatform_event_handlerÚbusy_text_modeÚbusy_text_timingÚhuman_delayc          
     ó,   € V ^8„  d   QhRRRRRRRRR	R
/# )r"   r^   r   rÑ  rj   rÒ  zOptional[tuple[float, float]]rÓ  z"Optional[tuple[int, int]] | objectr%   r\   r'   )r(   s   "r)   r*   rH   F  sE   € ÷ [ñ [Ø*ð[ð &ð[ð A^ð[ð 8ð	[ð
 
ñ[r+   c               ó®  € TP                  T;'       g    V P                  4       4       TP                  T;'       g    V P                  4       VP	                  V P
                  4       TP                  T;'       g    V P                  4       4       \        VRR4      p
\        V
4      '       d   V
! V P                  4       VP                  V P                  4       \        VRR4      p\        V4      '       d   V! V P                  4       TP                  T;'       g    V P                  VP                   4      4       TP#                  T;'       g    V P%                  4       4       Vf   V P&                  MTVn        T;'       g    \        V RR4      pV'       d   Vw  Vn        Vn        V	\,        J d   \        V RR4      Vn        R# T	Vn        R# )z¦Install the runner callbacks every adapter needs (defaults = primary handlers;
secondary wiring passes profile-scoped variants). ``set_reaction_handler`` is optional.Úset_reaction_handlerNÚset_topic_transfer_fnÚ_busy_text_timingÚ_human_delay)Úset_message_handlerÚ_primary_message_handlerÚset_fatal_error_handlerrÅ   Úset_session_storeÚsession_storeÚset_busy_session_handlerÚ_primary_busy_session_handlerr¿   Úcallabler¹   Úset_topic_recovery_fnÚ!_recover_telegram_topic_thread_idÚ_transfer_telegram_root_dmÚset_authorization_checkÚ_make_adapter_auth_checkr#   Úset_platform_event_handlerÚ_primary_platform_event_handlerÚ_busy_text_modeÚ_busy_text_debounce_secondsÚ_busy_text_hard_cap_secondsÚ_UNSETÚ_human_delay_range_ms)r8   r^   rÌ  rÍ  rÎ  rÏ  rÐ  rÑ  rÒ  rÓ  Ú_set_reactionÚ_set_transferÚtimings   &&$$$$$$$$   r)   rß  Ú3GatewayAdapterLifecycleMixin._wire_adapter_handlersF  sŠ  € ð 	×#Ñ# O×$VÐ$V°t×7TÑ7TÓ7VÔWØ×'Ñ'Ð(;×(_Ð(_¸t×?_Ñ?_Ô`Ø×!Ñ! $×"4Ñ"4Ô5Ø×(Ñ(Ð)=×)eÐ)eÀ×AcÑAcÓAeÔfÜ Ð)?ÀÓFˆÜ�M×"Ò"Ù˜$×5Ñ5Ô6Ø×%Ñ% d×&LÑ&LÔMÜ Ð)@À$ÓGˆÜ�M×"Ò"Ù˜$×9Ñ9Ô:Ø×'Ñ'Ø×RÐR 4×#@Ñ#@À×AQÑAQÓ#Rô	
ð 	×*Ñ*Ð+A×+kÐ+kÀT×EiÑEiÓEkÔlØ;IÒ;Q 4×#7Ò#7ÐWeˆÔØ!×MÐM¤W¨TÐ3FÈÓ%MˆßØW]ÑTˆGÔ/°Ô1Tà3>Ä&Ó3HŒG�D˜.¨$Ó/ð 	Ö%ØNYð 	Ö%r+   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(   s   "r)   r*   rH   d  s,   € ÷ (<ñ (<Ø*ð(<Ø:=ð(<ØIQð(<à	ñ(<r+   c                ó¼  € V RVP                    2Vn        \        VRR4      p\        V4      '       d	   V! V4       \        V RR4      p\        V RR4      p\        V RR4      pT P	                  TV P                  V4      V P                  W#4      V P                  V4      V P                  W2R7      V P                  V4      \        V\        4      '       d   VP                  W P                  4      MV P                  \        V\        4      '       d   VP                  V4      MR\        V\        4      '       d   VP                  V\        4      M\        R7	       V P                  V4       W!n        V P#                  4       '       dT   VP                   \$        9  d=   \'        VP                   \        \        VR	R4      R
R4      4      '       d	   W!n        R# R# R# R# )zDInstall the profile-scoped handlers shared by startup and reconnect.rœ  Úset_owner_profileNÚ_busy_text_modes_by_profileÚ_busy_text_timing_by_profileÚ_human_delay_by_profile)r^  )rÌ  rÍ  rÎ  rÏ  rÐ  rÑ  rÒ  rÓ  rÎ   Úextra)r.   Ú_runtime_status_platform_keyr¿   rá  rß  Ú_make_profile_message_handlerÚ!_make_profile_fatal_error_handlerÚ"_make_profile_busy_session_handlerræ  Ú$_make_profile_platform_event_handlerr  rÌ   r¶   ré  rì  rî  Ú_hermes_profile_namer   r   Ú_platform_binds_portÚ_shared_listener_profile)r8   r^   r^  r#   Ú
_set_ownerÚ
text_modesÚtimingsÚdelayss   &&&&    r)   rÅ  Ú7GatewayAdapterLifecycleMixin._configure_profile_adapterd  s¤  € ð
 3?°¸qÀÇÁÐ@PÐ/QˆÔ,ô ˜WÐ&9¸4Ó@ˆ
Ü�J×ÒÙ�|Ô$ô ˜TÐ#@À$ÓGˆ
Ü˜$Ð >ÀÓEˆÜ˜Ð8¸$Ó?ˆØ×#Ñ#ØØ ×>Ñ>¸|ÓLØ $× FÑ FÀ|Ó ^Ø!%×!HÑ!HÈÓ!VØ $× =Ñ =¸hÐ =Ó bØ#'×#LÑ#LÈ\Ó#Zô ˜j¬$×/Ò/ð —‘˜|×-AÑ-AÔBà×)Ñ)ä;EÀgÌt×;TÒ;T˜gŸk™k¨,Ô7ÐZ^Ü=GÈÔPT×=UÒ=U˜Ÿ™ L´&Ô9Ô[að 	$ô 	
ð  	×'Ñ'¨Ô0ð (4Ô$ð ×Ñ×Ò H§N¡NÔ:ZÔ$ZÜ(¨¯©¼ÄÈÐRZÐ\`ÓAaÐcjÐlpÓ9q×rÒrØ/;Ö,ñ sñ %[Ñr+   c               ó    € V ^8„  d   QhRRRR/# )r"   r^  r&   r#   r   r'   )r(   s   "r)   r*   rH   Ž  s   € ÷ )$ñ )$¸sð )$Èhñ )$r+   c              ƒ  óV  "  € ^ RI HpHp ^ RIHp ^ RIHp ^ RIHp V! V4      p	\        P                  ! Wy4      G Rj  x€L
  V! V	RR7      ;_uu_ 4        V! 4       P                  P                  V4      p
V
e   V
P                  '       g   RuuRRR4       # V! W*4      '       g.   \        P                  RVP                   V4       RuuRRR4       # V P#                  W*4      pVf.   \        P%                  R	VP                   V4       RuuRRR4       # \'        W;4        V P)                  W±V4       V P+                  W²R
R7      G Rj  x€L
 pY¼3uuRRR4       #  EL L  \,         d(    T P/                  Y²4      G Rj  x€L 
  \1        Y³4       h i ; i  + '       g   i     R# ; i5i)u
  One scoped attempt to rebuild+connect a secondary adapter â†’ ``(adapter, success)``;
``(None, None)`` = give up for good (disabled, credential removed, adapter unavailable). Caller
tears down a RETURNED adapter; one whose configure/connect raised is torn down here.r¿  r�  r[  rY  NFr^  z?Secondary %s reconnect skipped: no bot credential (profile: %s)zASecondary %s reconnect skipped: adapter unavailable (profile: %s)Tr£   rƒ  )rŠ   rÍ  rX  r"  r‚  rd  r\  rc  rZ  rL   re  rÝ   r¶   rÃ  rc   rt   r.   rÛ  rd   r   rÅ  rž   ÚBaseExceptionrf   r   )r8   r^  r#   rÓ   rÍ  rX  r‚  r\  rZ  rn  Úprofile_configr^   rã  s   &&&&         r)   Ú_secondary_reconnect_attemptÚ9GatewayAdapterLifecycleMixin._secondary_reconnect_attemptŽ  su  é € ÷ 	Uå7ÝHÝ6Ù& |Ó4ˆä×ÒÐ >ÓM×MÐMÙ# LÀ%×HÖHÙ0Ó2×<Ñ<×@Ñ@ÀÓJˆNØÒ%¨^×-C×-CÐ-CØ!÷ IÒHñ 0°×IÒIÜ—‘ØUØ—N‘N Lôð "÷ IÒHð ×*Ñ*¨8ÓDˆGØŠÜ—‘ØWØ—N‘N Lôð "÷' IÒHô(   Ô5ðØ×/Ñ/°ÀxÔPØ $× BÑ BÀ7ÐcgÐ BÓ h×h�ð Ð#÷; IÒHò 	Nñ0 iøÜ ô à×3Ñ3°GÓF×FÑFÜ& wÔ<Øð	ú÷1 I×HÐHüs‡   ‚<F)¾E¿F)Á6FÂFÂF)Â0FÃF)Ã7FÄ
F)ÄFÄ!(E Å	EÅ
E ÅFÅF)ÅE Å FÅ?F
Æ FÆFÆF&	Æ 	F)c               ó$   € V ^8„  d   QhRRRRRR/# r§  r'   )r(   s   "r)   r*   rH   ¹  s)   € ÷ Q8ñ Q8ØðQ8Ø+3ðQ8à	ñQ8r+   c           
   ƒ  ó`  "  € ^ RI HpHp ^ pR\        P                  ! 4       R^ /p\
        P                  ! 4       p V P                  '       Edõ   Rp	 V P                  WV4      G Rj  x€L
 w  ršV	f·    V P                  p\        V\        4      '       d   VP                  V4      MRp\        V\        4      '       di   VP                  V4      p\        V\
        P                  4      '       d   WØJ d1   VP                  VR4       V'       g   VP                  VR4       R# R# R# R# V
'       Edk   V P                  '       EdX   V P                  P!                  V/ 4      pW.9  Ed5   WžV&   \#        W94       V P%                  V	4       \&        P)                  RVP*                  V4       V P-                  W!R7      G Rj  x€L
  V P/                  4         V P1                  VR7        V P                  p\        V\        4      '       d   VP                  V4      MRp\        V\        4      '       di   VP                  V4      p\        V\
        P                  4      '       d   WØJ d1   VP                  VR4       V'       g   VP                  VR4       R# R# R# R# V P7                  W’4      G Rj  x€L
  \#        W“4       V
'       g'   \9        V	RR4      '       dÊ   \9        V	RR	4      '       g·    V P                  p\        V\        4      '       d   VP                  V4      MRp\        V\        4      '       di   VP                  V4      p\        V\
        P                  4      '       d   WØJ d1   VP                  VR4       V'       g   VP                  VR4       R# R# R# R# T P                  '       g·    T P                  p\        T\        4      '       d   TP                  T4      MRp\        T\        4      '       di   TP                  T4      p\        T\
        P                  4      '       d   YØJ d1   TP                  TR4       T'       g   TP                  TR4       R# R# R# R# T^,          pYgR&   T P=                  T4      pT P?                  \@        PB                  ! TRR7      T4      ;_uu_ 4        T PE                  Y'\        P                  ! 4       T RTP*                   2R7       RRR4       T! T4      p\&        P)                  RTP*                  TT4       \
        PF                  ! T4      G Rj  x€L
  EK   V P                  p\        V\        4      '       d   VP                  V4      MRp\        V\        4      '       di   VP                  V4      p\        V\
        P                  4      '       d   WØJ d1   VP                  VR4       V'       g   VP                  VR4       R# R# R# R#  EL’ EL?  \2         d(    \&        P5                  RTP*                  TR	R
7        ELKi ; i EL…  \:         dž   pT	eU   T P7                  Y’4      G Rj  x€L 
  T P                  P                  T/ 4      P                  T4      T	Jd   \#        Y“4       \        T\2        4      '       g   h \&        P5                  RTP*                  TR	R
7        Rp?EL7Rp?ii ; i  + '       g   i     ELû; i EL»  T P                  p\        T\        4      '       d   TP                  T4      MRp\        T\        4      '       df   TP                  T4      p\        T\
        P                  4      '       d   YØJ d/   TP                  TR4       T'       g   TP                  TR4       i i i i ; i5i)zDReconnect a retryable secondary adapter under its own profile scope.)rX  rÅ  rÐ   rÉ   Nu    âœ“ %s reconnected (profile: %s)rD  rü  zAresume-pending reschedule after %s reconnect failed (profile: %s)Tr´   rá  FrÜ   z3Secondary %s reconnect attempt failed (profile: %s)r^  rœ  )r´  z1Secondary %s reconnect retry in %ds (profile: %s))$rŠ   rX  rÅ  rn   ro   rL   r  r9  r
  r  r  rÌ   r¶   r  r  rÁ  rÂ  r   rí  rc   rt   r.   rÿ  rö  r  rq   rr   rf   r¿   r  Ú_routed_profile_homeÚ_scope_or_nullÚ	functoolsÚpartialr½  r8  )r8   r^  r#   rÓ   rX  rÅ  rÉ   Ú
queue_infor  r^   rã  ri  r  rE   rÈ  rœ   rn  r;  s   &&&&              r)   Ú _run_secondary_profile_reconnectÚ=GatewayAdapterLifecycleMixin._run_secondary_profile_reconnect¹  sƒ  é € ÷ 	KØˆà!¤4§>¢>Ó#3°ZÀÐCˆ
Ü×+Ò+Ó-ˆðH	8Ø—-—-‘-Ø�ð,Ø-1×-NÑ-NØ$°ó.÷ (Ñ$�Gð ’Øðr ×4Ñ4ˆGÜ;EÀgÌt×;TÒ;T˜gŸk™k¨,Ô7ÐZ^ˆOÜ˜/¬4×0Ò0Ø&×*Ñ*¨8Ó4�Ü! $¬¯©×5Ò5¸Ó9MØ#×'Ñ'¨°$Ô7ß*ØŸ™ L°$Ö7ñ +ñ :Nñ 1÷u �w 4§=§=¡=Ø&*×&<Ñ&<×&GÑ&GÈÐVXÓ&Y˜Ø#Õ6Ø4;¨Ñ1Ü2°;ÔHØ ×BÑBÀ7ÔKÜ"ŸK™KÐ(JÈHÏNÉNÐ\hÔiØ"&×"QÑ"QØ (ð #Ró #÷ ð ð
 !×AÑAÔCðZØ $× FÑ FÐPXÐ FÔ Yð #ðL ×4Ñ4ˆGÜ;EÀgÌt×;TÒ;T˜gŸk™k¨,Ô7ÐZ^ˆOÜ˜/¬4×0Ò0Ø&×*Ñ*¨8Ó4�Ü! $¬¯©×5Ò5¸Ó9MØ#×'Ñ'¨°$Ô7ß*ØŸ™ L°$Ö7ñ +ñ :Nñ 1ðK ×7Ñ7¸ÓJ×JÐJÜ*¨7Ô@ßÜ Ð):¸E×BÒBÜ '¨Ð1HÈ$× OÒ Oàð: ×4Ñ4ˆGÜ;EÀgÌt×;TÒ;T˜gŸk™k¨,Ô7ÐZ^ˆOÜ˜/¬4×0Ò0Ø&×*Ñ*¨8Ó4�Ü! $¬¯©×5Ò5¸Ó9MØ#×'Ñ'¨°$Ô7ß*ØŸ™ L°$Ö7ñ +ñ :Nñ 1ð' —}—}�}Øð  ×4Ñ4ˆGÜ;EÀgÌt×;TÒ;T˜gŸk™k¨,Ô7ÐZ^ˆOÜ˜/¬4×0Ò0Ø&×*Ñ*¨8Ó4�Ü! $¬¯©×5Ò5¸Ó9MØ#×'Ñ'¨°$Ô7ß*ØŸ™ L°$Ö7ñ +ñ :Nñ 1ð# ˜A•�Ø)1˜:Ñ&Ø#×8Ñ8¸ÓF�à×(Ñ(Ü!×)Ò)Ð*@ÐRWÔXÐZf÷hõ hà×8Ñ8Ø ¬d¯nªnÓ.>ÈlÈ^Ð[\Ð]e×]kÑ]kÐ\lÐKmð 9ô o÷hñ -¨XÓ6�Ü—‘ØGÈÏÉÐY`Ðbnôô —m’m GÓ,×,Ó,ð{  ð@ ×4Ñ4ˆGÜ;EÀgÌt×;TÒ;T˜gŸk™k¨,Ô7ÐZ^ˆOÜ˜/¬4×0Ò0Ø&×*Ñ*¨8Ó4�Ü! $¬¯©×5Ò5¸Ó9MØ#×'Ñ'¨°$Ô7ß*ØŸ™ L°$Ö7ñ +ñ :Nñ 1ò(òøô $-ô ZÜ &§¡Ð-pØ-5¯^©^¸\ÐTXð !-÷ !ZðZúò Køô %ô 
ØÒ*Ø"×;Ñ;¸GÓN×NÑNØ×1Ñ1×5Ñ5°lÀBÓG×KÑKÈHÓUÐ]dÓdÜ2°7ÔHÜ% c¬9×5Ò5ØÜ—L‘LØMÈxÏ~É~Ø$¨tð !÷ ò ûð
ú÷"h÷ hð húò -øð ×4Ñ4ˆGÜ;EÀgÌt×;TÒ;T˜gŸk™k¨,Ô7ÐZ^ˆOÜ˜/¬4×0Ò0Ø&×*Ñ*¨8Ó4�Ü! $¬¯©×5Ò5¸Ó9MØ#×'Ñ'¨°$Ô7ß*ØŸ™ L°$Õ7ð +ð :Nð 1üs.  ‚9^.¼[9 Á[9 ÁX7 Á'W9Á(
X7 Á3B^.Ä^.Ä(X7 Ä1X7 ÅA9X7 Æ=W<Æ>X7 ÇW? Ç&B^.Ê^.ÊX7 Ê/X4Ê0=X7 Ë.B^.Î	^.Î#[9 Î6B^.Ñ^.Ñ+A[9 Ò97["Ó0A[9 Ô;[6Ô<[9 ÕB^.×^.×9X7 ×<X7 ×?.X1Ø-X7 Ø0X1Ø1X7 Ø7[Ù[ÙYÙA9[Û[9 Û[Û[9 Û"[3	Û-
[9 Û9B^+Þ^+Þ+^.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(   s   "r)   r*   rH     s,   € ÷ *ñ *Øð*Ø+3ð*Ø>Qð*à	ñ*r+   c           	     óÞ  a aaaa€ \        SRR4      '       g   R# \        \        SRR4      4      '       de   \        P                  RSSP                  SP
                  SP                  ;'       g    R4       S P                  S RSP                   2S4       R# R VVVV 3R	 lloR
 VV 3R llpS P                  \        P                  ! V! 4       RS RSP                   2R7      4       R# )z¤Queue a cold-start reconnect: startup failures happen BEFORE ``_running`` flips True (the
regular scheduler would drop them), so park a task and hand off once live.rÜ   TNr
  uc   [MULTIPLEX] Profile '%s': %s credential is held by another gateway (%s) â€” parked, not retried. %srm   rœ  c               ó   € V ^8„  d   QhRR/# r[   r'   )r(   s   "r)   r*   Ú`GatewayAdapterLifecycleMixin._schedule_secondary_profile_startup_reconnect.<locals>.__annotate__  s   € ÷ 	ñ 	˜$ñ 	r+   c                 ó–   <€  SP                  SSS 4       R#   \         d&    \        P                  R SSP                  4        R# i ; i)zCsecondary-startup-reconnect handoff failed (profile=%s platform=%s)N)Ú%_schedule_secondary_profile_reconnectrq   rc   rì   r.   )r^   r#   r^  r8   s   €€€€r)   Ú_handoffÚ\GatewayAdapterLifecycleMixin._schedule_secondary_profile_startup_reconnect.<locals>._handoff  sD   ø€ ðØ×:Ñ:¸<ÈÐSZÖ[øÜô ä× Ñ ØYØ  (§.¡.÷ðús   ƒ ˜,AÁAc               ó   € V ^8„  d   QhRR/# r[   r'   )r(   s   "r)   r*   r  )  s   € ÷ 	ñ 	°Dñ 	r+   c               “  óh  <"  € SP                   '       d
   S ! 4        R # SP                   '       gA   SP                  P                  4       '       g!   \        P                  ! R4      G R j  x€L
  KR  SP                   '       d,   SP                  P                  4       '       g
   S ! 4        R # R # R #  LE5i)Ngš™™™™™¹?)r9  rí   rõ   rL   r8  )r  r8   s   €€r)   Ú_await_running_then_scheduleÚpGatewayAdapterLifecycleMixin._schedule_secondary_profile_startup_reconnect.<locals>._await_running_then_schedule)  su   øé € Ø�}�}ˆ}Ù”
Ùà—m—m�m¨D×,@Ñ,@×,GÑ,G×,IÒ,IÜ—m’m CÓ(×(Ò(Ø�}�}ˆ} T×%9Ñ%9×%@Ñ%@×%BÒ%BÙ–
ñ &C‰}ñ )ùs(   ƒ-B2±B2ÁB2Á*B0Á+B2ÂB2Â#B2zsecondary-startup-reconnect:©r{   )r¿   r   rc   rñ   r.   r
  r  rÁ  r  rL   rÂ   )r8   r^  r#   r^   r   r  s   ffff @r)   rÆ  ÚJGatewayAdapterLifecycleMixin._schedule_secondary_profile_startup_reconnect  sÑ   ü€ ô
 �wÐ 7¸×>Ò>ÙÜ%¤g¨gÐ7IÈ4Ó&P×QÒQä�L‰Lð;Ø<HÈ(Ï.É.Ø×(Ñ(¨'×*EÑ*E×*KÐ*KÈôð ×%Ñ%¨¨°a¸¿¹Ð7GÐ&HÈ'ÔRÙ÷	ó 	÷	ñ 	ð 	×$Ñ$¤W×%8Ò%8Ù(Ó*Ø/°¨~¸Q¸x¿~¹~Ð>NÐOô&
ö 	r+   c               ó(   € V ^8„  d   QhRRRRRRRR/# r  r'   )r(   s   "r)   r*   rH   8  s,   € ÷ ñ ØðØ+3ðØ>Qðà	ñr+   c           	     ól  € V P                   '       d   VP                  '       g   R# V P                  p\        V\        4      '       g	   / ;q@n        VP                  V/ 4      pW%9   d   R# V P                  \        P                  ! V P                  WV4      RV RVP                   2R7      4      WR&   R# )zDSchedule one runner-owned reconnect without sharing primary secrets.Nzsecondary-reconnect:rœ  r"  )r9  rÜ   r  r  rÌ   rÂ  r  rL   rÂ   r  r.   )r8   r^  r#   r^   ri  r  s   &&&&  r)   r  ÚBGatewayAdapterLifecycleMixin._schedule_secondary_profile_reconnect8  sŸ   € ð �}�}ˆ} G×$A×$AÐ$AÙØ×0Ñ0ˆÜ˜'¤4×(Ò(Ø79Ð9ˆGÔ4Ø!×,Ñ,¨\¸2Ó>ˆØÔ&ÙØ$(×$@Ñ$@Ä×ATÒATØ×1Ñ1°,È'ÓRØ'¨ ~°Q°x·~±~Ð6FÐGôB
ó %ˆÓ!r+   c               ó$   € V ^8„  d   QhRRRRRR/# )r"   r^  r&   r#   r   r%   z0Callable[[BasePlatformAdapter], Awaitable[None]]r'   )r(   s   "r)   r*   rH   I  s)   € ÷ cñ cØðcØ+3ðcà	9ñcr+   c                óD   € \         P                  ! V P                  W4      # )zGRoute a secondary-profile fatal error to that profile's reconnect slot.)r  r  Ú#_handle_profile_adapter_fatal_error)r8   r^  r#   s   &&&r)   rû  Ú>GatewayAdapterLifecycleMixin._make_profile_fatal_error_handlerI  s   € ô × Ò  ×!IÑ!IÈ<ÓbÐbr+   c               ó(   € V ^8„  d   QhRRRRRRRR/# r  r'   )r(   s   "r)   r*   rH   O  s,   € ÷ 
ñ 
Øð
Ø+3ð
Ø>Qð
à	ñ
r+   c              ƒ  óB  "  € \        V R/ 4      P                  V4      p\        V\        4      '       d   VP                  V4      VJd$   \        P                  RVP                  V4       R# VP                  VR4       V P                  V4      ;p\        Jd   \        W5R7       V P                  W24      G Rj  x€L
  V P                  '       g   R# V P                  WV4       \        P                  RVP                  TVP                  ;'       g    R4       R#  Lb5i)zRRemove a failed multiplexed adapter (the primary-only fatal handler ignores them).rÁ  zBIgnoring stale fatal error from secondary %s adapter (profile: %s)N)Úhermes_homez6Fatal %s adapter error for multiplexed profile %s (%s)r  )r¿   r¶   r  rÌ   rc   rr   r.   r  r  ÚUNRESOLVED_PROFILE_HOMEr   rf   r9  r  rñ   r
  )r8   r^  r#   r^   rÈ  rn  s   &&&&  r)   r)  Ú@GatewayAdapterLifecycleMixin._handle_profile_adapter_fatal_errorO  sé   é € ô ˜dÐ$7¸Ó<×@Ñ@ÀÓNˆÜ˜+¤t×,Ò,°·±ÀÓ0IÐQXÓ0XÜ�L‰LØTØ—‘ ôñ Ø�‰˜ $Ô'à ×5Ñ5°lÓCÐCˆLÔLcÓcÜ& wÕIØ×+Ñ+¨GÓ>×>Ð>Ø�}�}ˆ}ÙØ×2Ñ2°<È7ÔSÜ�‰ØDÀhÇnÁnÐVbØ×$Ñ$×1Ð1¨	ö	
ñ	 	?ùs   ‚B8DÂ:DÂ;DÃADÄ
Dc               ó   € V ^8„  d   QhRR/# ©r"   r^  r&   r'   )r(   s   "r)   r*   rH   h  s   € ÷ +ñ +¨3ñ +r+   c                ó~   € ^ RI Hp  V! V 4      #   \         d"    \        P	                  RT RR7       \
        u # i ; i)ay  A named routed profile's home, or :data:`UNRESOLVED_PROFILE_HOME` when it does not
resolve (deleted or renamed mid-run, invalid name, transient OSError).

Never ``None``: ``None`` is reserved for "this body is the launch profile's own work", and
answering it for an unresolvable NAMED profile is what made a secondary's inbound message
run on the launch profile's credentials.
r�  z—Profile home for '%s' does not resolve; its handlers run with no profile scope (credential reads fail closed instead of borrowing the launch profile's)Tr´   )r"  r‚  rq   rc   rd   r.  )r^  r‚  s   & r)   r  Ú1GatewayAdapterLifecycleMixin._routed_profile_homeg  sJ   € õ 	8ð	+Ù" <Ó0Ð0øÜô 	+Ü�N‰Nð[à tð ô -ô +Ò*ð	+ús   ˆ �)<»<c                ór   € V\         J d   \        P                  ! 4       # Ve	   V ! V4      # ^ RIHp V! 4       # )u+  The runtime scope for one body, by what ``profile_home`` IS:

* a home â€” that profile's scope;
* ``None`` â€” no routed profile: the LAUNCH profile's own work, so bind the launch profile
  explicitly once this process multiplexes. A bare ``nullcontext()`` made the launch
  profile the one tenant running on ambient ``os.environ`` and the process home, which a
  secondary's context may have poisoned; under the one-process-per-host ruling it is a
  tenant like any other. Single-profile hosts are unchanged (no-op until activation);
* :data:`UNRESOLVED_PROFILE_HOME` â€” a NAMED profile whose home is gone: bind nothing, so an
  unscoped ``get_secret`` raises ``UnscopedSecretError`` under multiplexing. A profile never
  borrows another profile's value, and "we cannot tell whose this is" must fail closed.
)Ú#launch_profile_scope_if_multiplexed)r.  Ú
contextlibÚnullcontextÚ!tui_gateway.launch_profile_policyr5  )Úscope_factoryrn  r5  s   && r)   r  Ú+GatewayAdapterLifecycleMixin._scope_or_nullz  s9   € ð Ô2Ó2Ü×)Ò)Ó+Ð+ØÒ#Ù  Ó.Ð.ÝYÙ2Ó4Ð4r+   c                ór   € V\         J d   \        P                  ! 4       # Ve	   V ! V4      # ^ RIHp V! 4       # )zU``async with`` twin of :meth:`_scope_or_null` (for ``_async_profile_runtime_scope``).)Ú)async_launch_profile_scope_if_multiplexed)r.  r6  r7  r8  r<  )r9  rn  r<  s   && r)   rm  Ú1GatewayAdapterLifecycleMixin._async_scope_or_null�  s9   € ð Ô2Ó2Ü×)Ò)Ó+Ð+ØÒ#Ù  Ó.Ð.Ý_Ù8Ó:Ð:r+   Útransport_profileÚprimary_homec               ó    € V ^8„  d   QhRRRR/# )r"   r>  rj   r?  úOptional[Path]r'   )r(   s   "r)   r*   rH   ™  s   € ÷ ñ ¸-ð Ø$2ñr+   c               ó4  € Vf   R# ^ RI Hp  V! WW#R7      pT'       d<   \        TRR4      '       g)   \        \        4      ;_uu_ 4        Y!n        RRR4       T# T#   \         d    \        P	                  RRR7        R# i ; i  + '       g   i     T# ; i)u§  Runner-side identity seam: the pinned :class:`RoutingIdentity` of *source*, resolving it
once when absent. ``transport_profile`` names a secondary's own bot (its handlers know it by
construction); ``None`` = the primary/shared bot. ``None`` result = rejected route under
multiplexing (the caller drops; the ingress gate warns once) or a source that cannot resolve
(bare test rigs) â€” the legacy readers then stay in force.N)Úcanonical_identity)Úrunnerr>  r?  z8identity resolution failed; legacy readers stay in forceTr´   rh   )Úgateway.session_identityrC  rq   rc   rr   r¿   r   rh   )r8   Úsourcer>  r?  rC  Úidentitys   &&$$  r)   Ú_canonicalizeÚ*GatewayAdapterLifecycleMixin._canonicalize™  sŠ   € ð Š>ÙÝ?ð	Ù)ØÐ7HôeˆH÷
 ¤W¨V°YÀ×%EÒ%EÜœ)×$Õ$Ø!2”÷ %àˆˆxˆøô ô 	Ü�L‰LÐSÐ^bˆLÔcÚð	ú÷ %Ö$àˆús   Ž
A Á
BÁ"BÂBÂB	c               ó   € V ^8„  d   QhRR/# r1  r'   )r(   s   "r)   r*   rH   ®  s   € ÷ &ñ &¸#ñ &r+   c                ó´   a aaaaa€ ^ RI Ho S P                  S4      o^ RIHoHp S\        J d   RMSoV! S SS4       VVVVV V3R lpVP                  S 4      # )z¾Message handler that canonicalizes the event's identity FIRST, then delegates under the
profile scope (auth runs BEFORE the agent-turn scope, so the profile's ``.env`` must be
visible here).©rP  )Únative_callbackÚregister_transport_homeNc           
   “  óÌ  <"  € SP                  \        VR R4      SR7       Se   SVP                  n        S! SVSS4      ;_uu_ 4        SP	                  SS4      ;_uu_4       GRj  x€L
  SP                  V4      G Rj  x€L
 uuRRR4      GRj  x€L
  uuRRR4       #  L9 L" L  + GRj  x€L 
 '       g   i     M; i RRR4       R#   + '       g   i     R# ; i5i)rF  N©r>  )rH  r¿   rF  Ú_authorization_profile_homerm  Ú_handle_message)Ú_runnerÚeventrP  rM  rn  r^  r8   Útransport_homes   &&€€€€€€r)   Ú_handlerÚLGatewayAdapterLifecycleMixin._make_profile_message_handler.<locals>._handlerº  s¬   øé € Ø×Ñœw u¨h¸Ó=ÐQ]ÐÔ^ØÒ)Ø;I�—‘Ô8Ù   u¨n¸l×KÕKØ×4Ñ4Ð5QÐS_×`×`Õ`Ø!%×!5Ñ!5°eÓ!<×<÷ a×`Ñ`÷ LÒKÙ`Ù<÷ a×`×`Ò`úÐ`÷ L×K×KÒKüs„   ƒAC$Á
CÁ)B#Á*CÁ-B)	ÂB%ÂB)	ÂCÂB'
ÂCÂC$Â#CÂ%B)	Â'CÂ)CÂ/B2Â0
CÂ;CÂ=CÃ
C$ÃC!	Ã	C$)rŠ   rP  r  Úgateway.session_ingress_contextrM  rN  r.  Ú__get__)r8   r^  rN  rV  rP  rM  rn  rU  s   ff  @@@@r)   rú  Ú:GatewayAdapterLifecycleMixin._make_profile_message_handler®  sU   ý€ õ 	=Ø×0Ñ0°Ó>ˆß\ð ".Ô1HÓ!H™ÈlˆÙ  l°NÔC÷	=ò 	=ð ×Ñ Ó%Ð%r+   c               ó   € V ^8„  d   QhRR/# r1  r'   )r(   s   "r)   r*   rH   Ä  s   € ÷ ñ ¸sñ r+   c                óN   a aaa€ ^ RI Ho S P                  S4      oVVVV 3R lpV# )z¬Busy-path twin: canonicalize FIRST, then resolve busy policy under the profile scope
(auth runs against the profile's own allowlist, same as the cold-path message handler).rL  c              “  ó\  <"  € SP                  V P                  SR 7       SP                  SS4      ;_uu_4       GRj  x€L
  SP                  V SP	                  V P                  4      4      G Rj  x€L
 uuRRR4      GRj  x€L
  #  LI L L	  + GRj  x€L 
 '       g   i     R# ; i5i©rP  N)rH  rF  rm  Ú#_handle_active_session_busy_messageÚ_session_key_for_source)rT  Ú_session_keyrP  rn  r^  r8   s   &&€€€€r)   rV  ÚQGatewayAdapterLifecycleMixin._make_profile_busy_session_handler.<locals>._handlerÊ  sw   øé € Ø×Ñ˜uŸ|™|¸|ÐÔLØ×0Ñ0Ð1MÈ|×\×\Õ\Ø!×EÑEÀeÈT×MiÑMiÐjo×jvÑjvÓMwÓx×x÷ ]×\Ô\Ùx÷ ]×\×\Ó\üs^   ƒ<B,¿B	Á B,Á/BÁ2BÁ3BÁ6B,ÂBÂB,ÂBÂB,ÂB)	ÂBÂ
B)	Â!B)	Â#	B,)rŠ   rP  r  )r8   r^  rV  rP  rn  s   ff @@r)   rü  Ú?GatewayAdapterLifecycleMixin._make_profile_busy_session_handlerÄ  s+   û€ õ 	=Ø×0Ñ0°Ó>ˆ÷	yð 	yð
 ˆr+   c                óŠ   a aa€ ^ RI HoHp \        V! 4       4      o^ RIHp V! S RS4       VVV 3R lpVP                  S 4      # )z¥Scope primary-adapter messages to their routed multiplex profile. Authorization stays
with the transport profile (a routed profile may have no credential/allowlist).©rP  rI  )rN  Nc           
   “  ó¨  <"  € SP                  VP                  S4      ;'       g    Sp^ RIHp V! SVS4      ;_uu_ 4        S! V4      ;_uu_4       GRj  x€L
  SP	                  V4      G Rj  x€L
 uuRRR4      GRj  x€L
  uuRRR4       #  L9 L" L  + GRj  x€L 
 '       g   i     M; i RRR4       R#   + '       g   i     R# ; i5i)é    )rM  N)Ú_admit_primary_sourcerF  rX  rM  rR  )rS  rT  rn  rM  rP  Údefault_homer8   s   &&  €€€r)   rV  ÚTGatewayAdapterLifecycleMixin._make_default_profile_message_handler.<locals>._handlerÙ  s‘   øé € à×5Ñ5°e·l±lÀLÓQ×aÐaÐUaˆLÝGÙ   u¨l×;Õ;Ù7¸×E×EÕEØ!%×!5Ñ!5°eÓ!<×<÷ F×EÑE÷ <Ò;ÙEÙ<÷ F×E×EÒEúÐE÷ <×;×;Ò;üsƒ   ƒ?CÁB>ÁBÁB>ÁB	Á0BÁ1B	Á4B>ÂB
ÂB>ÂCÂB>ÂB	ÂB>ÂB0ÂB Â
B0Â)B0Â+B>Â4
CÂ>C	Ã		C)rŠ   rP  rI  r   rX  rN  rY  )r8   rI  rN  rV  rP  ri  s   f   @@r)   Ú%_make_default_profile_message_handlerÚBGatewayAdapterLifecycleMixin._make_default_profile_message_handlerÑ  s=   ú€ ÷ 	NÜ™OÓ-Ó.ˆÝKÙ  d¨LÔ9÷	=ð ×Ñ Ó%Ð%r+   c                óL   a aa€ ^ RI HoHp \        V! 4       4      oVVV 3R lpV# )zÿBusy-path twin of ``_make_default_profile_message_handler``: busy callbacks bypass the message
handler, so the routed scope and transport-home authorization must be re-established here or the
follow-up is authorized in whatever scope is ambient (#103717).re  c              “  óB  <"  € V P                   pSP                  VS4      pVf   R# S! V4      ;_uu_4       GR j  x€L
  SP                  V SP                  V4      4      G R j  x€L
 uuR R R 4      GR j  x€L
  #  L? L L	  + GR j  x€L 
 '       g   i     R # ; i5i)NT)rF  rh  r_  r`  )rT  ra  rF  rn  rP  ri  r8   s   &&  €€€r)   rV  ÚYGatewayAdapterLifecycleMixin._make_default_profile_busy_session_handler.<locals>._handlerê  s{   øé € Ø—\‘\ˆFØ×5Ñ5°f¸lÓKˆLØÒ#ÙÙ3°L×A×AÕAØ!×EÑEØ˜4×7Ñ7¸Ó?ó÷ ÷ B×AÔAñ÷ B×A×AÓAüs]   ƒ9B¼A<½BÁ %BÁ%A>Á&BÁ)BÁ6B Á7BÁ>BÂ BÂB	ÂBÂ	
B	ÂB	Â	B)rŠ   rP  rI  r   )r8   rI  rV  rP  ri  s   f  @@r)   Ú*_make_default_profile_busy_session_handlerÚGGatewayAdapterLifecycleMixin._make_default_profile_busy_session_handlerã  s"   ú€ ÷ 	NÜ™OÓ-Ó.ˆ÷	ð ˆr+   c               ó    € V ^8„  d   QhRRRR/# )r"   ri  r   r%   rA  r'   )r(   s   "r)   r*   rH   ö  s   € ÷ bñ b¸$ð bÀ>ñ br+   c                óp   € V P                  WR7      pVe   VP                  # \        VRR4      RJ d   R# T# )uë   Canonicalize a primary-adapter source (transport home for authorization, routed profile
for the runtime) and return the runtime home to scope the turn under; ``None`` when the
route targets an unserved profile. Route â‰  admitting bot.©r?  NÚprofile_route_rejectedFT)rH  Úruntime_homer¿   )r8   rF  ri  rG  s   &&& r)   rh  Ú2GatewayAdapterLifecycleMixin._admit_primary_sourceö  sF   € ð ×%Ñ% fÐ%ÓHˆØÒØ×(Ñ(Ð(Ü˜vÐ'?ÀÓGÈ4ÓOˆtÐaÐUaÐar+   c                ó²   € \        V RR4      RJpV P                  4       '       g	   V'       d   V P                  4       # V P                  V P                  4      # )z:Return the correctly scoped handler for a primary adapter.Úsession_authorityN)r¿   r   rk  Ú_standalone_scopedrR  )r8   Úshareds   & r)   rÛ  Ú5GatewayAdapterLifecycleMixin._primary_message_handlerÿ  sM   € ä˜Ð2°DÓ9ÀÐEˆØ×Ñ×Ò§6Ø×=Ñ=Ó?Ð?Ø×&Ñ& t×';Ñ';Ó<Ð<r+   c                ó„   € V P                  4       '       d   V P                  4       # V P                  V P                  4      # )zGReturn the correctly scoped busy-session handler for a primary adapter.)r   rp  rz  r_  r7   s   &r)   rà  Ú:GatewayAdapterLifecycleMixin._primary_busy_session_handler  s7   € à×Ñ×ÒØ×BÑBÓDÐDØ×&Ñ& t×'OÑ'OÓPÐPr+   c                ó(   a aa€ ^ RI Ho VVV 3R lpV# )a®  Standalone twin of the ``_make_default_profile_*`` wrappers: run ``handler`` under
``_standalone_launch_scope`` so slash commands and turns keep resolving the launch profile's
credentials after a hosted room flipped the process-wide guard (#112878). The credential
body is marked at entry (``launch_body``): a turn already running when a second profile
switches this gateway to multiplexing keeps resolving its launch credentials.)Úlaunch_bodyc            	   —  ó  <"  € S! 4       ;_uu_ 4        SP                  4       ;_uu_ 4        S! V !  G R j  x€L
 uuR R R 4       uuR R R 4       #  L  + '       g   i     M; iR R R 4       R #   + '       g   i     R # ; i5ir1  )Ú_standalone_launch_scope)ÚargsÚhandlerr€  r8   s   *€€€r)   rV  ÚAGatewayAdapterLifecycleMixin._standalone_scoped.<locals>._handler  sG   øé € Ù—• × =Ñ =× ?Õ ?Ù$ d™^×+÷ !@Ñ ?—’Ù+÷ !@× ?ú———’üsH   ƒB“A.¬
A	¶A·A	º
A.ÁBÁA	ÁA!ÁA.Á$
BÁ.A?	Á9	B)r8  r€  )r8   r„  rV  r€  s   ff @r)   rz  Ú/GatewayAdapterLifecycleMixin._standalone_scoped  s   ú€ õ 	B÷	,ð ˆr+   c               ó   € V ^8„  d   QhRR/# rª   r'   )r(   s   "r)   r*   rH     s   € ÷ Gñ G˜tñ Gr+   c                	óB   € \        \        V P                  R R4      4      # )Úmultiplex_profilesF)r$   r¿   rÎ   r7   s   &r)   r   Ú*GatewayAdapterLifecycleMixin._multiplex_on  s   € Ü”G˜DŸK™KÐ)=¸uÓEÓFÐFr+   c               ó    € V ^8„  d   QhRRRR/# )r"   rT  rÌ   r%   r\   r'   )r(   s   "r)   r*   rH     s   € ÷ ?ñ ?¸$ð ?È4ñ ?r+   c              ƒ  óú   "  € \        \        P                  RRR7      ;_uu_ 4        ^ RIHpHp V! R4      '       d    V P                  V4      '       d	   V! R/ VB  RRR4       R#   + '       g   i     R# ; i5i)zCAuthorize and publish one normalized adapter event to plugin hooks.z+gateway_platform_event hook dispatch failedTr´   )Úhas_hookÚinvoke_hookÚgateway_platform_eventN)r�  )r   r`   ra   Úhermes_cli.lifecycler�  rŽ  Ú_is_user_authorized_for_source)r8   rT  rF  r�  rŽ  s   &&&  r)   Ú_handle_gateway_platform_eventÚ;GatewayAdapterLifecycleMixin._handle_gateway_platform_event  sV   é € ô œWŸ]™]Ð,YÐdh×iÖißBÙÐ0×1Ò1°d×6YÑ6YÐZ`×6aÒ6aÙÑ>¸Ò>÷ j×i×iÒiüs"   ‚%A;§-A'ÁA'Á
A;Á'A8	Á2	A;c               ó   € V ^8„  d   QhRR/# r1  r'   )r(   s   "r)   r*   rH   %  s   € ÷ 
ñ 
Àñ 
r+   c                óN   a aaa€ ^ RI Ho S P                  S4      oVVVV 3R lpV# )zDBind platform-event auth and hook dispatch to one multiplex profile.©rX  c              “  óÚ   <"  € SP                  VSR 7       SP                  SS4      ;_uu_ 4        SP                  W4      G Rj  x€L
 uuRRR4       #  L  + '       g   i     R# ; i5ir^  )rH  r  r’  )rT  rF  rX  rn  r^  r8   s   &&€€€€r)   rV  ÚSGatewayAdapterLifecycleMixin._make_profile_platform_event_handler.<locals>._handler*  sV   øé € Ø×Ñ˜v¸ÐÔFØ×$Ñ$Ð%;¸\×JÕJØ!×@Ñ@ÀÓO×O÷ KÒJÙO÷ K×JÐJüs.   ƒ.A+±AÁAÁAÁ
A+ÁAÁA(	Á"	A+)rŠ   rX  r  )r8   r^  rV  rX  rn  s   ff @@r)   rý  ÚAGatewayAdapterLifecycleMixin._make_profile_platform_event_handler%  s)   û€ å6Ø×0Ñ0°Ó>ˆ÷	Pð 	Pð
 ˆr+   c                óL   a aa€ ^ RI HoHp \        V! 4       4      oVVV 3R lpV# )zAScope primary-transport events to their routed multiplex profile.)rX  rI  c              “  óÐ   <"  € SP                  VS4      pVf   R # S! V4      ;_uu_ 4        SP                  W4      G R j  x€L
 uuR R R 4       #  L  + '       g   i     R # ; i5ir1  )rh  r’  )rT  rF  rn  rX  ri  r8   s   && €€€r)   rV  Ú[GatewayAdapterLifecycleMixin._make_default_profile_platform_event_handler.<locals>._handler6  sS   øé € Ø×5Ñ5°f¸lÓKˆLØÒ#ÙÙ'¨×5Õ5Ø!×@Ñ@ÀÓO×O÷ 6Ò5ÙO÷ 6×5Ð5üs.   ƒ)A&¬AÁAÁAÁA&ÁAÁA#	Á	A&)rŠ   rX  rI  r   )r8   rI  rV  rX  ri  s   f  @@r)   Ú,_make_default_profile_platform_event_handlerÚIGatewayAdapterLifecycleMixin._make_default_profile_platform_event_handler1  s    ú€ çGÜ™OÓ-Ó.ˆ÷	Pð ˆr+   c                	ó„   € V P                  4       '       d   V P                  4       # V P                  V P                  4      # r1  )r   r�  rz  r’  r7   s   &r)   rè  Ú<GatewayAdapterLifecycleMixin._primary_platform_event_handler?  s7   € Ø×Ñ×ÒØ×DÑDÓFÐFØ×&Ñ& t×'JÑ'JÓKÐKr+   c               ó$   € V ^8„  d   QhRRRRRR/# ©r"   r#   r   r^   r   r%   zOptional[tuple]r'   )r(   s   "r)   r*   rH   E  s&   € ÷ Hñ H¨Hð H¸sð HÀñ Hr+   c                óD   € ^ RI Hp VP                  ! V4      pVf   R# W3# )z?Return the exclusive credential resource claimed by an adapter.r   N)rŠ   r   r4  )r#   r^   r   Úfingerprints   &&  r)   rÔ   Ú6GatewayAdapterLifecycleMixin._adapter_credential_claimD  s*   € õ 	.Ø#×CÒCÀGÓLˆØ"Ò*ˆtÐG°Ð0GÐGr+   c               ó$   € V ^8„  d   QhRRRRRR/# r¢  r'   )r(   s   "r)   r*   rH   L  s&   € ÷ 
Bñ 
B¨(ð 
B¸Sð 
BÀ_ñ 
Br+   c                ó>  € \        VRR4      p\        V RR4      R8w  g-   \        V\        4      '       d   VP                  4       '       g   R#  \	        \        VRR4      4      pRRTP                  4       P                  4       T3#   \
        \        3 d     R# i ; i)zªExclusive listener claim (Photon sidecar bind+port): distinct credentials still cannot
share a port, so the later adapter is rejected before connect() disturbs the first.Ú_sidecar_bindNr.   ÚphotonÚ_sidecar_portrÀ  )r¿   r  r&   r€   rÊ   Ú	TypeErrorr‚   Úlower)r#   r^   r¢  r£  s   &&  r)   rÕ   Ú4GatewayAdapterLifecycleMixin._adapter_listener_claimK  s“   € ô �w °Ó6ˆÜ�8˜W dÓ+¨xÔ7¼zÈ$ÔPS×?TÒ?TÐ\`×\fÑ\f×\hÒ\hÙð	Ü”w˜w¨¸Ó>Ó?ˆDð ˜H d§j¡j£l×&8Ñ&8Ó&:¸DÐAÐAøô œ:Ð&ô 	Úð	ús   ÁB ÂBÂBc               ó    € V ^8„  d   QhRRRR/# )r"   r^   r   r%   rj   r'   )r(   s   "r)   r*   rH   Y  s   € ÷ ñ °ð ¸ñ r+   c           	     ó²  € R Uu. uF  qV3NK  	  upR Uu. uF  p\        V RR4      V3NK  	  up,           pV F�  w  r1\        W1R4      p\        V\        4      '       g   K)  VP                  4       '       g   KA  ^ RIpVP                  RVP                  4       ,           P                  R4      4      P                  4       R,          u # 	  R# u upi u upi )zvSalted, log-safe hash of an adapter's credential; None when none is discoverable
(conflict detection is then skipped).rÎ   Nzhermes-mux:zutf-8:Né   N)	rq  r  Ú_tokenÚ	api_tokenÚ
_bot_tokenÚ_project_secretÚ_app_idÚ
_client_idÚ_bot_id)rq  r  )r¿   r  r&   r€   ÚhashlibÚsha256ÚencodeÚ	hexdigest)r^   r…  Ú
candidatesr„  r†  r¸  s   &     r)   r4  Ú<GatewayAdapterLifecycleMixin._adapter_credential_fingerprintX  sÈ   € ñ)ó
ñ) �d‹Oñ )ñ
ñ CYÓYÑBX¸$Œg�g˜x¨Ó.°Ó5ÑBXÑYõZˆ
ó $‰IˆCÜ˜# TÓ*ˆCÜ˜#œs×#Ô#¨¯	©	¯¬ÛØ—~‘~ }°s·y±y³{Õ'B×&JÑ&JÈ7Ó&SÓT×^Ñ^Ó`ÐadÕeÒeñ	 $ñ
 ùò
ùò Zs
   …C—Cc               ó$   € V ^8„  d   QhRRRRRR/# ©r"   r#   r   rÎ   r   r%   zOptional[BasePlatformAdapter]r'   )r(   s   "r)   r*   rH   l  s"   € ÷ ñ ¨ð ¸#ð ÐB_ñ r+   c                ó<   € V P                  W4      pVe   Wn        V# )zœCreate an adapter bound to this runner (every lifecycle path goes through here so
adapters can resolve inbound profile routes before handlers or connect()).)Ú_instantiate_adapterÚgateway_runner)r8   r#   rÎ   r^   s   &&& r)   rÛ  Ú,GatewayAdapterLifecycleMixin._create_adapterl  s%   € ð ×+Ñ+¨HÓ=ˆØÒØ%)Ô"Øˆr+   c               ó$   € V ^8„  d   QhRRRRRR/# r¿  r'   )r(   s   "r)   r*   rH   t  s"   € ÷ >ñ >¨Xð >¸sð >ÐGdñ >r+   c                ó¾  € ^ RI Hp \        VR4      '       d‚   \        VP                  \
        4      '       db   VP                  P                  RV P                  P                  4       VP                  P                  R\        V P                  RR4      4       \        \        P                  RVP                  4      ;_uu_ 4        ^ RIHp VP!                  VP                  4      '       dM   VP#                  VP                  V4      pVf!   \$        P'                  R	VP                  4       VuuRRR4       #  RRR4       V! W4      #   + '       g   i     L; i)
zNInstantiate the adapter for a platform: plugin registry first, then built-ins.)Ú_instantiate_builtin_adapterrø  Úgroup_sessions_per_userÚthread_sessions_per_userFz,Platform registry lookup for '%s' failed: %srÊ  NzWPlatform '%s' is registered but adapter creation failed (check dependencies and config))rŠ   rÆ  Úhasattrr  rø  rÌ   rÂ  rÎ   rÇ  r¿   r   r`   ra   r.   rÎ  rË  rÏ  Úcreate_adapterrc   rñ   )r8   r#   rÎ   rÆ  rË  r^   s   &&&   r)   rÁ  Ú1GatewayAdapterLifecycleMixin._instantiate_adaptert  sý   € å<Ü�6˜7×#Ò#¬
°6·<±<Ä×(FÒ(FØ�L‰L×#Ñ#Ð$=¸t¿{¹{×?bÑ?bÔcØ�L‰L×#Ñ#Ø*¬G°D·K±KÐA[Ð]bÓ,côô œWŸ]™]Ð,ZÐ\d×\jÑ\j×kÕkÝCØ ×.Ñ.¨x¯~©~×>Ò>Ø+×:Ñ:¸8¿>¹>È6ÓR�Ø’?Ü—L‘Lð:Ø;C¿>¹>ôð ÷ lÒkà>÷ lñ ,¨HÓ=Ð=÷ l×kús   ÃA)EÅE	c               ó$   € V ^8„  d   QhRRRRRR/# )r"   r#   r   r^  rj   r%   z3Callable[[str, Optional[str], Optional[str]], bool]r'   )r(   s   "r)   r*   rH   ˆ  s$   € ÷ 4ñ 4Ø ð4Ø0=ð4à	<ñ4r+   c                óÔ   a aaaa€ ^ RI Hp S P                  4       '       d   Sf   \        V! 4       4      MRoS'       d   S P	                  S4      MRoRRRRR/R VVVV V3R llllpV# )	uB  Platform-bound auth callback for adapters (prompt-injection mitigation for fetched
context); delegates to :meth:`_is_user_authorized`. ``profile_name`` binds a secondary to
its scope; for the shared primary (None) the routed profile is stamped so its pairing store
is consulted while allowlist reads stay under the transport home.

Without this an inline-button caller approved only in the routed profile's pairing store was denied
(#86296), because the adapter's callback source was never route-stamped. A secondary-owned bot's
callback fires outside the profile runtime scope (straight off the adapter's event loop), so the
check re-enters the owning profile's scope per call â€” the gate's scoped env read otherwise falls
back to os.environ (the default profile's env) and denies the secondary's own allowlisted
callers (#120639).
rH  NÚis_botFÚ	thread_idc               ó0   € V ^8„  d   QhRRRRRRRRRRR	R/# )
r"   Úuser_idr&   Ú	chat_typerj   Úchat_idrÎ  r$   rÏ  r%   r'   )r(   s   "r)   r*   ÚKGatewayAdapterLifecycleMixin._make_adapter_auth_check.<locals>.__annotate__�  s>   € ÷ 	?ñ 	?Øð	?Ø%2ð	?ØDQð	?àð	?à-:ð	?ð ñ	?r+   c          
     ó€  <€ V '       g   R # \        S	T;'       g    RT;'       g    RW\        V4      SR7      pS'       d'   \        SRR4      ;'       g    / P                  S4      M\        SRR4      ;'       g    / pVP                  S	4      pVe   \        P
                  ! V4      Vn        SfS   ^ RIHp SP                  \        P                  ! VR R7      S
4      ;_uu_ 4        SP                  V4      uuRRR4       # SP                  VSR	7      f   R # SP                  V4      #   + '       g   i     L8; i)
Frm   Úgroup)r#   rÓ  rÒ  rÑ  rÏ  rÎ  rh   rÁ  Nrô   r–  r^  rt  )r   r$   r¿   r¶   Ú_weakrefÚrefÚ_transport_adapter_refrŠ   rX  r  r  r  Ú_is_user_authorizedrH  r‘  )rÑ  rÒ  rÓ  rÎ  rÏ  rF  Úregistryr^   rX  r#   rn  r^  r8   rU  s   &&&$$    €€€€€r)   ÚcheckÚDGatewayAdapterLifecycleMixin._make_adapter_auth_check.<locals>.check�  s-  ø€ ÷ ÙÜ"Ø!¨7¯=¨=°bÀI×DXÐDXÐQXØ¼TÀ&»\ÐS_ôˆF÷  ô ˜Ð2°DÓ9×?Ð?¸R×DÑDÀ\ÔRÜ%,¨T°:¸tÓ%D÷ð ð ð ð —l‘l 8Ó,ˆGØÒ"Ü08·²¸WÓ0E�Ô-ØÒ%õ ?Ø×(Ñ(Ü!×)Ò)Ð*@ÐRWÔXÐZf÷hõ hà×3Ñ3°FÓ;÷hò hð
 ×!Ñ! &°~Ð!ÓFÒNÙØ×6Ñ6°vÓ>Ð>÷h÷ hús   Ã)D-Ä-D=	rƒ  )rŠ   rI  r   r   r  )r8   r#   r^  rI  rÜ  rn  rU  s   fff  @@r)   ræ  Ú5GatewayAdapterLifecycleMixin._make_adapter_auth_checkˆ  se   ü€ õ 	0Ø48×4FÑ4F×4HÒ4HÈ\ÒMaœ™oÓ/Ô0Ðgkˆ÷ CO�t×0Ñ0°Ô>ÐTXˆñ	?à ð	?à=A÷	?÷ 	?ð> ˆr+   )
r  r"  rö   r÷   r¾   r  r  r�  r$  r©  r1  )rê   g      >@)rm   )Xr;   r<   r=   r>   r?   ÚstaticmethodrR   rX   rf   rx   r„   r_   r•   rž   r�   r®   r¹   rÅ   rØ   rà   ræ   rÃ   ró   rï   r  rÁ   r#  r)  r:  r}  r‚  r�  r–  rß   r   r½  rÁ  rÆ  rÐ  r²  rÙ  rï  rö  rà  r  r.  r#  r&  rn  rz  rŠ  r¤  r®  r»  r%  rì  rß  rÅ  r
  r  rÆ  r  rû  r)  r  r  rm  rH  rú  rü  rk  rp  rh  rÛ  rà  rz  r   r’  rý  r�  rè  rÔ   rÕ   r4  rÛ  rÁ  ræ  rA   r'   r+   r)   rC   rC   F   s7  † Ùeàôó ðõ	õ
ðÐ]a÷ ðB ô	ó ð	õZñuÈu÷ uð uð&Ø9>ðØPU÷õ*Uõ<õ3õ
ð
Øae÷
õ"õHKõ<&õ|:õ?õBð ôó ðõ#ð
 ô-ó ð-ðHØ-1ðHØ<=ðHØHLðHØY]ôH÷T_&÷Bõ0Kð:,°Tô ,õ(õ(ð6
ØOS÷
õ,
õõ
õYdõv-õ1õnõ!oõFõ2<õ|õ bõ*"ðH ôó ðõ6 &ðD%à)-ð%àPT÷%õN
õ<õ$`ðD[Ø?Cð[ØY]ð[à!ð[à7;ð[àTXð[ð )-ð[ð aeð[ð ;A÷	[õ<(<÷T)$÷VQ8õf*õXõ"cõ
ð0 ô+ó ð+ð$ ñ5ó ð5ð( ñ;ó ð;ðÈ$ð Ø59÷õ*&õ,ò&ò$õ&bò=òQòõGõ?õ
òòLð
 ôHó ðHð ô
Bó ð
Bð ôó ðõ&õ>÷(4ó 4r+   rC   )>r?   Ú
__future__r   r`   Útypingr   rL   r6  r   r  r~   rn   Úweakrefr×  Úagent.async_utilsr   Úcontextvarsr   r   r   r	   r
   rc  r   r   r   r   rÿ  Úgateway.platforms.baser   Úgateway.platforms.helpersr   r   Úgateway.restartr   Úgateway.run_shutdownr   Úgateway.sessionr   Ú/hermes_cli.observability.shared_metrics_gatewayr   r   Úpathlibr   r   r   r   r   r   rŠ   r   Úgateway.run_turn_runnerr   Ú	getLoggerrc   Úobjectrì  rÝ  r0   r2   r.  rC   r'   r+   r)   Ú<module>rï     s´   ðñõ #ã Ý  Û Û Ý Û Û 	Û Û Ý :Ý ß 7Ó 7÷ó õ 7ß QÝ 6Ý 0Ý )ß oÝ ß ;Õ ;çÝ)Ý2ð 
×	Ò	˜=Ó	)€Ù	‹€ØÐ ðMÈ÷ M÷+ñ +ñ 1Ó2Ð ÷vó vr+   