+
    jHàj Y  ã                  ó¾   € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	H
t
 ^ RIHtHtHt ^ RIHt ^ RIHtHt ^ RIHt ]P,                  ! R4      t ! R	 R
4      tR# )uŽ  Plugin-triggered gateway turns (``PluginContext.inject_message``): the process-wide injector this
runner publishes, the thread-safe scheduler, and the dispatch through the adapter message path.

Two targets: an existing session (``session_key``; route and session id pinned from the store) or a
messaging chat (``origin``) whose session is created â€” or continued â€” through the normal session path
in the calling plugin's OWN profile. The origin path never chooses a profile: the gateway's routing
for that chat through that profile's adapter must already land in the plugin's profile, so a human
follow-up in the same chat keys into the same session.)ÚannotationsN)ÚPath)ÚAnyÚMappingÚOptional)ÚPlatform)ÚMessageEventÚMessageType)ÚSessionSourcezgateway.runc            
      óú   € ] tR t^tR R ltR R ltRRRRRRR	R
RR/R R lltR R 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/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)tR# )+ÚGatewayPluginInjectionMixinc               ó   € V ^8„  d   QhRR/# ©é   ÚreturnÚNone© )Úformats   "ÚA/home/ubuntu/.hermes/hermes-agent/gateway/run_plugin_injection.pyÚ__annotate__Ú(GatewayPluginInjectionMixin.__annotate__   s   € ÷ Tñ T°$ñ Tó    c                ó6   € ^ RI Hp V! W P                  4       R# )zBPublish this live gateway's plugin message scheduler process-wide.)Úpublish_gateway_message_hostN)Úhermes_cli.pluginsr   Ú"_schedule_plugin_message_injection)Úselfr   s   & r   Ú _install_plugin_message_injectorÚ<GatewayPluginInjectionMixin._install_plugin_message_injector   s   € åCá$ T×+RÑ+RÖSr   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r   !   s   € ÷ 3ñ 3°ñ 3r   c                ó"   € ^ RI Hp V! V 4       R# )z@Remove this runner's scheduler without clobbering a newer owner.)Ú$clear_published_gateway_message_hostN)r   r!   )r   r!   s   & r   Ú_clear_plugin_message_injectorÚ:GatewayPluginInjectionMixin._clear_plugin_message_injector!   s   € åKá,¨TÖ2r   Úsession_keyNÚoriginÚplugin_homeÚkeylessFÚcalling_session_keyÚ c               ó8   € V ^8„  d   QhRRRRRRRRRR	R
RRRRR/# )r   ÚcontentÚstrÚ	plugin_idr$   úOptional[str]r%   zOptional[Mapping[str, Any]]r&   úOptional[Path]r'   Úboolr(   r   r   )r   s   "r   r   r   '   s\   € ÷ Gñ GØðGØ*-ðGØ<IðGà+ðGàAOðGð ðGð 58ðGð 
ñ	Gr   c               óx  aa€ ^ RI Hp \        V RR4      p	\        V RR4      '       d   V	e   V	P                  4       '       d   R# V'       dQ   ^ RIHp
 V
P                  WSVR7      pVf   R# RV^,          P                   R	2oV
P                  ! V .VO5R
VRS/ pM¤Vem   V P                  WESR7      pVe   V P                  WÕSR7      '       g   R# RVP                  P                   RVP                   2oV P                  WÑSR7      pM4V P                  W5SR7      '       g   R# RV 2oV P!                  W1SVR7      p \"        P$                  ! 4       pWéJ dT    V	P)                  V4      pT P2                  P5                  T4       TP7                  T P2                  P8                  4       M$V! WÉ\.        R\:        P<                  R7      pVf   R# R VV3R llpVP7                  V4       R#   \&         d    Rp L¨i ; i  \*         d,    TP-                  4        \.        P1                  RRR7        R# i ; i)aY  Schedule a plugin-triggered turn on the live gateway loop (thread-safe).

