+
    jHàj—t  ã                   óª  a € Ri t40 t R t^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	H
t
 ^ RIHtHtHtHtHtHt ]P$                  ! R4      tR R ltRsR	 R
 ltR R ltR R ltRjR R lltR R ltRRR]R3RRRR R3.]! RRR4      ORkN]! R4      ORRRR R3N]! R4      ORlNRmN]! RR R!R"R#R$R%R&4      OR'R'RR]3N]! R(4      O5t] ^ k R) R* ltR+ R, ltR-]! 4       /R. R/ lltR0 R1 lt R2 R3 lt!R4 R5 lt"]! ]PF                  04      t$]! ]PJ                  ]PL                  04      t'R6 R7 lt(RnR8RR9 3.](! R:R;R<R=R>4      OR?]$R3NR@]$R3NRA]$R3N](! RBRCRD4      ORE]$R3N](! RFRGRHRIRJRKRLRM4      ORN]'R3NROR]"3N](! RPRQRR4      O5t)] ^k RSR/RT RU llt*RoRV RW llt+RX RY lt,RZ R[ lt-R\R/R] R^ llt.RpR_ R` llt/RqRa Rb llt0Rc Rd lt1Re Rf lt2Rg Rh lt3R# )ruì  config.yaml / gateway.json â†’ ``GatewayConfig.from_dict`` schema (the ``load_gateway_config`` phases).

Precedence for top-level keys: key-presence at the TOP LEVEL of config.yaml wins; the nested
``gateway.<key>`` form (what ``hermes config set gateway.<key>`` produces) is consulted only when the
top-level key is absent â€” not merely falsy/mistyped â€” so a present-but-empty top-level value is never
silently replaced by the nested one. Both overwrite whatever legacy gateway.json set.
N)ÚPath)ÚAnyÚOptional)ÚUNAUTHORIZED_DM_BEHAVIORSÚPlatformÚPlatformConfigÚ_coerce_dictÚ
_dict_slotÚ_normalize_choicezgateway.configc                ó0   € V ^8„  d   QhR\         R\        /# ©é   ÚhomeÚreturn)r   r   )Úformats   "Ú:/home/ubuntu/.hermes/hermes-agent/gateway/config_loader.pyÚ__annotate__r      s   € ÷ ñ ¤4ð ¬Cñ ó    c                óz  € V R,          pVP                  4       '       g   / #  \        VRRR7      ;_uu_ 4       p\        P                  ! V4      ;'       g    / pRRR4       \        P                  RV4       X#   + '       g   i     L(; i  \         d#   p\        P                  RY4       / u Rp?# Rp?ii ; i)ua   Legacy ``gateway.json`` base layer (config.yaml keys always win). Malformed â†’ ``{}`` + warning.zgateway.jsonÚrú	utf-8-sig©ÚencodingNu<   Loaded legacy %s â€” consider moving settings to config.yamlzFailed to load %s: %s)ÚexistsÚopenÚjsonÚloadÚloggerÚinfoÚ	ExceptionÚwarning)r   ÚpathÚfÚdataÚes   &    r   Úload_legacy_gateway_jsonr%      s�   € à�.Õ €DØ�;‰;�=Š=Øˆ	ðÜ�$˜ k×2Õ2°aÜ—9’9˜Q“<×%Ð% 2ˆD÷ 3ä�‰ÐRÐTXÔYØˆ÷ 3×2ûô ô Ü�‰Ð.°Ô8Ø�	ûðús4   £B ¹!A:ÁB Á:B
	ÂB ÂB:ÂB5Â/B:Â5B:Fc                ó:   € V ^8„  d   QhR\         \        ,          /# ©r   r   )r   Ústr)r   s   "r   r   r   9   s   € ÷ [ñ [¤¬#¥ñ [r   c                 ó\   € \         '       d    \        P                  P                  R4      # R# )zW``os.environ['GATEWAY_ALLOW_ALL_USERS']`` when it is the bridge's own write, else None.ÚGATEWAY_ALLOW_ALL_USERSN)Ú_BRIDGED_ALLOW_ALL_USERSÚosÚenvironÚget© r   r   Úbridged_allow_all_usersr0   9   s!   € ç8PÓ8PŒ2�:‰:�>‰>Ð3Ó4ÐZÐVZÐZr   c                ó0   € V ^8„  d   QhR\         R\         /# )r   Úenvr   ©Údict)r   s   "r   r   r   >   s   € ÷ ñ œ$ð ¤4ñ r   c                óB   € \        4       e   V P                  RR4       V # )zbRemove the bridge-owned ``GATEWAY_ALLOW_ALL_USERS`` from a child-process env (operator-set stays).Nr*   )r0   Úpop)r2   s   &r   Údrop_bridged_envr7   >   s   € äÓ Ò,Ø�‰Ð)¨4Ô0Ø€Jr   c                ó0   € V ^8„  d   QhR\         R\        /# ©r   Úvaluer   ©r   Úbool)r   s   "r   r   r   D   s   € ÷ ñ œcð ¤dñ r   c                 óˆ   € \        V \        4      '       d   R # \        P                  R\	        V 4      P
                  4       R# )TzIIgnoring invalid quick_commands in config.yaml (expected mapping, got %s)F)Ú
