+
    jHàjÚ%  ã                   ó  € R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
Ht ^ RIHtHtHt ^ RIHtHtHtHtHt ]P,                  ! R4      t]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 R ltR R lt ]!! 4       t"RR/R R llt#RR/R R llt$R R lt%RR/R  R! llt&R" R# lt'R$ R% lt(]! R&R'7       ! R( R)4      4       t)R*R3/t*]PV                  R4R+ R, ll4       t,R- R. lt-R/ R0 lt.R5R1 R2 llt/R# )6a9  Declarative env-credential bridge a platform plugin attaches to its ``PlatformEntry``.

A platform declares ``env_overrides`` (ordered ``step(config)`` callables, usually :class:`EnvCred`,
:func:`home_step`, :func:`reply_mode_step`) and ``env_enable_credentials`` (the env names its
explicit-disable WARNING cites). ``gateway.config_env._apply_env_overrides`` runs the steps of every
platform with activation evidence, so the data lives with the adapter instead of in a core table.

Import-light on purpose (only ``gateway.config``): adapters import it at module load.
N)Ú	dataclass)Úpartial)ÚPath)ÚAnyÚCallableÚOptional)ÚGatewayConfigÚHomeChannelÚPlatformÚPlatformConfigÚ_getenv_strzgateway.configc                ó0   € V ^8„  d   QhR\         R\        /# ©é   ÚvalueÚreturn)ÚstrÚlist)Úformats   "Ú9/home/ubuntu/.hermes/hermes-agent/gateway/platform_env.pyÚ__annotate__r      s   € ÷ Gñ G”Cð GœDñ Gó    c                 ó˜   € V P                  R 4       Uu. uF*  qP                  4       '       g   K  VP                  4       NK,  	  up# u upi )Ú,)ÚsplitÚstrip)r   Úparts   & r   Úcsv_listr      s3   € Ø%*§[¡[°Ô%5ÓFÑ%5˜T¿¹¿ŒLˆD�J‰JŽLÑ%5ÑFÐFùÒFs
   ”A°Ac                óT   € V ^8„  d   QhR\         R\        \        .\         3,          /# )r   Údefaultr   )Úintr   r   )r   s   "r   r   r   #   s%   € ÷ ñ ”Cð œH¤c U¬C ZÕ0ñ r   c                ó   a € R V 3R llpV# )zA``int(raw.strip(), 10)`` with *default* on malformed/blank input.c                ó0   € V ^8„  d   QhR\         R\        /# )r   Úrawr   )r   r    )r   s   "r   r   Úint_or.<locals>.__annotate__%   s   € ÷ ñ ”3ð œ3ñ r   c                 ó~   <€  \        \        V 4      P                  4       ^
4      #   \        \        3 d    Su # i ; i)é
   )r    r   r   Ú	TypeErrorÚ
ValueError)r#   r   s   &€r   ÚparseÚint_or.<locals>.parse%   s9   ø€ ð	Ü”s˜3“x—~‘~Ó'¨Ó,Ð,øÜœ:Ð&ô 	ØŠNð	ús   ƒ"& ¦<»<© )r   r)   s   f r   Úint_orr,   #   s   ø€ ÷ð ð
 €Lr   c                ó0   € V ^8„  d   QhR\         R\         /# r   ©r   )r   s   "r   r   r   -   s   € ÷ ñ ”sð œsñ r   c                 ó$   € V P                  R 4      # )Ú/)Úrstrip©r   s   &r   Ústrip_slashr3   -   s   € Ø�<‰<˜ÓÐr   c                ó0   € V ^8„  d   QhR\         R\         /# r   r.   )r   s   "r   r   r   1   s   € ÷ !ñ !”sð !œsñ !r   c                 ó>   € V P                  4       P                  4       # ©N)r   Úlowerr2   s   &r   Ústrip_lowerr8   1   s   € Ø�;‰;‹=×ÑÓ Ð r   c                ó0   € V ^8„  d   QhR\         R\        /# r   )r   Úbool)r   s   "r   r   r   5   s   € ÷ 7ñ 7œð 7¤ñ 7r   c                 ó(   € V P                  4       R9   # )Útrue>   Ú1ÚonÚyesr<   )r7   r2   s   &r   Útruthy_tokenr@   5   s   € Ø�;‰;‹=Ð6Ñ6Ð6r   c                ó0   € V ^8„  d   QhR\         R\        /# r   ©r   r   )r   s   "r   r   r   9   s   € ÷ 2ñ 2œCð 2¤Cñ 2r   c                óˆ   €  \         P                  ! V 4      #   \         d    \        T P	                  RR4      4      u # i ; i)z(JSON list, else comma/newline separated.Ú