With ``origin`` the profile, origin and adapter checks run here, synchronously, so the plugin
gets ``False`` for a chat it may not start; authorization is rechecked at dispatch. ``keyless``
(neither given) picks the target here too (``gateway/plugin_keyless_inject.py``).)Úsafe_schedule_threadsafeÚ_gateway_loopNÚ_runningF)Úplugin_keyless_inject)r&   r-   r(   úsession=z (no key given)r+   r-   ©r&   r-   úorigin=Ú/)Úsourcer+   r-   )r$   r+   r-   r&   z*Plugin message injection scheduling failedT©Úexc_info)ÚloggerÚlog_messageÚ	log_levelc               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   ÚTGatewayPluginInjectionMixin._schedule_plugin_message_injection.<locals>.__annotate__b   s   € ÷ 		gñ 		g dñ 		gr   c                ó"  <€  V P                  4       '       d   R #  \        P                  RSS4       R #   \        P                  \        P                  P                  3 d     R # \
         d    \        P                  RSSRR7        R # i ; i)Nz-Plugin message injection failed: plugin=%s %sTr;   z5Plugin message injection was not routed: plugin=%s %s)ÚresultÚasyncioÚCancelledErrorÚ
concurrentÚfuturesÚ	Exceptionr=   Úwarning)Ú	completedr-   Útargets   &€€r   Ú_log_resultÚSGatewayPluginInjectionMixin._schedule_plugin_message_injection.<locals>._log_resultb   s‚   ø€ ðØ×#Ñ#×%Ò%Ùð &ô �N‰NÐRÐT]Ð_eÖføô ×*Ñ*¬J×,>Ñ,>×,MÑ,MÐNô ÚÜô Ü—‘ÐNÐPYÐ[aÐlp�ÔqÚðús   ƒ5 µ/BÁ'BÁ0BÂB)Úgateway.runr2   ÚgetattrÚ	is_closedÚgatewayr5   ÚresolveÚrouteÚadmitÚ_plugin_origin_sourceÚ_plugin_origin_admissibleÚplatformÚvalueÚchat_idÚ!_dispatch_plugin_origin_injectionÚ_plugin_session_key_admissibleÚ"_dispatch_plugin_message_injectionrD   Úget_running_loopÚRuntimeErrorÚcreate_taskrH   Úcloser=   rI   Ú_background_tasksÚaddÚadd_done_callbackÚdiscardÚloggingÚWARNING)r   r+   r-   r$   r%   r&   r'   r(   r2   Úloopr5   ÚresolvedÚcoror:   Úcurrent_loopÚfuturerL   rK   s   &$d$$$$$         @r   r   Ú>GatewayPluginInjectionMixin._schedule_plugin_message_injection'   sC  ù€ õ 	9Ü�t˜_¨dÓ3ˆÜ�t˜Z¨×/Ò/°4²<À4Ç>Á>×CSÒCSÙçÝ5Ø,×4Ñ4°TÐ^gØI\ð 5ó ^ˆHàÒÙØ ¨¥× 1Ñ 1Ð2°/ÐBˆFØ(×.Ò.¨tÐe°hÒeÈÐeÐ[dÑe‰DØÒØ×/Ñ/°Ð[dÐ/ÓeˆFØŠ~ T×%CÑ%CÀFØNWð &D÷ &Yò &YáØ˜vŸ™×4Ñ4Ð5°Q°v·~±~Ð6FÐGˆFØ×9Ñ9ÀÐdmÐ9Ón‰Dà×6Ñ6°{ÐgpÐ6×qÒqÙØ ˜}Ð-ˆFØ×:Ñ:Ø'ÀIÐ[fð ;ó ˆDð	 Ü"×3Ò3Ó5ˆLð ÓðØ×)Ñ)¨$Ó/�ð
 ×"Ñ"×&Ñ& vÔ.Ø×$Ñ$ T×%;Ñ%;×%CÑ%CÕDá-Ø¤6Ð7cÜ!Ÿ/™/ôˆFð Š~Ù÷		gñ 		gð 	× Ñ  Ô-ÙøôA ô 	 ØŠLð	 ûô ô Ø—
‘
”Ü—‘ÐKÐVZ�Ô[Úðús$   ÅG0 ÅH Ç0H Ç?H È2H9È8H9c               ó   € V ^8„  d   QhRR/# )r   r   r0   r   )r   s   "r   r   r   p   s   € ÷ Zñ Z¨Tñ Zr   c                	óP   € \        V R R4      ;'       d    \        V RR4      '       * # )r4   FÚ	_draining)rO   )r   s   &r   Ú_plugin_injection_acceptingÚ7GatewayPluginInjectionMixin._plugin_injection_acceptingp   s&   € Ü�t˜Z¨Ó/×YÐY¼ÀÀkÐSXÓ8YÔ4YÐYr   c               ó    € V ^8„  d   QhRRRR/# )r   r:   r
   Úhomer/   r   )r   s   "r   r   r   s   s   € ÷ cñ c¨mð cÀ>ñ cr   c                ó²   € \        \        V RR4      RR4      RJd   \        P                  ! 4       # ^ RIHp T! T;'       g    V P                  V4      4      # )ua  Multiplex: enter the source's profile runtime scope (or *home*'s, when the owner is known)