isinstancer4   r   r    ÚtypeÚ__name__)r:   s   &r   Ú_quick_commands_okrA   D   s3   € Ü�%œ×ÒÙÜ
‡N�NØSÜˆU‹×Ñôñ r   c                ó<   € V ^8„  d   QhR\         R\        R\        /# )r   r:   Údefaultr   )r   r(   )r   s   "r   r   r   N   s&   € ÷ Hñ Hœsð H¬Sð H¼cñ Hr   c                 ó$   € \        V \        V4      # ©N)r
   r   )r:   rC   s   &&r   Ú_dm_behavior_choicerF   N   s   € Ü˜UÔ$=¸wÓGÐGr   c                ó0   € V ^8„  d   QhR\         R\        /# ©r   Úkeysr   ©r(   Útuple)r   s   "r   r   r   R   s   € ÷ ?ñ ?”Sð ?œUñ ?r   c                  óZ   € \         ;QJ d    . R  V  4       F  NK  	  5# ! R  V  4       4      # )c              3   ó.   "  € T F  qVR RR3x € K  	  R# 5i)ÚpresenceNr/   ©Ú.0Úks   & r   Ú	<genexpr>Ú_presence.<locals>.<genexpr>S   s   é € Ð>¹°A�Q˜
 D¨$Õ/»ùs   ‚©rK   ©rI   s   *r   Ú	_presencerV   R   s$   € ßŒ5Ñ>¹Ó>�5Ð>ˆ5Ñ>¹Ó>Ó>Ð>r   Úquick_commandsÚnoneÚsttrN   c                 ó"   € \        V \        4      # rE   )r>   r4   ©Úvs   &r   Ú<lambda>r]   Y   s   € ¬°A´tÔ)<r   Ústt_echo_transcriptsÚgroup_sessions_per_userÚthread_sessions_per_userÚroom_link_urlÚprofile_routesc                 ó"   € \        V \        4      # rE   )r>   Úlistr[   s   &r   r]   r]   ]   s   € ¼:ÀaÌÔ;Nr   Úmax_concurrent_sessionsÚreset_triggersÚalways_log_localÚwrite_sessions_jsonÚloop_watchdogÚloop_watchdog_probe_interval_sÚloop_watchdog_probe_timeout_sÚloop_watchdog_max_strikesÚfilter_silence_narrationÚunauthorized_dm_behaviorÚunauthorized_dm_decline_messagec                ó`   € V ^8„  d   QhR\         R\        R\         R\        R\        R\        /# )r   Úyaml_cfgÚgateway_sectionÚgw_dataÚkeyÚmoder   )r4   r   r(   rK   )r   s   "r   r   r   k   s8   € ÷ *ñ *œTð *´Cð *Ä$ð *ÌSð *ÔX[ð *Ô`eñ *r   c                óØ  € \        V\        4      pVR9   d8   W09   d   RW,          3# V'       d   W19   d   VR8X  g   W29  d   RW,          3# R# VR8X  d   V'       d   W19   d   RW,          3# R# V P                  V4      pVR8X  d$   Vf   V'       d   VP                  V4      pVRJV3# \        V\        4      '       g   V'       d   VP                  V4      p\        V\        4      V3# )zDReturn ``(found, value)`` for *key* under the given fallback *mode*.rN   TNÚnestedrX   )rN   Úgwdata)FN©r>   r4   r.   )rq   rr   rs   rt   ru   rw   r:   s   &&&&&  r   Ú_bridge_lookuprz   k   sá   € ä˜¬Ó.€FØÐ%Ô%ØŒ?Ø˜�Ð&Ð&ß�cÔ,°$¸*Ô2DÈÔHZØ˜Õ-Ð-Ð-ØÐØˆxÔß/5¸#Ô:P��oÕ*Ð+ÐcÐVcÐcØ�L‰L˜Ó€EØˆv„~ØŠ=ŸVØ#×'Ñ'¨Ó,ˆEØ˜DÐ  %Ð'Ð'ä�eœT×"Ò"§vØ×#Ñ# CÓ(ˆÜ�eœTÓ" EÐ)Ð)r   c                ó@   € V ^8„  d   QhR\         R\        R\         RR/# )r   rq   rr   rs   r   N)r4   r   )r   s   "r   r   r   �   s/   € ÷ Cñ C¤4ð C¼#ð CÌð CÐQUñ Cr   c                 ó¦   € \          FF  w  r4rVp\        WW#V4      w  r‰V'       d   Ve   V! V	4      '       g   K2  V'       d	   V! V	4      MT	W$&   KH  	  R # rE   )Ú_TOPLEVEL_BRIDGErz   )
rq   rr   rs   Úyaml_keyÚgw_keyru   ÚacceptÚ	transformÚfoundr:   s
   &&&       r   Úbridge_toplevel_keysrƒ   �   sH   € ß5EÑ1ˆ˜$¨	Ü% hÀÐTXÓY‰ˆß˜Ò+±F¸5·M²MÙß.7™) EÔ*¸Uˆ‹ó	 6Fr   Úalsoc          
      óT   € V ^8„  d   QhR\         R\        R\         R\        R\         /# )r   rq   Úgateway_cfgrs   r„   r   )r4   r   Ú	frozenset)r   s   "r   r   r   ‹   s1   € ÷ "ñ "¤dð "¼ð "Ätð "ÔV_ð "Ôrvñ "r   c          
     ó–  a€ \        VR4      oR V3R llp\        V\        4      '       d   TM/ pV! VP                  R4      4       V! V P                  R4      4       T! VP	                  4        UUu/ uFA  w  rgVR8w  g   K  \        V\        4      '       g   K&  Wc9   g   \        V4      '       g   K?  WgbKC  	  upp4       S# u uppi )uà  Merge every place a platform block may live into ``gw_data["platforms"]`` and return it.