r   )ÚjsonÚloadsr(   r   Úreplacer2   s   &r   Úmention_patternsrH   9   s;   € ð2Ü�zŠz˜%Ó Ð øÜô 2Ü˜Ÿ™ d¨CÓ0Ó1Ò1ð2ús   ‚ ˜&AÁ Ac                óJ   € V ^8„  d   QhR\         \        \        3,          RR/# )r   Úextrar   N)Údictr   r   )r   s   "r   r   r   A   s"   € ÷ ñ ”dœ3¤˜8•nð ¨tñ r   c                óN   € V F  w  r#\        V4      pV'       g   K  W@V&   K   	  R# )zO``extra[key] = csv_list(raw)`` for each ``(key, raw)`` whose list is non-empty.N)r   )rJ   ÚspecÚkeyr#   Úitemss   &&   r   Ú
csv_extrasrP   A   s#   € ã‰ˆÜ˜“ˆß‰5Ø�#‹Jó r   c                ó$   € V ^8„  d   QhR\         /# )r   r   r.   )r   s   "r   r   r   I   s   € ÷ 9ñ 9”sñ 9r   c                ó†   € \        V \        4      '       d   \        V 4      # \        R \	        \        V 4       4       R4      # )zKFirst truthy value among *envs* (a single name or a tuple of alternatives).c              3   ó8   "  € T F  q'       g   K  Vx € K  	  R # 5ir6   r+   )Ú.0Úvs   & r   Ú	<genexpr>Úenv_first.<locals>.<genexpr>M   s   é € Ð3Ñ-�q³—’Ó-ùs   ‚	�
Ú )Ú
isinstancer   ÚgetenvÚnextÚmap)Úenvss   &r   Ú	env_firstr^   I   s3   € ä�$œ×ÒÜ�d‹|ÐÜÑ3œC¤¨Ô-Ó3°RÓ8Ð8r   r   Fc                óV   € V ^8„  d   QhR\         \        \        3,          R\        RR/# )r   rJ   r   r   N)rK   r   r   r:   )r   s   "r   r   r   U   s)   € ÷ 7ñ 7”dœ3¤˜8•nð 7´dð 7Àtñ 7r   c               óz  € V F   vr4p\        V4      pV'       d   VP                  4       pV'       g   K2  V'       dL   V^ ,          \        J d;   \        P                  ! \
        4      ;_uu_ 4        \        V4      W&   RRR4       K…  V'       d   V^ ,          ! V4      MTW&   K¢  	  R#   + '       g   i     K·  ; i)zË``extra[key] = fn(value)`` for each ``(key, env[, fn])`` whose env value is truthy.

``strip=True`` strips BEFORE the truthiness check. ``fn=INT`` parses an int
and silently ignores a non-integer value.
N)rZ   r   ÚINTÚ
contextlibÚsuppressr(   r    )rJ   rM   r   rN   ÚenvÚfnr   s   &&$    r   Ú
env_extrasrf   U   s�   € ó ˆˆ�2Ü�s“ˆßØ—K‘K“MˆEßÙß�"�Q•%œ3“,Ü×$Ò$¤Z×0Õ0Ü  ›Z�‘
÷ 1Ñ0÷ *,˜˜Až˜uœ°ˆE‹Jó ÷ 1×0Ð0ús   Á0B)Â)B:c          
      óL   € V ^8„  d   QhR\         R\        R\        R\        RR/# )r   ÚconfigÚplatformÚenv_baser   r   N)r   r
   r   r:   )r   s   "r   r   r   h   s1   € ÷ 	
ñ 	
œ]ð 	
´hð 	
Ì#ð 	
ÔY]ð 	
Ðjnñ 	
r   c          	     ó  € \        V4      pV'       d   VP                  4       pV'       d\   WP                  9   dJ   \        Y\        V R2R4      \        V R24      ;'       g    RR7      V P                  V,          n        R# R# R# )zeSet ``home_channel`` from ``<env_base>`` (+``_NAME``/``_THREAD_ID``) when the platform is configured.Ú_NAMEÚHomeÚ
_THREAD_IDN)ri   Úchat_idÚnameÚ	thread_id)rZ   r   Ú	platformsr	   Úhome_channel)rh   ri   rj   r   ro   s   &&&$ r   Úenv_home_channelrt   h   ss   € ä�XÓ€GßØ—-‘-“/ˆß�8×/Ñ/Ô/Ü2=ØÜ˜8˜* EÐ*¨FÓ3¼vÈÈ
ÐR\ÐF]Ó?^×?fÐ?fÐbfô3
ˆ×Ñ˜Õ"Ö/ñ 0�wr   c                ó@   € V ^8„  d   QhR\         R\        R\        RR/# )r   rh   ri   rd   r   N)r   r
   r   )r   s   "r   r   r   t   s.   € ÷ Uñ Uœ=ð U´Hð UÄ3ð UÈ4ñ Ur   c                 óš   € \        V4      P                  4       pVR9   d+   W0P                  P                  V\	        4       4      n        R# R# )ÚoffN>   Úallrw   Úfirst)rZ   r7   rr   Ú