around ``handle_message`` so the background task it spawns â€” the turn AND the reply send after
the handler returns â€” inherits that profile's home and secrets (this coroutine runs from the
default loop context, not from the profile adapter's own intake task).ÚconfigNÚmultiplex_profilesFT)Ú_async_profile_runtime_scope)rO   Ú
contextlibÚnullcontextrN   rw   Ú _resolve_profile_home_for_source)r   r:   rs   rw   s   &&& r   Ú_plugin_injection_scopeÚ3GatewayPluginInjectionMixin._plugin_injection_scopes   sQ   € ô
 ”7˜4 ¨4Ó0Ð2FÈÓNÐVZÓZÜ×)Ò)Ó+Ð+Ý<Ù+¨D×,aÐ,a°D×4YÑ4YÐZ`Ó4aÓbÐbr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r:   r
   r-   r,   rK   r   r0   r   )r   s   "r   r   r   }   s+   € ÷ ñ °=ð ÐPSð Ð]`ð Ðeiñ r   c               ó¾   €  V P                  VRR7      pT'       g   \        P                  RY#4       T#   \         d    \        P                  RY#RR7        R# i ; i)a  Current gateway authorization for the route the injected turn will run as. Host-side
plugin code is trusted to ask, never to widen access: a stored or supplied route must pass
today's allowlists / pairing / allow-all, and adapter-time grants (Discord roles) do not count.F)Úallow_adapter_delegationzAPlugin message injection authorization check failed: plugin=%s %sTr;   zNPlugin message injection denied by current gateway authorization: plugin=%s %s)Ú_is_user_authorized_for_sourcerH   r=   rI   )r   r:   r-   rK   Ú
authorizeds   &&$$ r   Ú_plugin_injection_authorizedÚ8GatewayPluginInjectionMixin._plugin_injection_authorized}   sg   € ð	Ø×<Ñ<¸VÐ^cÐ<ÓdˆJ÷
 Ü�N‰NÐkØ$ô.àÐøô ô 	Ü�N‰NÐ^Ø$°tð ô =âð	ús   ‚5 µ#AÁAc               ó(   € V ^8„  d   QhRRRRRRRR/# ©r   r$   r,   r&   r/   r-   r   r0   r   )r   s   "r   r   r   Œ   s0   € ÷ oñ o¸#ð oÈ~ð oÐjmð oÐrvñ or   c               ó*  € V P                   P                  V4      pVe   VP                  f   R# ^ RIHp V! V P                  V4      4      pVP                  \        P                  8X  d   V P                  WaVVR7      RJ# V P                  WVR7      # )zÀSynchronous refusal of a keyed injection into another profile's session (local or