Order (later wins on shared keys, ``extra`` deep-merged so gateway.json defaults survive):
``gateway.platforms.*`` â†’ top-level ``platforms.*`` â†’ ``gateway.<platform>`` subsections (nested
first so top-level config keeps precedence, matching the gateway.streaming fallback). An
``enabled`` key in any block sets the ``_enabled_explicit`` marker consumed by the env pass.
Top-level adapter keys (``gateway.api_server.port: 8642``) reach ``extra`` in
``PlatformConfig.from_dict``. *also* names platforms whose ``gateway.<platform>`` shorthand counts
even while no adapter is registered (a platform that left core, read before its plugin loads).
Ú	platformsc                ó(   € V ^8„  d   QhR\         RR/# )r   Úsource_platformsr   N©r   )r   s   "r   r   Ú-merge_platform_sections.<locals>.__annotate__˜   s   € ÷ /ñ /¤ð /¨ñ /r   c                 ó„  <€ \        V \        4      '       g   R # V P                  4        F’  w  r\        V\        4      '       g   K  SP                  V/ 4      p\        V\        4      '       d   TM/ p/ VP                  R/ 4      CVP                  R/ 4      CpRV9   d   RVR&   / VCVCpV'       d   WER&   VSV&   K”  	  R # )NÚextraÚenabledTÚ_enabled_explicit)r>   r4   Úitemsr.   )r‹   Ú	plat_nameÚ
plat_blockÚexistingÚmerged_extraÚmergedÚplatforms_datas   &     €r   ÚmergeÚ&merge_platform_sections.<locals>.merge˜   s»   ø€ ÜÐ*¬D×1Ò1ÙØ%5×%;Ñ%;Ö%=Ñ!ˆIÜ˜j¬$×/Ò/ÙØ%×)Ñ)¨)°RÓ8ˆHÜ#-¨h¼×#=Ò#=‘xÀ2ˆHØW˜hŸl™l¨7°BÓ7ÐW¸:¿>¹>È'ÐSUÓ;VÐWˆLØ˜JÔ&Ø48�Ð0Ñ1Ø/˜Ð/ JÐ/ˆFßØ".�w‘Ø(.ˆN˜9Ó%ó &>r   )r	   r>   r4   r.   r’   Ú_is_platform_name)	rq   r†   rs   r„   r™   Únested_gatewayrQ   r\   r˜   s	   &&&$    @r   Úmerge_platform_sectionsr�   ‹   s¾   ø€ ô   ¨Ó5€N÷/ð /ô  %/¨{¼D×$AÒ$A‘[Àr€NÙ	ˆ.×
Ñ
˜[Ó
)Ô*Ù	ˆ(�,‰,�{Ó
#Ô$Ù	˜N×0Ñ0Ô2ô `Ñ2‘D�AØ�;Ñô Ü#-¨a´×#6ô Ø<=¼IÔIZÐ[\×I]ô ˆ1Š4Ñ2ò `ô aàÐùó`s   Á4C
ÂC
ÂC
Â5C
c                ó0   € V ^8„  d   QhR\         R\        /# )r   rt   r   r;   )r   s   "r   r   r   °   s   € ÷ ñ œ3ð ¤4ñ r   c                 óN   €  \        V 4       R#   \        \        3 d     R # i ; i)FT)r   Ú
ValueErrorÚAttributeError)rt   s   &r   r›   r›   °   s,   € ðÜ�Œñ øô œÐ'ô Úðús   ‚ �$£$c                óH   € V ^8„  d   QhR\         R\        R\        R\        /# )r   rq   ÚnameÚgateway_platformsr   )r4   r(   r   rK   )r   s   "r   r   r   ¸   s(   € ÷ 	ñ 	œtð 	¬3ð 	Ä3ð 	Ì5ñ 	r   c                óª   a€ V P                  S4      p\        V\        4      pV'       g(   V3R lW P                  R4      3 4       p\        WS4      pW43# )zß``(section, is_toplevel)`` for platform *name*: a top-level ``<name>:`` block wins; otherwise
the block under ``gateway.platforms`` / ``platforms`` so shared-key bridging and adapter hooks
still run for nested-only configs.c              3   ó´   <"  € T FM  p\        V\        4      '       g   K  \        VP                  S4      \        4      '       g   KB  VS,          x € KO  	  R # 5irE   ry   )rP   Úsrcr£   s   & €r   rR   Ú#platform_section.<locals>.<genexpr>¿   s`   øé € ð  TÑ'U ÔYcÐdgÔim×Yn”)Ôs}ð  B÷  Fñ  Fð  GKó  Lô  NR÷  tS”)�#�d—)’)Ó'Uùs   ƒA "AÁAr‰   )r.   r>   r4   Únext)rq   r£   r¤   ÚsectionÚtoplevelrw   s   &f&   r   Úplatform_sectionr¬   ¸   sR   ø€ ð �l‰l˜4Ó €GÜ˜'¤4Ó(€Hßô TÐ(9¿<¹<ÈÓ;TÑ'Uó  TˆÜ�vÓ'ˆØÐÐr   c                ó0   € V ^8„  d   QhR\         R\         /# r9   rŒ   )r   s   "r   r   r   Ä   s   € ÷ Wñ W”cð Wœcñ Wr   c                 óš   € \        V \        4      '       d/   V P                  4        UUu/ uF  w  r\        V4      VbK  	  upp# T # u uppi rE   )r>   r4   r’   r(   )r:   rQ   r\   s   &  r   Ú
_str_keyedr¯   Ä   s<   € Ü4>¸uÄd×4KÒ4K %§+¡+¤-Ô0¡-™$˜!ŒC�‹F�AŠI¡-Ò0ÐVÐQVÐVùÓ0s   ªAc                ó0   € V ^8„  d   QhR\         R\        /# rH   rJ   )r   s   "r   r   r   Ë   s   € ÷ 0ñ 0”#ð 0œ%ñ 0r   c                 óZ   € \         ;QJ d    . R V  4       F  NK  	  5# ! R V  4       4      # )z7Keys copied verbatim into ``extra`` for every platform.c              3   ó*   "  € T F	  qR R 3x € K  	  R # 5irE   r/   rO   s   & r   rR   Ú_plain.<locals>.<genexpr>Í   s   é € Ð/©$ Q�T˜4•«$ùs   ‚rT   rU   s   *r   Ú_plainr´   Ë   s$   € çŒ5Ñ/©$Ó/�5Ð/ˆ5Ñ/©$Ó/Ó/Ð/r   Únotice_deliveryc                 ó    € \        V R R0R 4      # )ÚpublicÚprivate)r
   r[   s   &r   r]   r]   Ô   s   € Ô(9¸!¸hÈ	Ð=RÐT\Ô(]r   Úreply_prefixÚreply_in_threadÚcron_continuable_surfaceÚrequire_mentionÚsend_read_receiptsÚallowed_chatsÚgroup_allowed_chatsÚallowed_topicsÚfree_response_channelsÚmention_patternsÚexclusive_bot_mentionsÚ"observe_unmentioned_group_messagesÚ	dm_policyÚ
allow_fromÚallow_admin_fromÚuser_allowed_commandsÚgroup_policyÚgroup_allow_fromÚgroup_allow_admin_fromÚgroup_user_allowed_commandsÚchannel_skill_bindingsÚchannel_promptsÚgateway_restart_notificationÚtyping_indicatorÚtyping_status_textÚ
root_blockc          
      óT   € V ^8„  d   QhR\         R\        R\        R\        R\        /# )r   ÚplatÚplatform_cfgrs   rÒ   r   )r   r4   r<   )r   s   "r   r   r   ä   s1   € ÷ ñ œð ´ð ¼tð ÔTXð Ôeiñ r   c               óþ  € / pV'       d~   \         P                  R0,          pTP                  VP                  4        UUu/ uF  w  rgWe9  g   K  WgbK  	  upp4       VP                  \	        VP                  R/ 4      4      4       \         Fe  w  r‰p
W�9  g   V	e	   W	9  d   K  V
R8X  d'   \        W,          VP                  RR4      4      WH&   KE  V
'       d   V
! W,          4      MW,          WH&   Kg  	  V# u uppi )a  Shared-key bridge; a ROOT-level ``<platform>:`` block (which ``merge_platform_sections``
never copies into ``platforms_data``) also gets its adapter keys promoted into ``extra``, with
the same typed-key exclusion and explicit-``extra`` precedence as ``PlatformConfig.from_dict``.Úchannel_overridesr�   Údmrn   Úpair)r   Ú_TYPED_KEYSÚupdater’   r   r.   Ú_SHARED_KEYSrF   )rÔ   rÕ   rs   rÒ   ÚbridgedÚtypedrQ   r\   rt   Úonlyr�   s   &&&$       r   Ú_bridged_keysrà   ä   sÙ   € ð €GßÜ×*Ñ*Ð.AÐ-BÕBˆØ�‰¨×);Ñ);Ô)=ÔPÑ)=¡ ÀÁœ˜šÑ)=ÒPÔQØ�‰”| L×$4Ñ$4°W¸bÓ$AÓBÔCß ,Ñˆ�9ØÔ" tÒ'7¸DÔ<LÙØ˜ÔÜ.¨|Õ/@À'Ç+Á+ÐNhÐjpÓBqÓrˆG‹Lç;D™9 \Õ%6Ô7È,ÕJ[ˆG‹Lñ !-ð €Nùó Qs   Á
C9
ÁC9
c                ó$   € V ^8„  d   QhR\         /# r'   )rd   )r   s   "r   r   r   ÷   s   € ÷ ñ ´4ñ r   c                óJ  € \        \        4      pVf   V e   V P                  4       MRpV F_  p\        P                  ! \
        \        4      ;_uu_ 4        \        VP                  4      ;qB9  d   VP                  V4       RRR4       Ka  	  V#   + '       g   i     Kv  ; i)a  Built-in platforms plus registered plugin platforms (so plugin authors get shared-key bridging).

