+
    jHàjñ  ã                  ó¢   € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	H
t
HtHt ]P                  ! ]4      t ! R R4      tR R ltR	 R
 ltR# )uè  Late plugin loads re-wire the running adapters (#87770).

A plugin that finishes loading after an adapter connected â€” a tool-triggered force re-discovery, or
``hermes plugins install/enable`` / the Desktop / ``plugins.manage`` nudging the gateway over the control
socket â€” used to leave its platform handlers (slash commands, button callbacks, inbound transforms)
silently unwired until a restart. The runner subscribes to ``PluginManager.on_plugin_loaded`` per served
profile and calls every live adapter's idempotent ``rewire_plugin_handlers()`` on the event loop.

Scope is handlers only: a mid-run-loaded plugin's tools and system-prompt sections stay deferred to the
next session (prompt-cache invariant; same as ``/skills install``).
)ÚannotationsN)ÚPath)ÚAnyÚCallableÚDictÚOptionalc                  óJ   € ] tR t^t$ RtRtR]R&   R
R R lltR
R R lltR	t	R# )ÚGatewayPluginRewireMixinzYSubscribe once per plugin manager; re-wire that profile's adapters on every loaded event.Nz'Optional[dict[str, Callable[[], None]]]Ú_plugin_rewire_unsubscribec               ó(   € V ^8„  d   QhRRRRRRRR/# )	é   Úmanagerr   Úprofile_nameúOptional[str]Úprofile_homeúOptional[Path]ÚreturnÚNone© )Úformats   "Ú>/home/ubuntu/.hermes/hermes-agent/gateway/run_plugin_rewire.pyÚ__annotate__Ú%GatewayPluginRewireMixin.__annotate__   s*   € ÷ ;ñ ;°ð ;À=ð ;Ø/=ð;ØIMñ;ó    c                ó2  a aaa€ S P                   pVf
   / ;pS n         \        \        VRR4      ;'       g    \        V4      4      pWT9   d   R#  \        P
                  ! 4       oR VVVV 3R llpVP                  V4      WE&   R#   \         d    Ro L0i ; i)zÇIdempotent per manager scope: a served-profile rescan re-enters ``_load_secondary_profile_config``
and must not stack a second listener (two listeners = two re-wire passes, still deduped, but noise).NÚ	scope_keyÚ c               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r   s   "r   r   ÚGGatewayPluginRewireMixin._subscribe_plugin_rewire.<locals>.__annotate__,   s   € ÷ 	`ñ 	` $ñ 	`r   c                óz   <€ Se   SP                  4       '       d   R # SP                  SP                  SS4       R # ©N)Ú	is_closedÚcall_soon_threadsafeÚ_rewire_plugin_handlers)Ú_namesÚloopr   r   Úselfs   &€€€€r   Ú
_on_loadedÚEGatewayPluginRewireMixin._subscribe_plugin_rewire.<locals>._on_loaded,   s2   ø€ ð Š|˜tŸ~™~×/Ò/ÙØ×%Ñ% d×&BÑ&BÀLÐR^Ö_r   )r
   ÚstrÚgetattrÚidÚasyncioÚget_running_loopÚRuntimeErrorÚon_plugin_loaded)r&   r   r   r   ÚsubsÚscoper'   r%   s   f&ff   @r   Ú_subscribe_plugin_rewireÚ1GatewayPluginRewireMixin._subscribe_plugin_rewire   s’   û€ ð ×.Ñ.ˆØŠ<Ø57Ð7ˆD�4Ô2Ü”G˜G [°"Ó5×DÐD¼¸G»ÓEˆØŒ=Ùð	Ü×+Ò+Ó-ˆD÷	`ó 	`ð ×.Ñ.¨zÓ:ˆ‹øô ô 	ØŠDð	ús   ÁB ÂBÂBc               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   r   r   r   Úintr   )r   s   "r   r   r   5   s#   € ÷ ñ °Mð Ø.<ðØHKñr   c                óž  € Vf"   \        \        V RR4      ;'       g    / 4      pM9\        \        V RR4      ;'       g    / P                  V4      ;'       g    / 4      pV'       g   ^ # ^ RIHp Ve   V! VRR7      M\
        P                  ! 4       p^ pT;_uu_ 4        VP                  4        F  w  rx VP                  4        V^,          pK!  	  RRR4       \        P                  RTV'       d   RV R24       V# R4       V#   \         d(    \        P                  R\        TRT4      R	R