messaging), so the plugin gets ``False``; an unknown key is decided at dispatch, as before.
Dispatch rechecks.NT©Úreplace_sourcer7   )Úsession_storeÚlookup_by_session_keyr%   Úgateway.session_identityrˆ   Ú_restored_sourcerW   r   ÚLOCALÚ_plugin_local_sessionÚ_plugin_messaging_session_owned)r   r$   r&   r-   Úentryrˆ   r:   s   &&$$   r   r[   Ú:GatewayPluginInjectionMixin._plugin_session_key_admissibleŒ   s”   € ð ×"Ñ"×8Ñ8¸ÓEˆØŠ=˜EŸL™LÒ0ÙÝ;Ù × 5Ñ 5°eÓ <Ó=ˆØ�?‰?œhŸn™nÔ,Ø×-Ñ-¨fÈ{Ø8Að .ó CØJNðOð Oà×3Ñ3°KÐdmÐ3ÓnÐnr   c               ó(   € V ^8„  d   QhRRRRRRRR/# r…   r   )r   s   "r   r   r   š   s+   € ÷ ñ ¸3ð ÐP^ð Ø36ðØ;?ñr   c               óÚ   € Vf   R# V P                  V4      pTpVe+   \        \        V RR4      RR4      RJ d   ^ RIHp V! V4      pVe	   WT8X  d   R# \        P                  RW1WT4       R# )a  A messaging session belongs to the profile its key names (``agent:<profile>:...``) under
multiplexing, and to the one served profile of a standalone gateway; it must be the plugin's
own, as on the origin path. A caller with no plugin home is left to dispatch, as before.NTru   rv   F)Úprofile_from_session_keyziPlugin message injection refused: plugin=%s session=%s belongs to profile %s, not the plugin's profile %s)Ú_served_profile_for_homerO   Úhermes_state_keysr”   r=   rI   )r   r$   r&   r-   ÚprofileÚownerr”   s   &&$$   r   r�   Ú;GatewayPluginInjectionMixin._plugin_messaging_session_ownedš   sy   € ð
 ÒÙØ×/Ñ/°Ó<ˆØˆØÒ¤7¬7°4¸À4Ó+HÐJ^Ð`eÓ#fÐjnÓ#nÝBÙ,¨[Ó9ˆEØÒ 5Ô#3ÙÜ�‰ð -Ø.7Àeô	Vá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   s   "r   r   r   ¬   s*   € ÷ ñ ¨Mð Èð Ð]kð Ø),ñr   c               óà   € ^ RI Hp Ve	   V! W4      MRpVe&   VP                  P                  VP                  4      MRpVe   VP
                  V8X  d   V# \        P                  RWBV4       R# )a°  A local session's own source passes no chat allowlist, so the plugin's profile boundary is
the only check: the session authority registered for the plugin's immutable home must hold
the live session under this key. Its ``LiveSession``, or ``None`` (logged). Never resolved
through the source's profile, whose fallback is the ambient scope (a default-profile local
source carries none, so under beta's scope it would read as beta's).©Úauthority_for_homeNzrPlugin message injection refused: plugin=%s session=%s is not a live local session of the plugin's profile home %s)Úgateway.session_authoritiesr�   ÚsessionsÚgetrY   rS   r=   rI   )r   r:   r$   r&   r-   r�   Ú	authorityÚlives   &&&$$   r   rŽ   Ú1GatewayPluginInjectionMixin._plugin_local_session¬   sm   € õ 	CØ=HÒ=TÑ& tÔ9ÐZ^ˆ	Ø9BÒ9Nˆy×!Ñ!×%Ñ% f§n¡nÔ5ÐTXˆØÒ §
¡
¨kÔ 9ØˆKÜ�‰ð 2Ø3<È;ô	Xá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   r0   r   )r   s   "r   r   r   ¼   s4   € ÷ +ñ +Ø!ð+Ø,/ð+Ø<?ð+ØN\ð+à	ñ+r   c             ƒ  ó6  "  € V P                  4       '       g   R# V P                  P                  V4      G Rj  x€L
 pVe%   VP                  e   V P                  4       '       g   R# ^ RIHp V! V P                  V4      4      pVP                  \        P                  8X  d   V P                  WuW#VR7      G Rj  x€L
 # V P                  WVR7      '       g   R# V P                  WsRV 2R7      '       g   R# V P                  V4      pVf   R# V P                  V4      ;_uu_4       GRj  x€L
  V P                  W‡WP                   W#R7      G Rj  x€L
 p	V	e   T	uuRRR4      GRj  x€L
  # VP#                  \%        V\&        P(                  VR	RR
VRR	RVRVP                   RR	/R7      4      G Rj  x€L
  RRR4      GRj  x€L
  \*        P-                  RW1VP                   4       R	#  EL´ EL5 LÅ L¡ LŒ LC L5  + GRj  x€L 
 '       g   i     LL; i5i)zARoute a plugin-triggered turn through the session's live adapter.FNr‡   )r+   r-   r&   r7   r6   ©r-   rK   ©r$   Ú
session_idr+   r-   TÚhermes_plugin_idÚhermes_plugin_injectionÚgateway_session_keyÚgateway_session_idÚgateway_session_strict©ÚtextÚmessage_typer:   ÚinternalÚallow_gateway_controlÚmetadatazGPlugin message injection dispatched: plugin=%s session=%s session_id=%s)rp   Úasync_session_storerŠ   r%   r‹   rˆ   rŒ   rW   r   r�   Ú _dispatch_plugin_local_injectionr�   r‚   Ú_delivery_adapter_forr{   Ú_admit_plugin_injectionr¨   Úhandle_messager   r	   ÚTEXTr=   Úinfo)
r   r$   r+   r-   r&   r�   rˆ   r:   ÚadapterÚadmitteds
   &$$$$     r   r\   Ú>GatewayPluginInjectionMixin._dispatch_plugin_message_injection¼   sø  é € ð ×/Ñ/×1Ò1ÙØ×.Ñ.×DÑDÀ[ÓQ×QˆØŠ=˜EŸL™LÒ0¸×8XÑ8X×8ZÒ8ZÙå;Ù × 5Ñ 5°eÓ <Ó=ˆØ�?‰?œhŸn™nÔ,Ø×>Ñ>¸vÐV]ØKVð ?ó X÷ Xð Xà×3Ñ3°KÐdmÐ3×nÒnÙØ×0Ñ0°ÐW_Ð`kÐ_lÐUmÐ0×nÒnÙà×,Ñ,¨VÓ4ˆØŠ?Ùà×/Ñ/°×7×7Õ7Ø!×9Ñ9Ø¨[×EUÑEUØð :ó 6÷ 6ˆHð Ò#Ø÷ 8×7Ò7ð ×(Ñ(¬Ø¬;×+;Ñ+;ÀFÐUYØ&+à&¨	Ð3LÈdØ)¨;Ð8LÈe×N^ÑN^Ø,¨dðô*ó ÷ ð ÷ 8×7ô 	�‰ØUØ E×$4Ñ$4ô	
ñ òK RòXñ 8ñ6ñ 8ñ÷ 8×7×7Ò7üsº   ‚7H¹G-º+HÁ&AHÂ;G0Â<A1HÄ-G3Ä.HÄ1"G=ÅG5Å	G=ÅHÅ*G7Å+HÅ0AG=Æ5G9Æ6G=Æ:HÇG;Ç(HÇ0HÇ3HÇ5G=Ç7HÇ9G=Ç;HÇ=H	ÈHÈ
H	ÈH	ÈH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   r0   r   )r   s   "r   r   r   é   s:   € ÷ Tñ T¸]ð TÐ_bð TØ:=ðTØLZðTØ_cñTr   c             ƒ  óº  "  € V P                  WP                  WTR7      pVf   R# V P                  W4      ;_uu_4       GRj  x€L
  \        V P	                  V P                  VP                  4      VP                  VP                  VP                  W4R7      G Rj  x€L
 4      uuRRR4      GRj  x€L
  #  Lt L L	  + GRj  x€L 
 '       g   i     R# ; i5i)aq  A local (CLI/TUI/Desktop) session has no messaging adapter or chat allowlist: the plugin
turn is committed to its FIFO on the live session's own source and adapter, as a bot delivery
is, only when the plugin's own profile's authority holds the session (checked before entering
that scope). Main queued key-less CLI injections into the REPL; this is where they land now.r7   NFr§   )rŽ   r$   r{   r0   r·   Ú_adapter_for_sourcer:   r¨   )r   r:   r�   r+   r-   r&   r¢   s   &&&$$$ r   rµ   Ú<GatewayPluginInjectionMixin._dispatch_plugin_local_injectioné   s®   é € ð ×)Ñ)¨&×2CÑ2CÐQ\Ð)ÓrˆØŠ<ÙØ×/Ñ/°×D×DÕDÜ˜d×:Ñ:Ø×(Ñ(¨¯©Ó5°t·{±{ÐPU×PaÑPaØ ×+Ñ+°Wð ;ó S÷ Só T÷ E×DÔDñS÷ E×D×DÓDüsa   ‚ACÁB8ÁCÁAB>ÂB:ÂB>Â%CÂ2B<Â3CÂ:B>Â<CÂ>C	ÃCÃ
C	ÃC	Ã	Cc               ó    € V ^8„  d   QhRRRR/# )r   rs   r/   r   r.   r   )r   s   "r   r   r   ÷   s   € ÷ [ñ [¨^ð [Àñ [r   c                ó’  aa€ Vf   R# ^ RI HpHo S! V4      o\        \        V RR4      RR4      '       d1   ^ RIHp  V! V P                  4      p\        TT3R
 lT 4       R4      # S! V! 4       4      S8w  d   R# \        V RR4      ;'       g    V P                  4       #   \         d    \        P                  RRR	7        R# i ; i)z‡Name of the profile this gateway serves at *home* (a plugin manager's immutable home), or
``None`` when this gateway does not serve it.N)Úget_routing_process_hermes_homeÚhermes_home_keyru   rv   F)Ú_multiplex_profile_homesz8Plugin message injection: served-profile set unavailableTr;   c              3  óJ   <"  € T F  w  rS! V4      S8X  g   K  Vx € K  	  R # 5i©Nr   )Ú.0ÚnameÚserved_homerÅ   Úkeys   &  €€r   Ú	<genexpr>ÚGGatewayPluginInjectionMixin._served_profile_for_home.<locals>.<genexpr>  s$   øé € Ðe±vÑ"3 $ÁÐQ\ÓA]ÐadÑAdŸš³vùs   ƒ#™
#Ú_primary_profile_name)Úhermes_constantsrÄ   rÅ   rO   rN   rÆ   ru   rH   r=   rI   ÚnextÚ_active_profile_name)r   rs   rÄ   rÆ   ÚservedrÅ   rÌ   s   &&   @@r   r•   Ú4GatewayPluginInjectionMixin._served_profile_for_home÷   sº   ù€ ð Š<ÙßUÙ˜dÓ#ˆÜ”7˜4 ¨4Ó0Ð2FÈ×NÒNÝ<ðÙ1°$·+±+Ó>�ô Õe±vÓeÐgkÓlÐlÙÑ:Ó<Ó=ÀÔDÙÜ�tÐ4°dÓ;×ZÐZ¸t×?XÑ?XÓ?ZÐZøô ô Ü—‘ÐYÐdh�ÔiÚðús   ¾B  Â "CÃCc               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   r%   zMapping[str, Any]r&   r/   r-   r,   r   zOptional[SessionSource]r   )r   s   "r   r   r   
  s,   € ÷ $ñ $Ø'ð$Ø9Gð$ØTWð$à	 ñ$r   c               óâ  a€ R V3R llpV P                  V4      pVf
   V! RV4      # \        V4      pVP                  RR4      pV'       d   Wu8w  d
   V! RWu4      #  \        P                  ! V4      pTP                  P                   RTP                   2p
T P                  T4      P                  TP                  4      pTf   T! R	TP                  P                  T4      # \        P                  ! T4      Tn        T P!                  T4      pTf
   T! R
T
4      # TP"                  T8w  d   T! RY¬P"                  T4      # T#   \
        \        \        3 d   p	T! RT	4      u Rp	?	# Rp	?	ii ; i)aA  The canonicalized source for a plugin-supplied *origin*, or ``None`` (logged) when the
plugin may not start a turn there: its profile is not served, the origin is malformed or
names another profile, that profile has no live adapter for the platform, or the gateway's
own routing for the chat lands in a different profile.c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úreasonr,   Úargsr   r   r   r   )r   s   "r   r   ÚGGatewayPluginInjectionMixin._plugin_origin_source.<locals>.__annotate__  s&   € ÷ 	fñ 	f˜Cð 	f¨ð 	f°ñ 	fr   c                óH   <€ \         P                  ! R V ,           S.VO5!   R# )z,Plugin message injection refused: plugin=%s N)r=   rI   )rØ   rÙ   r-   s   &*€r   Ú_refuseÚBGatewayPluginInjectionMixin._plugin_origin_source.<locals>._refuse  s   ø€ Ü�NŠNÐIÈFÕRÐT]ÐeÐ`dÖer   Nz1its profile home %s is not served by this gatewayr—   zRorigin names profile %r; plugins may only start sessions in their own profile (%s)zinvalid origin (%s)r9   z&no connected %s adapter for profile %sz.origin %s does not resolve to a served profilez;origin %s routes to profile %s, not the plugin's profile %s)r•   ÚdictÚpopr
   Ú	from_dictÚKeyErrorÚ	TypeErrorÚ