*entries* are the plugin entries to bridge (``load_yaml_layer`` passes only the configured
ones, see ``gateway.platform_activation``); None means every registered plugin platform.Nr/   )	rd   r   Úplugin_entriesÚ
contextlibÚsuppressr    ÚKeyErrorr£   Úappend)ÚregistryÚentriesÚtargetsÚentryrÔ   s   &&   r   Úshared_loop_targetsrì   ÷   s   € ô
 œ“N€GØ‚Ø/7Ò/C�(×)Ñ)Ô+ÈˆÛˆÜ× Ò ¤¬X×6Õ6Ü  §¡Ó,Ð,�Ô<Ø—‘˜tÔ$÷ 7Ñ6ñ ð €N÷ 7×6Ð6ús   Á-BÂB"c                ó0   € V ^8„  d   QhR\         R\         /# )r   r˜   r   r3   )r   s   "r   r   r     s   € ÷ 	ñ 	¬Dð 	´Tñ 	r   c                óÊ   € V P                  4        UUu/ uFA  w  r\        V\        4      '       g   K  V\        \        VP	                  R4      4      4      bKC  	  upp# u uppi )a¹  ``{plat_name: extra}`` as the user authored it under ``platforms.<plat>.extra``, captured
right after ``merge_platform_sections`` and BEFORE either copy site runs. Reading
``platforms_data`` live at a copy site would mistake values the earlier site bridged from the
block's own ``extra:`` sub-dict for authored ones (``telegram: {reply_to_mode: all, extra:
{reply_to_mode: off}}`` must still resolve to ``all``). Copies, never creates slots.r�   )r’   r>   r4   r   r.   )r˜   r£   rÔ   s   &  r   Úsnapshot_authored_extrarï     sW   € ð )×.Ñ.Ô0ôá0‰JˆD´J¸tÄT×4Jô 	4ˆŒd”< §¡¨Ó 1Ó2Ó3Ò3Ù0òð ùó s
   ”A³(Ac                óH   € V ^8„  d   QhR\         R\         R\         R\         /# )r   ÚauthoredÚmanagedr˜   r   r3   )r   s   "r   r   r     s)   € ÷ ñ ¤4ð ´$ð Ìð ÔQUñ r   c           	     óF  € V'       g   / # ^ RI Hp \        WP                  R4      / 4      p/ pV P	                  4        EFY  w  rg\        VP                  V4      4      p\        VP                  V4      4      p	\        V4      \        \        VP                  R4      4      4      ,          \        V	4      ,          p
V
\        \        V	P                  R4      4      4      ,
          \        V4      ,           F  pW{ K  	  \        V	P                  R4      4      pVP                  V! W|4      4       V'       g   Kû  \        \        W&4      R4      pVP                  V! WÜ4      4       V Uu/ uF#  pV\        P                  9  g   K  W·V,          bK%  	  upWV&   EK\  	  V# u upi )zôRemove from *authored* (in place) every key the administrator pinned in a managed ``<plat>:``
block: the user's ``platforms.<plat>.extra`` must not outrank it. A key the managed layer itself
sets under ``platforms.<plat>.extra`` stays authored.)Ú_deep_mergeÚgatewayr�   )Úhermes_cli.configrô   r�   r.   r’   r   ÚsetrÛ   r	   r   rÚ   )rñ   rò   r˜   rô   Úmanaged_platformsÚ	hook_pinsr£   r�   Úrootrw   Úpinnedrt   Úmanaged_extraÚdestinations   &&&           r   Ú_apply_managed_extrarþ     sY  € ÷ Øˆ	Ý-ä/°¿¹ÀYÓ9OÐQSÓTÐØ€IØ—~‘~×'‰ˆÜ˜GŸK™K¨Ó-Ó.ˆÜÐ/×3Ñ3°DÓ9Ó:ˆÜ�T“œS¤¨d¯h©h°wÓ.?Ó!@ÓAÕAÄCÈÃKÕOˆØœS¤¨f¯j©j¸Ó.AÓ!BÓCÕCÄsÈ5Ãz×QÐQˆCØ’
ñ Rô % V§Z¡Z°Ó%8Ó9ˆØ�‰‘[ Ó6Ô7÷ ‰=Ü$¤Z°Ó%EÀwÓOˆKØ×Ñ™{¨;ÓFÔGÙ:Gó I¹-°3Ø"%¬^×-GÑ-GÑ"Gô  /˜s¨#¥Jš¹-ñ IˆIŒOñ (ð" ÐùòIs   Å)FÆFÚwarnedc                óv   € V ^8„  d   QhR\         R\         R\        R\        R\        \        ,          R\         /# )r   r�   Úblockr“   r«   rÿ   r   )r4   r(   r<   r   r÷   )r   s   "r   r   r   0  s>   € ÷ !ñ !œ$ð !¤tð !¼ð !Ì$ð !ÔX`ÔadÕXeð !Ôquñ !r   c               ó�  a aaa€ Sf   \        4       oV'       d   RS R2MRS 2oR V VVV3R llpV! V4      p\        VP                  R4      \        4      '       dc   V! VR,          4      VR&   TP	                  VR,           Uu/ uF-  pVS 9   g   K  V\
        P                  9  g   K#  VS V,          bK/  	  up4       V# u upi )uÞ  Effective ``<plat>:`` block for YAMLâ†’extra/env bridging: *block* (top-level or
nested) overlaid with the keys the user authored in ``platforms.<plat>.extra``.

Returns a NEW dict and never mutates *block* or *extra*. For every key present in
both with DIFFERENT values, ONE warning logs that the authored extra took precedence
(equal values are silent). *warned* dedupes across both copy sites within one
``load_yaml_layer`` pass; ``None`` gives the caller a fresh local set.
zthe top-level 'z:' blockz
platforms.c                ó0   € V ^8„  d   QhR\         R\         /# )r   Úsourcer   r3   )r   s   "r   r   Ú$_authored_wins.<locals>.__annotate__=  s   € ÷ 	%ñ 	%œTð 	%¤dñ 	%r   c                 ó  <€ V  Uu/ uF  qS9   g   K  VSV,          bK  	  ppVP                  4        FK  w  r4W,          V8w  g   K  SV3S9  g   K  SP                  SV34       \        P                  R VSSS4       KM  	  / V CVC# u upi )zL%s set in both %s and platforms.%s.extra; platforms.%s.extra took precedence)r’   Úaddr   r    )	r  rQ   Úoverlayrt   r:   r�   r“   rÿ   Úwheres	   &    €€€€r   Úoverlay_ontoÚ$_authored_wins.<locals>.overlay_onto=  s�   ø€ Ù(.Ó=© 1°u±*”;�1�e˜A•h’;©ˆÐ=Ø!Ÿ-™-ž/‰JˆCØ�{˜eÖ#¨°CÐ(8ÀÖ(FØ—
‘
˜I sÐ+Ô,Ü—‘ØbØ˜ 	¨9öñ *ð %�&Ð$˜GÐ$Ð$ùò >s
   †B“Br�   )r÷   r>   r.   r4   rÛ   r   rÚ   )	r�   r  r“   r«   rÿ   r
  Ú	effectiverQ   r	  s	   f&f$d   @r   Ú_authored_winsr  0  sË   û€ ð ‚~Ü“ˆß5=ˆo˜i˜[¨Ñ1ÀZÐPYÈ{ÐC[€E÷	%ó 	%ñ ˜UÓ#€Iô �%—)‘)˜GÓ$¤d×+Ò+Ù)¨%°­.Ó9ˆ	�'Ñð 	×Ñ¨u°W®~ó Q©~¨!Ø %™Zô &Ø,-´^×5OÑ5OÑ,Oô &˜!˜U 1�Xš+©~ñ Qô 	RàÐùòQs   Â	CÂCÂ,Cc                óœ   € V ^8„  d   QhR\         R\        R\         R\         R\        R\        \        ,          R\        \         ,          RR	/# )
r   rq   r¤   rs   r˜   rê   rÿ   rñ   r   N)r4   r   rd   r   r÷   )r   s   "r   r   r   T  sV   € ÷ )ñ )Üð)Ü'*ð)Ü59ð)ÜKOð)ÜZ^ð)ä”S�Mð)ä,4´T­Nð)ð 
ñ)r   c           	     ó‚  € Vf   \        V4      pV EF¢  pV\        P                  8X  d   K  \        WP                  V4      w  r‰\        V\        4      '       g   KK  \        VP                  VP                  / 4      W‡P                  W•R7      p
\        WzW)R7      pRV9   pV'       d—   \        VP                  R4      \        4      '       dr   \        W7P                  4      p\        VR4       VR,          P                  4        UUu/ uF)  w  rï\        V\        4      '       g   K  \        V4      VbK+  	  uppVR&   T	;'       d    RV9   pV'       g   V'       g   V'       g   EKW  \        W7P                  4      p\        VR4      pV'       d   VR,          VR&   RVR&   VP                  V4       EK¥  	  R# u uppi )	u¹  Copy shared keys (allow_from, require_mention, â€¦) from each platform's YAML section into ``extra``.