setdefaultr   Úreply_to_mode)rh   ri   rd   Úmodes   &&& r   Úenv_reply_moder}   t   s>   € Ü�#‹;×ÑÓ€DØÐ&Ô&ØPT×Ñ×#Ñ# H¬nÓ.>Ó?ÖMñ 'r   c                ó<   € V ^8„  d   QhR\         R\        R\        /# )r   ri   rj   r   )r
   r   r:   )r   s   "r   r   r   |   s&   € ÷ Xñ Xœð X¬Cð X¼4ñ Xr   c                ó&   € \        \        WVR 7      # )©ri   rj   r   )r   rt   r€   s   &&$r   Ú	home_stepr�   |   s   € ÜÔ#¨hÐQVÔWÐWr   c                ó0   € V ^8„  d   QhR\         R\        /# )r   ri   rd   )r
   r   )r   s   "r   r   r   €   s   € ÷ ?ñ ?œhð ?¬Sñ ?r   c                 ó$   € \        \        WR 7      # )©ri   rd   )r   r}   r„   s   &&r   Úreply_mode_stepr…   €   s   € Ü”>¨HÔ>Ð>r   c                ó<   € V ^8„  d   QhR\         R\        R\        /# )r   rh   ri   r   )r   r
   r   )r   s   "r   r   r   „   s!   € ÷ .ñ .œMð .´Xð .Ä.ñ .r   c                ó   € ^ RI Hp V! W4      # )z¹Enable *platform* on env credentials unless config.yaml explicitly disabled it (warns once).
Delegates to the core gate, which owns the explicit-disable marker and the one-time WARNING.)Ú_enable_from_env)Úgateway.config_envrˆ   )rh   ri   rˆ   s   && r   Úenable_from_envrŠ   „   s   € õ 4Ù˜FÓ-Ð-r   T)Úfrozenc                   ób   a € ] tR t^‹t o RtRtRtRtRtRt	Rt
RtRtV 3R lR ltV 3R ltRtV tR# )ÚEnvCreda&  Credential-gated platform enable, applied as ``step(config)``.