ValueErrorrW   rX   rY   Ú_adapters_for_profiler    ÚweakrefÚrefÚ_transport_adapter_refÚ_canonicalizeÚruntime_profile)r   r%   r&   r-   rÜ   r—   ÚfieldsÚ	requestedr:   ÚexcÚwherer»   Úidentitys   &&$d         r   rU   Ú1GatewayPluginInjectionMixin._plugin_origin_source
  sm  ø€ ÷	fð 	fð ×/Ñ/°Ó<ˆØŠ?ÙÐNÐP[Ó\Ð\Ü�f“ˆØ—J‘J˜y¨$Ó/ˆ	ß˜Ô-ÙÐoØ$ó/ð /ð	7Ü"×,Ò,¨VÓ4ˆFð —?‘?×(Ñ(Ð)¨¨6¯>©>Ð*:Ð;ˆØ×,Ñ,¨WÓ5×9Ñ9¸&¿/¹/ÓJˆØŠ?ÙÐCÀVÇ_Á_×EZÑEZÐ\cÓdÐdô )0¯ª°GÓ(<ˆÔ%Ø×%Ñ% fÓ-ˆØÒÙÐKÈUÓSÐSØ×#Ñ# wÔ.ÙÐXØ ×":Ñ":¸GóEð Eàˆøô! œ)¤ZÐ0ô 	7ÙÐ0°#Ó6Õ6ûð	7ús   ÁE ÅE.ÅE)Å#E.Å)E.c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   r:   r
   r&   r/   r-   r,   r   r0   r   )r   s   "r   r   r   0  s*   € ÷ ñ °ð È~ð Ðjmð Ðrvñ r   c               ó$  € ^ RI Hp ^ RIHp Ve	   V! W4      MRpVf   R# V P                  P                  V P                  V4      4      pVe   V! Wg4      e   R# \        P                  RW1P                  P                  VP                  4       R# )aK  Under the session authority a plugin turn borrows the connector provenance of a human