``enabled`` is only written from a TOP-LEVEL block: for nested-only configs ``merge_platform_sections``
already merged it with the correct precedence. An explicit top-level enable/disable sets
``_enabled_explicit`` so the env pass honors ``enabled: false`` for migrated plugin platforms
instead of re-enabling them on token/SDK presence.
N©r«   rÿ   )rÒ   r×   r�   r�   Tr‘   )rï   r   ÚLOCALr¬   r:   r>   r4   r  r.   rà   r	   r’   r(   rÛ   )rq   r¤   rs   r˜   rê   rÿ   rñ   rÔ   rÕ   Úcfg_toplevelr  rÝ   Úhas_channel_overridesÚ	plat_dataÚcidÚov_dataÚenabled_was_explicitr�   s   &&&&&&&           r   Úbridge_platform_shared_keysr  T  sw  € ð ÒÜ*¨>Ó:ˆÜˆØ”8—>‘>Ô!ÙÜ%5°hÇ
Á
ÐL]Ó%^Ñ"ˆÜ˜,¬×-Ò-Ùô #Ø�L‰L˜Ÿ™ RÓ(¨,¿
¹
È\ôjˆ	ä °ÔRˆØ 3°|Ñ CÐß ¤Z°×0@Ñ0@ÐATÓ0UÔW[×%\Ò%\Ü" >·:±:Ó>ˆIÜ�y 'Ô*ð %1Ð1DÕ$E×$KÑ$KÔ$Mô.á$M‘L�CÜ˜g¤t×,ô "”�C“˜'Ò!Ù$Mò.ˆIÐ)Ñ*ð
  ,×IÐI°	¸\Ñ0IÐß×3×<QÚÜ˜~¯z©zÓ:ˆ	Ü˜9 gÓ.ˆßØ#/°	Õ#:ˆI�iÑ Ø)-ˆEÐ%Ñ&Ø�‰�W×ó9 ùó.s   Ä	F;Ä(F;c                óÈ   € V ^8„  d   QhR\         R\        R\         R\        \        ,          R\        \         ,          R\        \         ,          R\        \        ,          RR	/# )
r   rq   r¤   r˜   rÿ   rñ   rü   ré   r   N)r4   r   r   r÷   rd   )r   s   "r   r   r   €  sl   € ÷ %Wñ %WÜð%WÜ'*ð%WÜ<@ð%Wä”S�Mð%Wä,4´T­Nð%WäRZÔ[_ÕR`ð%Wô ”d�^ð%Wð 
ñ	%Wr   c           	     óö  € Vf   R# Vf   \        V4      pVf   VP                  4       MT EF  pVP                  f   K  \        WP                  V4      w  rš\        V	\        4      '       g   KD  \        VP                  VP                  / 4      W˜P                  W¤R7      pTP                  T;'       g    / P                  VP                  / 4      4        VP                  W4      p\        T\        4      '       g   KÕ  T'       g   Kß  \        \        Y(P                  4      R4      P                  T4       EK  	  R#   \         d.   p\        P                  RTP                  T4        Rp?EKG  Rp?ii ; i)u  Plugin-owned YAMLâ†’env config bridges (``PlatformEntry.apply_yaml_config_fn``). Order: shared-key
loop â†’ this dispatch â†’ core-only bridges (require_mention/signal) â†’ ``_apply_env_overrides()``.
*entries* limits the dispatch to those platforms (None = every registered entry).Nr  z&apply_yaml_config_fn for %s raised: %sr�   )rï   Úall_entriesÚapply_yaml_config_fnr¬   r£   r>   r4   r  r.   rÛ   r   r   Údebugr	   )rq   r¤   r˜   rè   rÿ   rñ   rü   ré   rë   rÕ   r  r  Úseededr$   s   &&&&&&&&      r   Úapply_plugin_yaml_hooksr  €  s/  € ð ÒÙØÒÜ*¨>Ó:ˆØ+2ª?�×%Ñ%Ô'ÀÓGˆð
 ×%Ñ%Ò-ÙÜ%5°hÇ