7        K‰  i ; i  + '       g   i     Lr; i)zæCall ``rewire_plugin_handlers()`` on every live adapter of one profile (``None`` = the launch
profile's ``self.adapters``); a secondary's adapters read their own manager, so bind its scope.
Returns the number of adapters re-wired.NÚadaptersÚ_profile_adapters©Ú_profile_runtime_scopeF©Úhydrate_secretsz"[%s] plugin handler re-wire failedÚvalueT)Úexc_infoz+Re-wired plugin handlers on %d adapter(s)%sz for profile 'Ú'r   )Údictr*   ÚgetÚgateway.runr:   Ú
contextlibÚnullcontextÚitemsÚrewire_plugin_handlersÚ	ExceptionÚloggerÚwarningÚinfo)	r&   r   r   r7   r:   r1   ÚcountÚplatformÚadapters	   &&&      r   r#   Ú0GatewayPluginRewireMixin._rewire_plugin_handlers5   s6  € ð
 ÒÜœG D¨*°dÓ;×AÐA¸rÓB‰HäœW TÐ+>ÀÓE×KÐKÈ×PÑPÐQ]Ó^×dÐdÐbdÓeˆHßÙÝ6à Ò,ñ (¨ÀeÕLÜ2<×2HÒ2HÓ2Jð 	àˆßŠUØ%-§^¡^Ö%5Ñ!�ð2Ø×2Ñ2Ô4Ø˜Q•J’Eñ &6÷ ô 	�‰ÐAÀ5ß8D�n \ N°!Ð4ô	Nàˆð KMô	Nàˆøô !ô 2Ü—N‘NÐ#GÌÐQYÐ[bÐdlÓImØ,0ð #÷ 2ð2ú÷ �Uús0   ÂD<Â5DÃD<Ä.D9	Ä5D<Ä8D9	Ä9D<Ä<E	)r
   )NN)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r
   Ú__annotations__r2   r#   Ú__static_attributes__r   r   r   r	   r	      s    ‡ ÙcàJNÐÐ GÓN÷;÷0ó r   r	   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úrunnerr   r%   zasyncio.AbstractEventLoopr   zCallable[..., dict]r   )r   s   "r   r   r   Q   s#   € ÷ &ñ & ð &Ð+Dð &ÐI\ñ &r   c                ó"   a a€ RR VV 3R lllpV# )a&  Control-socket ``reload-plugins``: force re-discovery under the requested home's scope so a plugin
installed/enabled by another process (CLI, Desktop, ``plugins.manage``) loads now; the loaded event
then re-wires that profile's adapters. Only the gateway home and served profile homes are accepted.
Answer: ``{"reloaded", "home", "plugins", "activations", "adapters_rewired"}``. Runs on the socket executor thread
(discovery is blocking); the count is read on the loop AFTER the re-wire callback (FIFO), so a
truthful "active now" reaches the caller.c               ó    € V ^8„  d   QhRRRR/# )r   ÚparamszOptional[dict]r   r@   r   )r   s   "r   r   Ú)reload_plugins_verb.<locals>.__annotate__Y   s   € ÷ -ñ -˜ð -°4ñ -r   c           
     ó   <aa€ ^ RI HpHo ^ RIHpHp ^ RIHp ^ RIH	p T ;'       g    / p \        V! 4       4      p\        \        V P                  R4      ;'       g    T4      4      P                  4       pS! V4      oRpSS! V4      8w  dp   \        SRR4      ;'       g    / P                  4       p	\!        VV3R lV	 4       R4      pVf   R	R