message already committed in that chat, and the gateway never mints it for a chat the
platform did not deliver: refuse such an origin here, so the plugin gets ``False`` instead of
a ``True`` for a turn the dispatch then drops. Dispatch rechecks.rœ   )Úcommitted_route_envelopeNTz†Plugin message injection refused: plugin=%s origin=%s/%s has no human message admitted yet; a plugin can continue a chat, not open oneF)rž   r�   Úgateway.session_automationrò   r‰   rŠ   Ú_session_key_for_sourcer=   rI   rW   rX   rY   )r   r:   r&   r-   r�   rò   r¡   r�   s   &&$$    r   rV   Ú5GatewayPluginInjectionMixin._plugin_origin_admissible0  sŠ   € õ
 	CÝGØ=HÒ=TÑ& tÔ9ÐZ^ˆ	ØÒÙØ×"Ñ"×8Ñ8¸×9UÑ9UÐV\Ó9]Ó^ˆØÒÑ!9¸)Ó!KÒ!WÙÜ�‰ð IØJS×UdÑUd×UjÑUjØ—~‘~ô	'ñ r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r:   r
   r+   r,   r-   r   r0   r   )r   s   "r   r   r   B  s,   € ÷ 'ñ 'Ø&ð'Ø14ð'ØADð'à	ñ'r   c             ƒ  óÌ  "  € RVP                   P                   RVP                   2pV P                  4       '       g   R# V P	                  V4      pVf   \
        P                  RV4       R# V P                  WVR7      '       g   R# V P                  V4      pV P                  V4      ;_uu_4       GRj  x€L
  ^ RI