Á
ÐL]Ó%^Ñ"ˆÜ˜,¬×-Ò-Ùô #Ø�L‰L˜Ÿ™ RÓ(¨,¿
¹
È\ôjˆ	ð 	×Ñ˜-×-Ð-¨2×2Ñ2°5·:±:¸rÓBÔCð	Ø×/Ñ/°ÓDˆFô �fœd×#Ô#¯©ä”z .·*±*Ó=¸wÓG×NÑNÈv×Vó3 Høô( ô 	Ü�L‰LÐAÀ5Ç:Á:ÈqÔQÞûð	ús   ÃE Å E8Å!E3Å3E8c                ó4   € V ^8„  d   QhR\         R\         RR/# )r   rq   r˜   r   Nr3   )r   s   "r   r   r   ¨  s&   € ÷ <^ñ <^¤tð <^¼Tð <^Àdñ <^r   c                óX  € ^ RI Hp V! 4       pV P                  R4      pV P                  R4      pVf(   \        V\        4      '       d   VP                  R4      pV'       gš   \
        '       g   \        P                  ! R4      '       gr   \        V4      P                  4       R9   s\
        '       d*   R\        P                  R&   \        P                  R4       M \        P                  P                  RR4       V P                  R4      pVe»   RV P                  R	4      ;'       g    / 9  d›   VP                  \        P                   P"                  / 4      pVP                  R