``creds``: env names that must ALL be truthy (inner tuple = ANY of). ``token``: env stored as
``PlatformConfig.token`` even when yaml disables the adapter (sending skills use it). ``fixed``:
``(extra_key, env[, default[, fn]])`` always written once enabled. ``optional*``: ``env_extras``
specs. ``warn_missing``: ``(env, msg)`` logged BEFORE enabling when blank. ``then``: tail
``fn(config, platform_config)``. ``home``: ``env_home_channel`` env base applied only when the gate passed.
NFc                ó$   <€ V ^8„  d   QhRS[ RR/# )r   rh   r   N)r   )r   Ú__classdict__s   "€r   r   ÚEnvCred.__annotate__    s   ø€ ÷ Vñ V™}ð V°ñ Vr   c                ó  € \         ;QJ d&    R  V P                   4       F  '       d   K   RM	  RM! R  V P                   4       4      '       g   R# V P                  '       dI   \        V P                  ^ ,          4      '       g'   \        P                  V P                  ^,          4       \        WP                  4      pV P                  '       d$   \        V P                  4      ;p'       d   W2n        VP                  pV P                   Fq  vrVpV'       d
   V^ ,          MRp\        V\        4      '       d   \        V4      ;'       g    TM
\        Wh4      p	\        V4      ^8”  d   V^,          ! V	4      MT	WE&   Ks  	  \        W@P                   4       \        W@P"                  RR7       V P$                  e   V P%                  W4       V P&                  '       d/   \)        WP                  V P&                  V P*                  R7       R# R# )c              3   ó8   "  € T F  p\        V4      x € K  	  R # 5ir6   )r^   )rT   Úgroups   & r   rV   Ú#EnvCred.__call__.<locals>.<genexpr>¡   s   é € Ð<±¨”9˜U×#Ð#³ùs   ‚FTNrX   )r   )rx   ÚcredsÚwarn_missingrZ   ÚloggerÚwarningrŠ   ri   ÚtokenrJ   ÚfixedrY   Útupler^   Úlenrf   ÚoptionalÚoptional_strippedÚthenÚhomert   Ú
home_strip)
Úselfrh   Úplatform_configr™   rJ   rN   rd   Úrestr   r   s
   &&        r   Ú__call__ÚEnvCred.__call__    s[  € ß‹sÑ<°·²Ó<�s�sŠsÑ<°·²Ó<×<Ò<ÙØ××Ð¤V¨D×,=Ñ,=¸aÕ,@×%AÒ%AÜ�N‰N˜4×,Ñ,¨QÕ/Ô0Ü)¨&·-±-Ó@ˆØ�:�:ˆ:¤F¨4¯:©:Ó$6Ð6˜5Ö6Ø$)Ô!Ø×%Ñ%ˆØ#ŸzœzˆOˆC�tß!%�d˜1–g¨2ˆGÜ1;¸CÄ×1GÒ1G”I˜c“N×-Ð- gøÌVÐTWÓMaˆEÜ+.¨t«9°q¬=˜˜až œ¸eˆE‹Jñ  *ô 	�5Ÿ-™-Ô(Ü�5×0Ñ0¸Õ=Ø�9‰9Ò Ø�I‰I�fÔ.Ø�9�9ˆ9Ü˜V§]¡]°D·I±IÀTÇ_Á_×Uñ r   c                óì   <€ V ^8„  d   Qh/ S[ ;R&   S[;R&   S[S[,          ;R&   S[;R&   S[;R&   S[;R&   S[S[,          ;R&   S[S[S[S[.R3,          ,          ;R	&   S[S[,          ;R
&   S[;R&   # )r   ri   r•   r™   rš   r�   rž   r–   NrŸ   r    r¡   )r
   r›   r   r   r   r   r   r:   )r   r�   s   "€r   r   r�   ‹   s¦   ø‡ ‚ ñ Ññ ñ �Lñ ñ ‘C�=Ññ ñ Ññ ñ Ññ ñ Ñ!ñ ñ  ™5•/Ñ(ñ! ñ" ‘8™]©NÐ;¸TÐAÕBÕ
CÑJñ# ñ$ ‘3�-Ññ% ñ& Ñò' r   r+   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r™   rš   r�   rž   r–   rŸ   r    r¡   r¥   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__)r�   s   @r   r�   r�   ‹   sH   ø‡ € ñð  €EØ€EØ€HØ!ÐØ$(€LØFJ€DØ€DØ€J÷Vð V÷+ ƒ r   r�   Úwecom_callbackc                ó<   € V ^8„  d   QhR\         R\         R\        /# )r   Ú	directoryÚstemr   rB   )r   s   "r   r   r   ¼   s!   € ÷ ñ œsð ¬#ð Ä#ñ r   c                óÞ  € ^ RI Hp WP                  ! 4       ^ ,          9  d   R# \        \        4      P                  4       P                  P                  R,          R,          V ,          V R2,          pVP                  4       '       g   R# \        P                  P                  RV RV  2V4      p\        P                  P                  V4      pVP                  P                  V4       V# )a  ``plugins/platforms/<directory>/<stem>.py`` (a light declaration module importing only core)
executed from its file under a private name: the plugin package (``__init__``, adapter,
``register()``) is never imported. None when absent or *directory* is not a bundled plugin.)r
   NÚpluginsrr   z.pyÚ_hermes_bundled_Ú_)Úgateway.configr
   Ú_scan_bundled_plugin_platformsr   Ú__file__ÚresolveÚparentÚis_fileÚ	importlibÚutilÚspec_from_file_locationÚmodule_from_specÚloaderÚexec_module)r²   r³   r
   ÚpathrM   Úmodules   &&    r   Úbundled_siblingrÆ   »   s¸   € õ
 (Ø×?Ò?ÓAÀ!ÕDÔDÙÜ”‹>×!Ñ!Ó#×*Ñ*×1Ñ1°IÕ=ÀÕKÈiÕWÐ]aÐ\bÐbeÐZfÕf€DØ�<‰<�>Š>ÙÜ�>‰>×1Ñ1Ð4DÀTÀFÈ!ÈIÈ;Ð2WÐY]Ó^€DÜ�^‰^×,Ñ,¨TÓ2€FØ‡K�K×Ñ˜FÔ#Ø€Mr   c                óF   € V ^8„  d   QhR\         R\        \        ,          /# ©r   rp   r   )r   r   r›   )r   s   "r   r   r   Ì   s"   € ÷ 
Qñ 
Qœ3ð 
Q¤8¬E¥?ñ 
Qr   c                óÞ   € \         P                  W R34      w  r\        V4      pVf   R# \        \	        W2 R2R4      ;'       g    R4      \        \	        W2 R2R4      ;'       g    R4      3# )ao  ``(env_overrides, env_enable_credentials)`` a BUNDLED platform plugin declares, read without
the plugin. For when its registry entry is absent: discovery suppressed (a parked profile's
config read, ``HERMES_SAFE_MODE``) or the plugin disabled. These rows were core's own table, and
the duplicate-credential guard and the explicit-disable warning still need them then.rX   NÚENV_OVERRIDESÚENV_ENABLE_CREDENTIALSr+   )Ú_BUNDLED_ENV_SIBLINGSÚgetrÆ   r›   Úgetattr©rp   r²   ÚprefixrÅ   s   &   r   Úbundled_env_rowsrÑ   Ì   sv   € ô
 .×1Ñ1°$¸r¸