Hp V! V 4      e‰   V P                  P                  V4      G Rj  x€L
 pVf*   \
        P                  RW44        RRR4      GRj  x€L
  R# V P                  WQWhP                  W#R	7      G Rj  x€L
 uuRRR4      GRj  x€L
  # VP!                  \#        V\$        P&                  VR
RRVRR
RV/R7      4      G Rj  x€L
  RRR4      GRj  x€L
  \
        P)                  RW4V4       R
#  EL LÑ L¨ L‚ Ls L8 L*  + GRj  x€L 
 '       g   i     LA; i5i)z®Start (or continue) the session at a plugin-supplied origin through the adapter's normal
message path: ``get_or_create_session`` creates it, the reply goes back to that chat.r8   r9   FNzBPlugin message injection: adapter for %s went away before dispatchr¦   ©Úactive_authorityz]Plugin message injection refused: plugin=%s %s has no session under the session authority yetr§   Tr©   rª   r«   r®   z<Plugin message injection dispatched: plugin=%s %s session=%s)rW   rX   rY   rp   r¶   r=   rI   r‚   rô   r{   rž   rù   r´   rŠ   r·   r¨   r¸   r   r	   r¹   rº   )	r   r:   r+   r-   rK   r»   r$   rù   r�   s	   &$$$     r   rZ   Ú=GatewayPluginInjectionMixin._dispatch_plugin_origin_injectionB  s¼  é € ð
 ˜6Ÿ?™?×0Ñ0Ð1°°6·>±>Ð2BÐCˆØ×/Ñ/×1Ò1ÙØ×,Ñ,¨VÓ4ˆØŠ?Ü�N‰NÐ_ÐagÔhÙØ×0Ñ0°ÐU[Ð0×\Ò\ÙØ×2Ñ2°6Ó:ˆØ×/Ñ/°×7×7Õ7ÝDÙ Ó%Ò1ð #×6Ñ6×LÑLÈ[ÓY×Y�Ø’=Ü—N‘Nð $?Ø@IôSà ÷ 8×7Ñ7ð "×9Ñ9Ø°×IYÑIYØ#ð :ó :÷ :÷ 8×7Ò7ð ×(Ñ(¬Ø¬;×+;Ñ+;ÀFÐUYØ&+ð '¨	Ð3LÈdØ)¨;ðô	*ó ÷ ð ÷ 8×7ô. 	�‰ÐRÐT]ÐgrÔsÙò1 8ñ Zñ 8ñ:ñ 8ñ÷ 8×7×7Ò7üsÀ   ‚B5G$Â7F9Â8G$Â;/GÃ*F<Ã+GÄ
G$ÄF>ÄG$Ä!GÄ=G Ä>GÅG$ÅGÅG$Å7GÆGÆGÆG$ÆGÆG$Æ<GÆ>G$Ç GÇG$ÇGÇG$ÇG!	ÇGÇ
G!	ÇG!	ÇG$c               ó0   € V ^8„  d   QhRRRRRRRRRRRR	/# )
r   r:   r
   r$   r,   r¨   r+   r-   r   zOptional[bool]r   )r   s   "r   r   r   k  s>   € ÷ ñ Ø,ðØ>AðØORðØ]`ðàðð 