RRR\        V4      /# T\        SRR4      ;'       g    R8X  d   RpV'       d   V! VR
R7      M\"        P$                  ! 4       p
V
;_uu_ 4        V! RR7       V! 4       p\'        VP(                  4      V! V4      rÜRRR4        \*        P,                  ! \/        SV4      S4      P1                  RR7      pR	RR\        V4      RXRXRV/#   + '       g   i     LW; i  \2         d    Rp L7i ; i)é    )Úget_hermes_homeÚhermes_home_key)Údiscover_pluginsÚget_plugin_manager)Úactivation_summariesr9   ÚhomeNÚ_served_profile_homesc              3  ó\   <"  € T F!  w  rS! V4      S8X  g   K  \        V4      x € K#  	  R # 5ir    )r)   )Ú.0ÚnÚhr_   Úreq_keys   &  €€r   Ú	<genexpr>Ú8reload_plugins_verb.<locals>._handler.<locals>.<genexpr>e   s(   øé € Ð \±F©D¨A¹oÈaÓ>PÐT[Ñ>[¤¤ Q§ ³Fùs   ƒ,™,ÚreloadedFÚerrorz"home is not served by this gatewayÚ_primary_profile_nameÚdefaultr;   T)Úforceg      @)ÚtimeoutÚpluginsÚactivationsÚadapters_rewired)Úhermes_constantsr^   r_   Úhermes_cli.pluginsr`   ra   Úhermes_cli.plugins_activationrb   rB   r:   r   r)   rA   Ú
expanduserr*   rE   ÚnextrC   rD   ÚsortedÚ_pluginsr,   Úrun_coroutine_threadsafeÚ_count_adaptersÚresultrG   )rZ   r^   r`   ra   rb   r:   Úgateway_homeÚ	requestedr   Úservedr1   r   Únamesrs   Úrewiredr_   ri   r%   rW   s   &              @@€€r   Ú_handlerÚ%reload_plugins_verb.<locals>._handlerY   s¤  ú€ ßEßKÝFÝ6Ø—�˜2ˆÜ™OÓ-Ó.ˆÜœ˜VŸZ™Z¨Ó/×?Ð?°<Ó@ÓA×LÑLÓNˆ	Ù! )Ó,ˆØ&*ˆØ‘o lÓ3Ô3Ü˜fÐ&=¸tÓD×JÐJÈ×QÑQÓSˆFÜÕ \±FÓ \Ð^bÓcˆLØÒ#Ø" E¨7Ð4XÐZ`ÔbeÐfoÓbpÐqÐqØ¤¨Ð0GÈÓ N× [Ð [ÐR[Ô\Ø#�ßMYÑ'¨	À5ÕIÜ ×,Ò,Ó.ð 	çŠUÙ 4Õ(Ù(Ó*ˆGÜ!'¨×(8Ñ(8Ó!9Ñ;OÐPWÓ;X�;÷ ð	Ü×6Ò6´ÀvÈ|Ó7\Ð^bÓc×jÑjÐsvÐjÓwˆGð ˜D &¬#¨i«.¸)ÀUÈMÐ[fØ" Gð-ð 	-÷ �Uûô ô 	ØŠGð	ús   Ä.-F*Å$1F= Æ*F:	Æ=GÇGr    r   )rW   r%   r„   s   ff r   Úreload_plugins_verbr†   Q   s   ù€ ÷-ó -ð< €Or   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rW   r   r   r   r   r5   r   )r   s   "r   r   r   z   s&   € ÷ [ñ [ #ð [°]ð [Àsñ [r   c              ƒ  óÄ   "  € Vf!   \        \        V RR4      ;'       g    / 4      # \        \        V RR4      ;'       g    / P                  V4      ;'       g    / 4      # 5i)z_Live adapters for the profile; scheduled after the loaded-event callback, so they are re-wired.Nr7   r8   )Úlenr*   rA   )rW   r   s   &&r   r}   r}   z   sX   é € àÒÜ”7˜6 :¨tÓ4×:Ð:¸Ó;Ð;Ü”˜Ð 3°TÓ:×@Ð@¸b×EÑEÀlÓS×YÐYÐWYÓZÐZùs   ‚A  A Á A ÁA )rS   Ú
__future__r   r,   rC   ÚloggingÚpathlibr   Útypingr   r   r   r   Ú	getLoggerrO   rH   r	   r†   r}   r   r   r   Ú<module>r�      sH   ðñ
õ #ã Û Û Ý ß 0Ó 0à	×	Ò	˜8Ó	$€÷6ñ 6õr&÷R[r   