ÓCÑ€IÜ˜YÓ'€FØ‚~ÙÜ”'˜& H¨MÐ":¸BÓ?×EÐEÀ2ÓFÜ”'˜& HÐ,BÐ"CÀRÓH×NÐNÈBÓOðQð Qr   c                ó0   € V ^8„  d   QhR\         R\        /# rÈ   )r   rK   )r   s   "r   r   r   Ù   s   € ÷ ]ñ ]œð ]¤ñ ]r   c                óš   € \         P                  W R34      w  r\        V4      pVe#   \        \	        W2 R2R4      ;'       g    / 4      # / # )z°``AUTHZ`` (allowlist / allow-all / allow-bots / own-policy env names) a bundled platform
plugin declares in its ``gateway_env.py``, read without the plugin; {} for other names.rX   NÚAUTHZ)rÌ   rÍ   rÆ   rK   rÎ   rÏ   s   &   r   Úbundled_authzrÕ   Ù   sQ   € ô .×1Ñ1°$¸r¸
ÓCÑ€IÜ˜YÓ'€FØBHÒBTŒ4”˜ (¨%Ð 0°$Ó7×=Ð=¸2Ó>Ð\ÐZ\Ð\r   c                óH   € V ^8„  d   QhR\         R\         R\        R\        /# )r   rp   ÚfieldÚentryr   rB   )r   s   "r   r   r   á   s.   € ÷ Nñ N”cð N¤#ð N¬cð N¼Sñ Nr   c                óÌ   € Ve   \        W!R4      MRpT;'       gJ    \        \        T ;'       g    R4      P                  4       P	                  4       4      P                  V4      # )zö*entry*'s authorization env field, else the bundled plugin's declaration. A user plugin
overriding a bundled platform, safe mode or a disabled plugin then still gate on the names core
always enforced for it; never looser than the bundled adapter.NrX   )rÎ   rÕ   r   r   r7   rÍ   )rp   r×   rØ   r   s   &&& r   Úauthz_fieldrÚ   á   sQ   € ð ,1Ò+<ŒG�E $Ô'À$€EØ×MÐM”M¤# d§j j¨b£/×"7Ñ"7Ó"9×"?Ñ"?Ó"AÓB×FÑFÀuÓMÐMr   )ÚwecomÚ	CALLBACK_)Úgateway_envr6   )0r¬   rb   Ú	functoolsÚimportlib.utilr¾   rE   ÚloggingÚdataclassesr   r   Úpathlibr   Útypingr   r   r   r¸   r   r	   r
   r   r   Ú	getLoggerr—   rZ   r   r,   r3   r8   r@   rH   rP   r^   Úobjectra   rf   rt   r}   r�   r…   rŠ   r�   rÌ   ÚcacherÆ   rÑ   rÕ   rÚ   r+   r   r   Ú<module>rç      s  ðñó Û Û Û Û Ý !Ý Ý ß *Ñ *ç \Õ \ð 
×	Ò	Ð+Ó	,€à	€õ
Gõõõ!õ7õ2õõ9ñ ƒh€ð7¸U÷ 7ð&	
Ð`e÷ 	
õUðXÀ%÷ Xõ?õ.ñ �$Ô÷&Vð &Vó ð&VðX *Ð+AÐBÐ ð ‡�öó ðõ 
Qõ]÷Nñ Nr   