ñr   c             ƒ  óÊ  "  € ^ RI Hp V! V 4      pVf   R# ^ RIp	^ RIp
^ RIHp V	P                  RWcV
P                  4       P                  .RR7      p\        V\        P                  VRRVRVR	V/R
7      p VP                  WV4      G Rj  x€L
  \        P!                  RYcT4       R#  L  T d-   p\        P                  RYcTP                  4        Rp?R# Rp?ii ; i5i)ac  Under a session authority, commit the plugin turn into the session's durable FIFO as a
trusted producer admission (the heartbeat / completion seam) instead of running it on the
in-process lane beside an admitted turn. ``None`` means no authority serves this scope and
the caller keeps the standalone adapter path; a refused admission is ``False``, logged.rø   N)ÚRuntimeStoreErrorÚplugin)Ú
separatorsTFr«   r¬   )r¯   r°   r:   r±   r²   Ú
message_idr³   zTPlugin message injection refused by the session authority: plugin=%s session=%s (%s)zEPlugin message injection admitted: plugin=%s session=%s session_id=%s)Ú,Ú:)rž   rù   ÚjsonÚuuidÚhermes_state_runtimerý   ÚdumpsÚuuid4Úhexr   r	   r¹   Úadmit_automationr=   rI   rØ   rº   )r   r»   r:   r$   r¨   r+   r-   rù   r¡   r  r  rý   rî   Úeventrì   s   &&&$$$$        r   r·   Ú3GatewayPluginInjectionMixin._admit_plugin_injectionk  sÞ   é € õ 	AÙ$ TÓ*ˆ	ØÒÙÛÛÝ:Ø—:‘:˜x¨ÀÇÁÃ×AQÑAQÐRÐ_i�:ÓjˆÜØ¤{×'7Ñ'7ÀÐQUØ"'°HØ+¨[Ð:NÐPZÐ[ô
ˆð
	Ø×,Ñ,¨W¸XÓF×FÐFô
 	�‰Ð[Ø¨Jô	8áñ GøØ ô 	Ü�N‰NÐqØ$°3·:±:ô?åûð	üsB   ‚A5C#Á8B- ÂB+ÂB- ÂC#Â+B- Â-C Â4!CÃC#ÃC Ã C#r   rÈ   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r"   r   rp   r{   r‚   r[   r�   rŽ   r\   rµ   r•   rU   rV   rZ   r·   Ú__static_attributes__r   r   r   r   r      s›   † õTõ3ðGØLPðGà.2ðGàRVðGð ðGð ;=÷GõRZ÷cõõoõõ$ð +Ø_c÷+õZTõ[õ&$õLõ$'÷Rñ r   r   )Ú__doc__Ú
__future__r   rD   Úconcurrent.futuresrF   rx   re   rå   Úpathlibr   Útypingr   r   r   Úgateway.configr   Úgateway.platforms.eventr   r	   Úgateway.sessionr
   Ú	getLoggerr=   r   r   r   r   Ú<module>r     sL   ðñ:õ #ã Û Û Û Û Ý ß )Ñ )å #ß =Ý )à	×	Ò	˜=Ó	)€÷nó nr   