/ 4      P                  RV4       V'       gG   \        P                  ! R4      '       g+   \        V4      P                  4       \        P                  R&   V P                  R/ 4      p\        V\        4      '       d¸   RV9   d¯   VP                  \        P$                  P"                  / 4      p	V	P                  R
/ 4      P                  RVR,          4       V'       gR   \        P                  ! R4      '       g4   \        VR,          4      P                  4       \        P                  R&   R# R# R# R# R# )u–  The YAMLâ†’env bridges that stay in core (per-platform ones live in plugin hooks).

Top-level ``require_mention`` â†’ Telegram when the ``telegram:`` section has none: users write it
alongside ``group_sessions_per_user`` expecting it to work, and the telegram plugin's hook only
runs when a telegram block exists. Signal ``require_mention`` â†’ ``SIGNAL_REQUIRE_MENTION`` (env wins).
``allow_all_users`` (top-level or ``gateway.allow_all_users``) â†’ ``GATEWAY_ALLOW_ALL_USERS``: every
allow-all reader (authz mixin, startup access check, own-policy adapters, plugin gates) consults
that env var, so the bridge is the one seam that makes the YAML key reach all of them (#110690).

Platform values are ALWAYS seeded into the owning platform's ``extra`` (the adapters read extra
first); the process-env write is skipped while a multiplexed secondary profile's scope is active â€”
the loader runs inside ``_profile_runtime_scope`` for every secondary, and a first-writer-wins write
there would make the secondary's policy the DEFAULT profile's (#80099 class). A secondary profile
sets ``GATEWAY_ALLOW_ALL_USERS`` in its own ``.env`` like every other scoped authorization gate.
)Úprofile_scopedrõ   Úallow_all_usersNr*   ÚtruezŽconfig.yaml allow_all_users: true grants every sender on every platform access (bridged to GATEWAY_ALLOW_ALL_USERS; an explicit env var wins).r¼   Útelegramr�   ÚTELEGRAM_REQUIRE_MENTIONÚsignalÚSIGNAL_REQUIRE_MENTION>   Ú1Úyesr$  )Úgateway.platforms._sharedr"  r.   r>   r4   r+   r,   Úgetenvr(   Úlowerr-   r   r    r6   Ú
setdefaultr   ÚTELEGRAMr:   ÚSIGNAL)
rq   r˜   r"  Úskip_env_bridgerr   Ú	allow_allÚtl_require_mentionÚtg_platÚ
signal_cfgÚsig_plats
   &&        r   Úbridge_core_env_settingsr7  ¨  s  € õ" 9á$Ó&€OØ—l‘l 9Ó-€OØ—‘Ð.Ó/€IØÒœZ¨¼×>Ò>Ø#×'Ñ'Ð(9Ó:ˆ	÷ × 8Ó 8ÄÇ	Â	ÐJc×@dÒ@dÜ#& y£>×#7Ñ#7Ó#9Ð=QÑ#QÐ ß#Ó#Ø4:ŒB�J‰JÐ0Ñ1ô �N‰NðRõô
 �J‰J�N‰NÐ4°dÔ;Ø!Ÿ™Ð&7Ó8ÐØÒ%Ð*;ÀHÇLÁLÐQ[ÓD\×DbÐDbÐ`bÔ*cØ ×+Ñ+¬H×,=Ñ,=×,CÑ,CÀRÓHˆØ×Ñ˜7 BÓ'×2Ñ2Ð3DÐFXÔY÷ ¤r§y¢yÐ1K×'LÒ'LÜ58Ð9KÓ5L×5RÑ5RÓ5TŒB�J‰JÐ1Ñ2ð —‘˜h¨Ó+€JÜ�*œd×#Ò#Ð(9¸ZÔ(GØ!×,Ñ,¬X¯_©_×-BÑ-BÀBÓGˆØ×Ñ˜G RÓ(×3Ñ3Ð4EÀzÐRcÕGdÔeß¤r§y¢yÐ1I×'JÒ'JÜ36°zÐBSÕ7TÓ3U×3[Ñ3[Ó3]ŒB�J‰JÐ/Ó0ñ (K‰ñ )HÑ#r   c                ó0   € V ^8„  d   QhR\         R\        /# r   ©r   r4   )r   s   "r   r   r   ç  s   € ÷ 9ñ 9œ4ð 9¤Dñ 9r   c                ó   € V R,          p/ pVP                  4       '       d7   ^ RIHp \        VRR7      ;_uu_ 4       pV! V4      ;'       g    / pRRR4       ^ RIHp V! V4      p^ RIHp VP                  V4      #   + '       g   i     L5; i)u  User ``config.yaml`` with the managed overlay applied â€” the YAML the gateway loader sees.

Raises on a malformed user file (the loader then falls back to env + gateway.json WITHOUT the
managed layer). An ABSENT user file is an empty layer, not a reason to skip the administrator's
values: a fleet host with no ``config.yaml`` must still honor them. Any pre-activation predicate
(``gateway.relay.relay_explicitly_disabled``) reads through here so it cannot disagree with
``load_gateway_config()`` on which files count.
zconfig.yaml)Úfast_safe_loadr   r   N)Ú_expand_env_vars©Úmanaged_scope)	r   Úutilsr;  r   rö   r<  Ú
hermes_clir>  Úapply_managed_overlay)r   Úconfig_yaml_pathrq   r;  r"   r<  r>  s   &      r   Úread_yaml_layersrC  ç  s   € ð ˜mÕ+ÐØ€HØ×Ñ× Ò õ 	)äÐ"¨[×9Õ9¸QÙ% aÓ(×.Ð.¨BˆH÷ :õ 3ñ   Ó)€Hõ )Ø×.Ñ.¨xÓ8Ð8÷ :×9ús   ½A=Á=B	c                ó4   € V ^8„  d   QhR\         R\        RR/# )r   r   rs   r   Nr9  )r   s   "r   r   r     s!   € ÷ %7ñ %7œ$ð %7¬ð %7°$ñ %7r   c                óè  € \        V 4      pV'       g   R# VP                  R4      p\        W#V4       \        V\        4      '       d   VP                  R4      MRp\        W#V4      p ^ RIHp V! 4        ^ RIH	p Rp	Ve    ^ RIHp
 VP                  V
! W%WR7      4      p	\!        Yyf   RM#V	 Uu. uF  qˆP"                  R	8X  g   K  VNK  	  up4      p\%        \        W#/ 4      4      p^ R
IHp \+        WÍP-                  / 4      V4      p\/        4       p\1        W$WW¿VR7       \3        W$WWWüWéR7       \5        W%4       R#   \         d#   p\        P                  RT4       Rp Rp?LëRp?ii ; iu upi )zhOverlay ``read_yaml_layers`` onto *gw_data* in place. Raises on any failure (caller warns + falls back).Nrõ   r‰   )Údiscover_plugins)Úplatform_registryzplugin discovery skipped: %s)Úactivation_predicate)rq   Úplatform_namesr   rè   Úpluginr=  )rÿ   rñ   )rÿ   rñ   rü   ré   )rC  r.   rƒ   r>   r4   r�   Úhermes_cli.pluginsrF  Úgateway.platform_registryrG  r   r   r  Úgateway.platform_activationrH  Úconfigured_entriesrì   r  rï   r@  r>  rþ   rA  r÷   r  r  r7  )r   rs   rq   rr   r¤   r˜   rF  rè   r$   ré   rH  rê   rñ   r>  rü   rÿ   s   &&              r   Úload_yaml_layerrO    sY  € ä Ó%€HßÙà—l‘l 9Ó-€OÜ˜°GÔ<Ü<FÀÔX\×<]Ò<]˜×+Ñ+¨KÔ8ÐcgÐÜ,¨XÈÓP€NðÝ7ÙÔÝKð €GØÒÝDØ×-Ñ-Ñ.BØÀ4ô/\ó ]ˆä! (²O©DÑU\ÓIuÑU\ÐPQ×`hÑ`hÐltÑ`tÏ!È!ÑU\ÑIuÓv€Gô 'Ô'>¸xÐZ\Ó']Ó^€HÝ(Ü(¨×3VÑ3VÐWYÓ3ZÐ\jÓk€MÜ“%€FÜØ W¸gÐ_gõiä˜H¸Ø#)ÈMõlä˜XÖ6øô- ô Ü�‰Ð3°QÔ7Ø�ûðüò Jvs$   Á)D? Â0E/
ÃE/
Ä?E,Å
E'Å'E,c                óh   € V ^8„  d   Qh/ ^ \         9   d
   \        ;R&   ^\         9   d
   \        ;R&   # )r   r}   rÜ   )Ú__conditional_annotations__rK   )r   s   "r   r   r      s<   € ÷ ñ ÷lò ”%ñ ñm÷bò Œeñ òcr   )rÙ   )Úmultiplex_profilesrR  rx   NN)Úsystemd_watchdog_secondsrS  rw   NN)Ú	streamingrT  r4   NN)rn   NrØ   rE   )NN)NNNN)5rQ  Ú__doc__rä   r   Úloggingr,   Úpathlibr   Útypingr   r   Úgateway.configr   r   r   r   r	   r
   Ú	getLoggerr   r%   r+   r0   r7   rA   rF   rV   r}   rz   rƒ   r‡   r�   r›   r¬   r¯   r/  Ú	_TELEGRAMÚDISCORDÚSLACKÚ_DISCORD_SLACKr´   rÜ   rà   rì   rï   rþ   r  r  r  r7  rC  rO  r   )rQ  s   @r   Ú<module>r_     sà  øðöó Û Û Û 	Ý ß  ç {× {ð 
×	Ò	Ð+Ó	,€õð@ !Ð õ[õ
õ÷Hõ?ð Ð'¨Ð1CÀTÐJØ
ˆE�:Ñ<¸dÐCðñ Ð%Ð'@ÐB\Ó]ðð Gð	ñ
 ˆÓðð Ð'¨Ñ1NÐPTÐUðñ Ð(Ó)ðð Sðð 3ðñ ØÐ,Ð.CÀ_Ø(Ð*IÐKfØ"óðð  Ð!;¸ZÈÐObÐcðñ  Ð0Ó1ñ!Ð ó õ(*õ,Cð"ÑbkÓbm÷ "õJõ	õWñ �x×(Ñ(Ð)Ó*€	Ù˜H×,Ñ,¨h¯n©nÐ=Ó>€õ0ð -Ø˜Ñ]Ð^ðñ ˆNÐ-Ð/IÐK\Ð^rÓsðð �i Ð&ð	ð
 ˜I tÐ,ðð �y $Ð'ðñ Ð$Ð&8Ð:RÓSðð *¨9°dÐ;ðñ Ø�\Ð#5Ð7NØÐ*Ð,DÐFcóðð ˜~¨tÐ4ðð ˜˜jÐ)ðñ Ð*Ð,>Ð@TÓUñ€ó ð$Ð[`÷ ÷&õ	õð<!Ðhl÷ !÷H)÷X%WõP<^õ~9÷B%7r   