+
    lHàjðŽ  ã            
       ó*  a € RO tE0 t R t^ RIt^ RIt^ RIt^ RIt^ RI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HtHtHt ^ RIHtHt ^ RIHtHt ]P6                  ! R4      t/ t] ^ k ]P<                  ! 4       tR R lt R	R/R
 R llt! ! R R4      t"R R lt#RRR^/R R llt$]%! 0 RPm4      t&]%! 0 RQm4      t']PP                  ! R4      t)R R lt*R R lt+RR RR R]+RR  R!R" /t, ! R# R$]-4      t.R% R& lt/R' R( lt0R)R*R*R*R+R*R,R,R-R,/t1R. R/ lt2R0 R1 lt3R2 R3 lt4R4t5RRR5R/R6 R7 lllt6RRR5R/R8 R9 lllt7R: R; lt8R5R/R< R= llt9R> R? lt:R@ RA lt;RB t<RC RD lt=]>! 4       t?] ^k RE RF lt@RG RH ltARI RJ ltB]%! 4       3RK RL lltCRM RN ltDR# )Sz÷MCP server config loading and stdio launch environment: ${VAR}/Cursor-style
interpolation, hidden-whitespace and suspicious-entry filtering, the filtered
subprocess env, command resolution, the cached-npx binary shortcut and the shared stderr log.N)ÚPath)ÚAnyÚDictÚListÚOptionalÚSetÚTuple)Ú
stamp_lineÚ	timestamp)Ú_env_ref_nameÚ_prepend_pathztools.mcp_toolc                ó$   € V ^8„  d   QhR\         /# ©é   Úreturn©r   )Úformats   "Ú:/home/ubuntu/.hermes/hermes-agent/tools/mcp_tool_config.pyÚ__annotate__r      s   € ÷ ñ œSñ ó    c            
     óF  € ^ RI Hp HpHp V! 4       p\        ;_uu_ 4        \
        P                  V4      pVe   VP                  '       dH    V ! 4       R,          pV! V4       \        VR,          RRR^R7      pVP                  4        T\
        T&   VuuRRR4       #   \         dc   p\        P                  R	T4        \        \        P                  R
RR7      p Rp?LX  \         d    \        P                   p  Rp?Lyi ; iRp?ii ; i  + '       g   i     R# ; i)a.  Shared append-mode handle for MCP subprocess stderr, cached until shutdown PER PROFILE HOME (a
multiplexed gateway's secondary profile must log under ITS ``logs/``, not the launch profile's). Must
expose a real fd (asyncio wires the child's stderr to it); falls back to ``/dev/null``, then real stderr.)Úget_hermes_homeÚhermes_home_keyÚmkdir_under_hermes_homeNÚlogszmcp-stderr.logÚaúutf-8Úreplace)ÚencodingÚerrorsÚ	bufferingz0Failed to open MCP stderr log, using devnull: %sÚw©r   )Úhermes_constantsr   r   r   Ú_mcp_stderr_log_lockÚ_mcp_stderr_log_fhÚgetÚclosedÚopenÚfilenoÚ	ExceptionÚloggerÚdebugÚosÚdevnullÚsysÚstderr)r   r   r   Úhome_keyÚfhÚlog_dirÚexcs          r   Ú_get_mcp_stderr_logr5      sç   € ÷ [ÑZÙÓ €Hß	Ö	Ü×#Ñ# HÓ-ˆØŠ:˜ŸŸ˜ð$Ù)Ó+¨fÕ4�Ù'¨Ô0ä˜'Ð$4Õ4°cÀGÐT]ÐijÔk�Ø—	‘	”ð ,.Ô˜xÑ(Ø÷! 
Ò	øô ô $Ü—‘ÐOÐQTÔUð$ÜœbŸj™j¨#¸Ô@•BøÜ ô $ÜŸ™–Bð$þð	$ú÷ 
×	Ð	úsY    +DÁ=BÂ

DÂDÂ*DÃC"ÃDÃ"D	Ã=DÃ>DÄD	ÄDÄDÄDÄD 	Úscopec                ó>   € V ^8„  d   QhR\         \        ,          RR/# )r   r6   r   N)r   Ústr)r   s   "r   r   r   3   s"   € ÷ \ñ \¤X¬c¥]ð \¸dñ \r   c           
     ó˜  € \         ;_uu_ 4        V f   \        \        4      MV .pV FX  p\        P                  VR4      pVe)   V\        P
                  J g   V\        P                  J d   KG   VP                  4        KZ  	  RRR4       R#   \         d    \        P                  RTRR7        KŒ  i ; i  + '       g   i     R# ; i)zMRelease cached parent handles after the selected MCP transports have stopped.Nz%Could not close MCP stderr log for %sT©Úexc_info)r$   Úlistr%   Úpopr/   r0   Ú
__stderr__ÚcloseÚOSErrorr+   Úwarning)r6   ÚkeysÚkeyr2   s   $   r   Ú_close_mcp_stderr_logsrD   3   sŸ   € ç	Ö	Ø+0ª=ŒtÔ&Ô'¸u¸gˆÛˆCÜ#×'Ñ'¨¨TÓ2ˆBàŠz˜R¤3§:¡:Ó-°´s·~±~Ó1EÙð\Ø—‘–
ñ ÷ 
Ñ	øô ô \Ü—‘ÐFÈÐVZ�×[ð\ú÷ 
×	Ð	ús0   �A B8Á0BÂ B8Â#B5	Â1B8Â4B5	Â5B8Â8C		c                   ót   a € ] tR t^Bt o RtRtV 3R lR ltV 3R lR ltV 3R lR ltRV 3R	 lR
 llt	Rt
V tR# )Ú
_StderrTeea.  A stdio child's stderr, copied into the shared log one stamped line at a time while the last few KB
stay readable (raw), so a server that dies at startup can say why on the MCP status surfaces instead of
only in the log (#124264). ``sink`` is handed to the child; ``close()`` returns the captured tail.i @  c                ó    <€ V ^8„  d   QhRS[ /# )r   Úlog_fhr   )r   Ú__classdict__s   "€r   r   Ú_StderrTee.__annotate__I   s   ø€ ÷ ñ ™sñ r   c                ó&  € \         P                  ! 4       w  r#\         P                  ! VR ^ R7      V n        V\	        4       uV n        V n        \        P                  ! V P                  V3RRR7      V n
        V P                  P                  4        R# )Úwb©r    z
mcp-stderrT)ÚtargetÚargsÚnameÚdaemonN)r-   ÚpipeÚfdopenÚsinkÚ	bytearrayÚ_logÚ_tailÚ	threadingÚThreadÚ_pumpÚ_readerÚstart)ÚselfrH   Úread_fdÚwrite_fds   &&  r   Ú__init__Ú_StderrTee.__init__I   sf   € ÜŸGšG›IÑˆÜ—I’I˜h¨¸Ô:ˆŒ	Ø &¬	«ÐˆŒ	�4”:Ü ×'Ò'¨t¯z©zÀÀ
ÐQ]ÐfjÔkˆŒØ�‰×ÑÖr   c                ó$   <€ V ^8„  d   QhRS[ RR/# )r   r^   r   N)Úint)r   rI   s   "€r   r   rJ   P   s   ø€ ÷ 
&ñ 
&™Sð 
& Tñ 
&r   c                ó  € \         P                  ! R 4      ! RR7      pRp\        P                  ! VR^ R7      ;_uu_ 4       pVP	                  R4      ;p'       db   V P
                  V,           V P                  ) R V n        W2P                  V4      ,           P                  R4      Ev rcV P                  V4       Kz   RRR4       W2P                  R	R
R7      ,           ;p'       d   V P                  V.4       R# R#   + '       g   i     LG; i)r   r   ©r   Ú ÚrbrM   i   NÚ
r   T)Úfinal)
ÚcodecsÚgetincrementaldecoderr-   rS   ÚreadrW   Ú_TAIL_BYTESÚdecodeÚsplitÚ_write_lines)r]   r^   ÚdecoderÚpendingÚsourceÚchunkÚlinesÚrests   &&      r   rZ   Ú_StderrTee._pumpP   s×   € Ü×.Ò.¨wÔ7¸yÔIˆØˆÜ�YŠY�w °×2Õ2°fØ!Ÿ;™; uÓ-Ð-�%Ö-Ø"Ÿj™j¨5Õ0°4×3CÑ3CÐ2CÐ2DÐE�”
à#*¯^©^¸EÓ-BÕ#B×"IÑ"IÈ$Ó"O‘�Ø×!Ñ! %Ö(ð	 .÷ 3ð Ÿ^™^¨C°t˜^Ó<Õ<Ð<ˆ4Ö<Ø×Ñ˜t˜fÖ%ñ =÷ 3×2ús   ÁC<ÁA!C<Ã<D	c                ó4   <€ V ^8„  d   QhRS[ S[,          RR/# )r   ru   r   N)r<   r8   )r   rI   s   "€r   r   rJ   \   s   ø€ ÷ ñ ¡$¡s¥)ð °ñ r   c                óâ   € V'       g   R #  V P                   P                  RP                  R V 4       4      4       V P                   P                  4        R #   \        \
        3 d     R # i ; i)Nrf   c              3   ó8   "  € T F  p\        V4      x € K  	  R # 5i©N)r	   )Ú.0Úlines   & r   Ú	<genexpr>Ú*_StderrTee._write_lines.<locals>.<genexpr>`   s   é € Ð#GÁ¸¤J¨t×$4Ð$4Ãùs   ‚)rV   ÚwriteÚjoinÚflushr@   Ú
ValueError)r]   ru   s   &&r   rp   Ú_StderrTee._write_lines\   sQ   € ßÙð	Ø�I‰I�O‰O˜BŸG™GÑ#GÁÓ#GÓGÔHØ�I‰I�O‰OÖøÜœÐ$ô 	Úð	ús   ŒAA ÁA.Á-A.c                ó&   <€ V ^8„  d   QhRS[ RS[/# )r   Útimeoutr   )Úfloatr8   )r   rI   s   "€r   r   rJ   e   s   ø€ ÷ <ñ <™Uð <©Sñ <r   c                ó¦   € V P                   P                  4        V P                  P                  V4       V P                  P                  RRR7      # )z�Close our write end and give the reader *timeout* to drain (a surviving grandchild can keep
the pipe open); the tail read so far.r   r   re   )rT   r?   r[   r�   rW   rn   )r]   r†   s   &&r   r?   Ú_StderrTee.closee   s>   € ð 	�	‰	�‰ÔØ�‰×Ñ˜'Ô"Ø�z‰z× Ñ  °Ð Ó;Ð;r   )rV   r[   rW   rT   N)g       @)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rm   r`   rZ   rp   r?   Ú__static_attributes__Ú__classdictcell__)rI   s   @r   rF   rF   B   s?   ø‡ € ñjð €K÷ð ÷
&ð 
&÷ð ÷<÷ <ð <r   rF   c                ó(   € V ^8„  d   QhR\         RR/# )r   Úserver_namer   N©r8   )r   s   "r   r   r   m   s   € ÷ ñ ¬#ð °$ñ r   c                ó    € \        4       p VP                  R\        4        RV  R24       VP                  4        R#   \         d     R# i ; i)z½Session marker so operators can find each server's output in the shared log; it leads with the
same stamp as every server line (``_StderrTee``) so ``hermes logs mcp --since`` can filter it.rh   z ===== starting MCP server 'z' =====
N)r5   r€   r
   r‚   r*   )r’   r2   s   & r   Ú_write_stderr_log_headerr•   m   sJ   € ô 
Ó	€BðØ
�‰�2”i“k�]Ð">¸{¸mÈ9ÐUÔVØ
�‰Ž
øÜô Úðús   Œ0> ¾AÁAÚ	max_bytesi    Ú	max_linesc                óH   € V ^8„  d   QhR\         R\        R\        R\         /# )r   r’   r–   r—   r   )r8   rc   )r   s   "r   r   r   x   s)   € ÷ ñ ¤Sð ¼ð Ìsð Ô[^ñ r   c          	     óÈ  €  \        4       p\        VRR4      pV'       d   V\        P                  8X  d   R# \	        VR4      ;_uu_ 4       pVP                  ^ \        P                  4       VP                  4       pVP                  \        ^ Wa,
          4      4       VP                  4       P                  RR4      pRRR4       XP                  RV  R24      pV^ 8  d   R# WxR P                  4        U	u. uF  q™P                  4       '       g   K  V	NK  	  p
p	V
'       d   R	P                  W¢) R 4      # R#   + '       g   i     L„; iu up	i   \         d     R# i ; i)
uœ  Trailing lines this server last wrote to the shared stderr log; ``''`` when none.

A connect failure that only says ``Connection closed`` hides why the child died
(#125300: a ``ModuleNotFoundError`` sat in the log while the agent log stayed mute).
Best-effort: the segment header must still be inside the read window, and another
server's output past that header is fair game â€” the header lines carry the name.rP   Nrf   rg   r   r   zstarting MCP server 'Ú'rh   )r5   Úgetattrr-   r.   r(   ÚseekÚSEEK_ENDÚtellÚmaxrl   rn   ÚrfindÚ
splitlinesÚstripr�   r*   )r’   r–   r—   r2   ÚpathÚrawÚsizert   Úcutr}   ru   s   &$$        r   Ú_tail_server_stderrr§   x   s  € ðÜ Ó"ˆÜ�r˜6 4Ó(ˆß�tœrŸz™zÔ)ÙÜ�$˜×Ô Ø�H‰H�QœŸ™Ô$Ø—8‘8“:ˆDØ�H‰H”S˜˜DÕ,Ó-Ô.Ø—H‘H“J×%Ñ% g¨yÓ9ˆE÷	 ð
 �k‰kÐ1°+°¸aÐ@ÓAˆØ�Œ7ÙØ"'¨ +×"8Ñ"8Ô":ÓKÑ":˜$¿j¹j¿l—�Ñ":ˆÐKß05ˆt�y‰y˜˜z˜{Ð+Ó,Ð=¸2Ð=÷ ×üò Løäô ÚðúsM   ‚4E ¸E ÁA2D:Â>$E Ã$E Ã8EÄEÄE Ä8E Ä:E
	ÅE ÅE!Å E!z\$\{([^}]+)\}c                ó$   € V ^8„  d   QhR\         /# r   r“   )r   s   "r   r   r   ¢   s   € ÷ ñ œ3ñ r   c                 ó‚   €  ^ RI Hp  V ! 4       pT;'       g    \        P                  ! 4       #   \         d    Rp L.i ; i)zŽAbsolute workspace root for ``${workspaceFolder}``: the session's authoritative root
(terminal cwd / task override / $TERMINAL_CWD), else cwd.)Ú_authoritative_workspace_rootN)Útools.file_tools_pathsrª   r*   r-   Úgetcwd)rª   Úroots     r   Ú_workspace_folderr®   ¢   s>   € ðÝHÙ,Ó.ˆð ×Ð”2—9’9“;Ðøô ô ØŠðús   ‚. ®>½>c                ó$   € V ^8„  d   QhR\         /# r   r“   )r   s   "r   r   r   ­   s   € ÷ 8ñ 8œSñ 8r   c                  ó†   € \        4       p \        P                  P                  V P	                  R 4      4      ;'       g    T # )z/\)r®   r-   r£   ÚbasenameÚrstrip)r­   s    r   Ú_workspace_basenamer³   ­   s0   € ÜÓ€DÜ�7‰7×Ñ˜DŸK™K¨Ó.Ó/×7Ð7°4Ð7r   ÚuserHomec                  ó@   € \         P                  P                  R 4      # )Ú~)r-   r£   Ú
expanduser© r   r   Ú<lambda>r¹   ´   s   € œŸ™×*Ñ*¨3Ô/r   ÚworkspaceFolderc                  ó   € \        4       # r{   )r®   r¸   r   r   r¹   r¹   ´   s   € ÔL]ÔL_r   ÚworkspaceFolderBasenameÚpathSeparatorc                  ó"   € \         P                  # r{   ©r-   Úsepr¸   r   r   r¹   r¹   µ   s   € ÌRÏVÊVr   Ú/c                  ó"   € \         P                  # r{   r¿   r¸   r   r   r¹   r¹   µ   s   € Ôbd×bhÒbhr   c                   óF   a a€ ] tR t^¸t oRtRV3R lV 3R llltRtVtV ;t# )Ú_RenderedStra§  A config string after ``${...}`` rendering, carrying how it resolved, so later steps never
guess from text that may itself look like ``${...}``. ``missed``: some env reference was unset
(or empty) and kept its placeholder; a re-render (connect renders again under the owner's fresh
scope) retries from ``template``, while a fully resolved value is final. ``unset_ref``: the
template was one whole env reference that missed.c                óB   <€ V ^8„  d   QhRS[ RS[S[ ,          RS[RS[/# )r   ÚtextÚtemplateÚmissedÚ	unset_ref)r8   r   Úbool)r   rI   s   "€r   r   Ú_RenderedStr.__annotate__¿   s.   ø€ ÷ ñ ™3ð ©x¹­}ð ÉTð Ñfjñ r   c                óX   <€ \         SV `  W4      pVf   TMTVn        W5n        WEn        V# r{   )ÚsuperÚ__new__rÇ   rÈ   rÉ   )ÚclsrÆ   rÇ   rÈ   rÉ   ÚrenderedÚ	__class__s   &&&&& €r   rÎ   Ú_RenderedStr.__new__¿   s0   ø€ Ü‘7‘? 3Ó-ˆØ$,Ò$4™D¸(ˆÔØ ŒØ&ÔØˆr   r¸   )rf   NFF)	rŠ   r‹   rŒ   r�   rŽ   rÎ   r�   r�   Ú__classcell__)rÑ   rI   s   @@r   rÄ   rÄ   ¸   s   ù‡ € ñ9÷÷ õ r   rÄ   c                óF   € V ^8„  d   QhR\         \        ,          R\        /# )r   Úuser_envr   )r   Údict)r   s   "r   r   r   Ç   s   € ÷ /ñ /œh¤t�nð /´ñ /r   c                óD  € ^ RI Hp ^ RIHp \        P
                  P                  4        UUu/ uFD  w  r4V\        9   g3   VP                  4       \        9   g   VP                  R4      '       g   KB  W4bKF  	  pppV! 4        F  pV! V4      pVf   K  WEV&   K  	  R F3  pV\        P
                  9   g   K  \        P
                  V,          WS&   K5  	  V '       d3   V P                  4        F  w  r4\        VRR4      '       d   K  WEV&   K   	  ^ RIHp V! V4      # u uppi )a  Filtered env for stdio subprocesses so API keys/tokens don't leak: the safe baseline
keys, ``XDG_*``, vars injected by an external secret source (users configured that backend
precisely so subprocesses can consume them), plus the server config's own ``env``.©Ú
get_secret)Úsecret_source_namesÚXDG_rÉ   F)Údelegated_child_subprocess_env)ÚHERMES_KANBAN_DBÚHERMES_KANBAN_BOARD)Úagent.secret_scoperÙ   Úhermes_cli.env_loaderrÚ   r-   ÚenvironÚitemsÚ_SAFE_ENV_KEYSÚupperÚ_SAFE_ENV_KEYS_CASE_INSENSITIVEÚ
startswithr›   Úagent.delegation_contextrÜ   )rÕ   rÙ   rÚ   rC   ÚvalueÚenvrÜ   s   &      r   Ú_build_safe_envrê   Ç   s÷   € õ .Ý9ä%'§Z¡Z×%5Ñ%5Ô%7ônÙ%7‘z�sØ”.Ô  C§I¡I£KÔ3RÔ$RÐVY×VdÑVdÐek×Vlô 	ˆŠ
Ñ%7ð ñ nñ #Ö$ˆÙ˜3“ˆØÔØ�‹Hñ %ó ;ˆØ”"—*‘*ÖÜ—z‘z #•ˆC‹Hñ ;÷ ð
 #Ÿ.™.Ö*‰JˆCÜ˜5 +¨u×5Ô5Ø �C“ñ +õ HÙ)¨#Ó.Ð.ùó-ns   ®?DÁ2Dc                ó0   € V ^8„  d   QhR\         R\        /# )r   Úcommandré   ©r8   rÖ   )r   s   "r   r   r   æ   s   € ÷ ñ ¬ð ¼Dñ r   c                óˆ  a € \        R VP                  4        4       R4      pV'       d%   V\        P                  P	                  R4      8X  d   R# VP                  R4       Uu. uF  qD'       g   K  VNK  	  ppV Uu. uF  pS V,           NK  	  ppV'       dA   \        ;QJ d    V 3R lV 4       F  '       g   K   RM	  RM! V 3R lV 4       4      '       d   S .p\        T;'       g    R4      P                  \        P                  4      p\        P                  R	8X  d6   \        P                  V9  d!   VP                  ^ \        P                  4       V FÙ  pT;'       g    \        P                  p	\        P                  P                  V	4      '       g   KD  V F�  p
\        P                  P                  Wš4      p\        P                  P!                  V4      '       g   KI  \        P"                  ! V\        P$                  \        P&                  ,          4      '       g   K‹  Vu u # 	  KÛ  	  R# u upi u upi )
aÍ  Resolve *command* under the config env's PATHEXT (Windows only; ``shutil.which`` uses the PARENT's).

The extension walk mirrors ``which`` itself (existing-suffix short-circuit, configured
extensions in order) but reads nothing from and writes nothing to ``os.environ``: swapping
the parent's PATHEXT around a ``which`` call would publish this server's per-profile value
to every other thread for the duration, and a ``finally``-restore cannot undo that window.c              3   ó¸   "  € T FP  w  rVP                  4       R 8X  g   K  \        V\        4      '       g   K4  VP                  4       '       g   KL  Vx € KR  	  R# 5i©ÚPATHEXTN©rä   Ú
isinstancer8   r¢   ©r|   ÚkÚvs   &  r   r~   Ú-_which_with_config_pathext.<locals>.<genexpr>í   s=   é € Ðq¡k™d˜a°Q·W±W³YÀ)Ñ5KœÔPZÐ[\Ô^a×PbœÐgh×gnÑgn×gpŸš£kùó   ‚A A¸AÁ
ANrñ   Ú;c              3   ó~   <"  € T F2  pSP                  4       P                  VP                  4       4      x € K4  	  R # 5ir{   ©ÚlowerÚendswith©r|   Úextrì   s   & €r   r~   r÷   ó   s+   øé € ÐSÉdÀs˜WŸ]™]›_×5Ñ5°c·i±i³k×BÐBËdùs   ƒ:=TFrf   Úwin32)Únextrâ   r-   rá   r&   ro   Úanyr8   Úpathsepr/   ÚplatformÚcurdirÚinsertr£   Úisdirr�   ÚisfileÚaccessÚF_OKÚX_OK)rì   Úpath_argré   Úcfg_pathextrÿ   ÚextsÚ
candidatesÚdirectoriesr¤   Ú	directoryÚ	candidateÚresolveds   f&&         r   Ú_which_with_config_pathextr  æ   sz  ø€ ô Ñq c§i¡i¤kÓqÐswÓx€Kß˜+¬¯©¯©¸	Ó)BÔBÙà&×,Ñ,¨SÔ1Ó9Ñ1�C³S�CˆCÑ1€DÐ9Ù+/Ó0©4 C�'˜C—-�-©4€JÐ0ßŸ›ÔSÉdÓSŸŸšÔSÉdÓS×SÒSØ�Yˆ
Ü�h—n�n "Ó%×+Ñ+¬B¯J©JÓ7€KÜ
‡|�|�wÔ¤2§9¡9°KÔ#?Ø×Ñ˜1œbŸi™iÔ(ÛˆØ×$Ð$œ2Ÿ9™9ˆ	Ü�w‰w�}‰}˜Y×'Ò'ÙÛ#ˆIÜ—w‘w—|‘| IÓ9ˆHÜ�w‰w�~‰~˜h×'Ô'¬B¯IªI°hÄÇÁÌ"Ï'É'Õ@Q×,RÔ,RØ”ó $ñ	 ñ ùò :ùÚ0s   Á$	H:Á2H:Á>H?ÚnpxÚnpmÚnodeÚuvÚuvxc                ó~   € V ^8„  d   QhR\         R\        \        \         \        \         ,          3,          ,          /# )r   rì   r   )r8   r   Útupler<   )r   s   "r   r   r     s,   € ÷ ñ œsð ¤x´´c¼4Ä½9°nÕ0EÕ'Fñ r   c                óf  € ^ RI p\        V ,          pVP                  V4      P                  VP	                  4       4      e   R# VP                  V4       VR8X  d/   VP                  V 4      pVe   \        VP                  4      .M. pML^ RI	H
p V! RR/4      R,          P                  \        P                  4       Uu. uF  qf'       g   K  VNK  	  ppV'       d6   \        P                  ! V \        P                  P!                  V4      R7      MRpVf   \#        RV  RV R	24      hWt3# u upi )
am  PM's executable for a bare launcher name and the toolchain dirs its children need first on
PATH (npx's ``env node``, uvx's sibling uv). Never the user's copy: a missing managed tool is
provisioned through PM, which raises naming the remedy when it may not. None only when PM
ships no build for this platform (Termux), where the platform's own copy IS the toolchain.Nr  )Úwith_hermes_node_pathÚPATHrf   ©r£   zHermes-managed z* is not installed; run `hermes pm install Ú`)ÚpmÚ_MANAGED_LAUNCHERSÚget_packageÚmissing_reasonÚcurrent_targetÚensureÚuv_launcherr8   Úparentr#   r  ro   r-   r  ÚshutilÚwhichr�   ÚRuntimeError)rì   r!  ÚpackageÚlauncherÚdirsr  ÚdÚ
executables   &       r   Ú_managed_launcherr1    s   € ó
 ä  Õ)€GØ	‡~�~�gÓ×-Ñ-¨b×.?Ñ.?Ó.AÓBÒNÙØ‡I�IˆgÔØ�$„Ø—>‘> 'Ó*ˆØ)1Ò)=”�H—O‘OÓ$Ñ%À2‰å:á0°&¸"°Ó>¸vÕF×LÑLÌRÏZÉZÔXÓ^ÑX�aÓ\]—�ÑXˆÐ^ßFJ”—’˜g¬B¯J©J¯O©O¸DÓ,AÕBÐPT€JØÒÜ˜_¨W¨IÐ5_Ð`gÐ_hÐhiÐjÓkÐkØÐÐùò	 _s   Ã 	D.ÃD.c                ó–   € V ^8„  d   QhR\         R\         R\        \         ,          R\        \         \        \         ,          3,          /# )r   r-  Úmanagedr.  r   )r8   r<   r  )r   s   "r   r   r     sB   € ÷ Qñ Qœsð Q¬Sð Q¼¼S½	ð QÄeÌCÔQUÔVYÕQZÈNÕF[ñ Qr   c                ó²   € ^ RI Hp V! V4      pWB8X  d   W3# \        P                  ! V \        P
                  P                  V4      R7      ;'       g    TV3# )zéHermes's npm/node *launcher* and toolchain *dirs*, swapped for PM's copies outside a
sealed Windows payload (``pm.user_facing.copies``). npm starts each package bin through
cmd.exe, and cmd.exe cannot start the packaged ``node.exe``.)Úcopiesr  )Úpm.user_facingr5  r)  r*  r-   r  r�   )r-  r3  r.  r5  Úmoveds   &&&  r   Ú_outside_packager8    sJ   € õ &á�4‹L€EØ„}Øˆ}Ðô �<Š<˜¤r§z¡z§¡°uÓ'=Ô>×IÐIÀ'È5ÐPÐPr   c                ó0   € V ^8„  d   QhR\         R\        /# )r   r  r   )r8   rÊ   )r   s   "r   r   r   -  s   € ÷ @ñ @¬#ð @´$ñ @r   c                óz  €  \        V 4      P                  4       pT\        \        P                  4      P                  4       P
                  8X  d   R# ^ RIHp  \        T! 4       4      P                  4       pYR,          8H  ;'       g    Y1P                  9   #   \         d     R# i ; i  \         d     R# i ; i)zòTrue for the bin dirs Hermes' bootstrap prepends to this process's PATH: anything
under the active hermes home (the sealed payload's venv, ``<home>/bin``, PM store
runtimes) plus the running interpreter's own bin dir (a repo checkout's venv).FT©r   Úbin)
r   Úresolver@   r/   r0  r(  r#   r   r*   Úparents)r  r  r   Úhomes   &   r   Ú_is_hermes_managed_bin_dirr@  -  s£   € ðÜ˜	“?×*Ñ*Ó,ˆð ”4œŸ™Ó'×/Ñ/Ó1×8Ñ8Ô8ÙÝ0ðÜ‘OÓ%Ó&×.Ñ.Ó0ˆð ˜e•|Ñ#×?Ð? t×/?Ñ/?Ñ'?Ð?øô ô Úðûô ô Úðús#   ‚B ÁB+ ÂB(Â'B(Â+B:Â9B:z5.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSCÚwindowsc                óh   € V ^8„  d   QhR\         \        ,          R\         \        ,          R\        /# )r   ré   rA  r   )r   rÖ   rÊ   r<   )r   s   "r   r   r   B  s/   € ÷ Gñ Gœ8¤D�>ð G¼hÄt½nð GÔX\ñ Gr   c               óÀ  € Vf   \         P                  R8H  MTpV'       g   R.# T ;'       g    / \         P                  3 Fc  p\        R VP	                  4        4       R4      pV'       g   K.  VP                  R4       Uu. uF  qU'       g   K  VNK  	  ppV'       g   Ka  Vu # 	  \        P                  R4       Uu. uF  qU'       g   K  VNK  	  up# u upi u upi )u‰  Executable suffixes a bare name resolves through, in order. The child env's PATHEXT
comes first (``shutil.which`` reads the PARENT's, so a per-profile config value never
reaches a plain ``which`` â€” same source as ``_which_with_config_pathext``), then the
parent's, then the OS default. POSIX appends nothing. ``windows`` injectable for the
same testability reason as ``_npx_bin_candidates``.NÚntrf   c              3   ó¸   "  € T FP  w  rVP                  4       R 8X  g   K  \        V\        4      '       g   K4  VP                  4       '       g   KL  Vx € KR  	  R# 5irð   rò   rô   s   &  r   r~   Ú$_pathext_suffixes.<locals>.<genexpr>L  sE   é € ð V¡N™D˜AØŸ™› iÑ/ô Ü4>¸qÄ#×4Fô ØKLÏ7É7Ï9÷ ’a£Nùrø   rù   )r-   rP   rá   r  râ   ro   Ú_WINDOWS_DEFAULT_PATHEXT)ré   rA  Ú
is_windowsrs   rè   rÿ   r  s   &$     r   Ú_pathext_suffixesrI  B  sÁ   € ð %,¢O”—‘˜D’¸€JßØˆtˆØ—9�9˜"œbŸj™jÓ)ˆÜñ V F§L¡L¤Nó VØW[ó]ˆç‰5Ø#(§;¡;¨sÔ#3Ó;Ñ#3˜C³s—C�CÑ#3ˆDÐ;ß‰tØ’ñ *ô 4×9Ñ9¸#Ô>ÓFÑ>�CÃ#�CˆCÑ>ÑFÐFùò <ùò Gs   Â	CÂCÂ?	CÃCc                ó¬   € V ^8„  d   QhR\         R\        \         ,          R\        \        ,          R\        \        ,          R\        \         ,          /# )r   rì   r  ré   rA  r   )r8   r   rÖ   rÊ   )r   s   "r   r   r   U  sD   € ÷ ñ ¤3ð ´(¼3µ-ð Ü'¬�~ðÜBJÌ4Å.ðÜ\dÔehÕ\iñr   c               ó´  a € \        W#R7      p\        ;QJ d    V 3R lV 4       F  '       g   K   RM	  RM! V 3R lV 4       4      '       d   S .pMV Uu. uF  pS V,           NK  	  pp\        T;'       g    R4      P                  \        P
                  4       F³  pV'       d   \        V4      '       d   K  V F�  p\        P                  P                  Wx4      p	\        P                  P                  V	4      '       g   KI  \        P                  ! V	\        P                  \        P                  ,          4      '       g   K‹  V	u u # 	  Kµ  	  R# u upi )u-  First PATH hit for *command* OUTSIDE Hermes-managed bin dirs, or ``None``.

``shutil.which`` stops at the first hit, and bootstrap prepends the managed runtime's
bin dir, so a bare ``python3`` resolves to the bundled interpreter â€” which lacks the
user's packages and kills the server on import (#125300). Candidates run through
``_pathext_suffixes`` rather than the npx cache layout's ``.cmd``/``.exe`` pair: a user
install may only ship a ``.bat``/``.py`` wrapper, and missing it here would silently
fall back to the managed hit this exists to step past.)rA  c              3   ó�   <"  € T F;  q;'       d.    SP                  4       P                  VP                  4       4      x € K=  	  R # 5ir{   rû   rþ   s   & €r   r~   Ú(_first_user_which_hit.<locals>.<genexpr>`  s1   øé € Ð
IÁD¸S×8Ð8�7—=‘=“?×+Ñ+¨C¯I©I«KÓ8Ô8ÃDùs
   ƒA�6ATFrf   N)rI  r  r8   ro   r-   r  r@  r£   r�   r  r	  r
  r  )
rì   r  ré   rA  r  Únamesrÿ   r  rP   r  s
   f&&$      r   Ú_first_user_which_hitrO  U  sâ   ø€ ô ˜SÔ2€Dß
ƒsÔ
IÁDÓ
I‡s‡s‚sÔ
IÁDÓ
I×IÒIØ�	‰á*.Ó/©$ 3�˜3—�©$ˆÐ/Ü˜Ÿ˜ RÓ(×.Ñ.¬r¯z©zÖ:ˆ	ßÔ6°y×AÒAÙÛˆDÜŸ™Ÿ™ YÓ5ˆIÜ�w‰w�~‰~˜i×(Ô(¬R¯YªY°yÄ"Ç'Á'ÌBÏGÉGÕBS×-TÔ-TØ Ô ó ñ ;ñ ùò 0s   ÁEc                ó^   € V ^8„  d   QhR\         R\        R\        \         \        3,          /# )r   rì   ré   r   )r8   rÖ   r  )r   s   "r   r   r   n  s*   € ÷ )*ñ )*¤Cð )*¬dð )*´u¼SÄ$¸YÕ7Gñ )*r   c                ó¬  € \         P                  P                  \        V 4      P	                  4       4      p\        T;'       g    / 4      p\        P                  ! RRV\        P                  R7      pV\        9   d   \        V4      MRpVeé   Vw  r&\        V,          R8X  d   \        WBV4      w  r&V Uu0 uF"  p\         P                  P                  V4      kK$  	  ppVP                  RR4      P                  \         P                  4       U	u. uF4  q™'       g   K  \         P                  P                  V	4      V9  g   K2  V	NK6  	  p
p	\         P                  P!                  . VOV
O4      VR&   W#3# \         P"                  V9  d‹   VP                  R4      pVe   \$        P&                  ! W+R7      MRpVf*   \(        P*                  R8X  d   V'       d   \-        W+V4      pV'       d   VR	9  d   \/        W+V4      ;'       g    TpV'       d   Tp\         P                  P1                  V4      pV'       d   \3        W=4      pW#3# u upi u up	i )
aÎ  Resolve a stdio command against the exact subprocess env (bare launchers under a filtered PATH).

Bare ``npx``/``npm``/``node``/``uv``/``uvx`` resolve to Hermes's PM-managed copies with their
toolchain dirs first on the child PATH, never the user's (an absolute ``command:`` stays the
user's choice). Anything else resolves on the child env's PATH only: ``shutil.which`` with
``path=None`` silently falls back to the PARENT's ``os.environ["PATH"]``, letting a command
"resolve" against an env the child will never be spawned with. An absent child PATH is a
miss; an explicitly empty one keeps its cwd-only meaning (same distinction the child's
``execvp`` will see); a miss stays as-written for an honest spawn failure.z\.(cmd|exe)$rf   )ÚflagsNr  r  r  r   >   r  r  r  r  r  )r-   r£   r·   r8   r¢   rÖ   ÚreÚsubÚ
IGNORECASEr"  r1  r8  Únormcaser&   ro   r  r�   rÀ   r)  r*  r/   r  r  rO  Údirnamer   )rì   ré   Úresolved_commandÚresolved_envr-  r3  r.  r/  rB   Úprv   r  Ú	which_hitÚcommand_dirs   &&            r   Ú_resolve_stdio_commandr]  n  sá  € ô —w‘w×)Ñ)¬#¨g«,×*<Ñ*<Ó*>Ó?ÐÜ˜Ÿ	˜	˜r“?€LÜ�vŠv�o rÐ+;Ä2Ç=Á=ÔQ€HØ-5Ô9KÔ-KÔ Ô)ÐQU€GØÒØ!(ÑÐÜ˜hÕ'¨5Ô0Ü%5°hÐRVÓ%WÑ"Ðá-1Ó2©T¨”—‘× Ñ  Ö#©TˆÐ2Ø'×+Ñ+¨F°BÓ7×=Ñ=¼b¿j¹jÔIÓsÑI�aËQ”ÔSU×SZÑSZ×ScÑScÐdeÓSfÐnrÑSr—�ÑIˆÐsÜ!Ÿz™zŸ™¨~°¨~¸¨~Ó>ˆ�VÑØÐ-Ð-Ü	‡v�vÐ%Ô%Ø×#Ñ# FÓ+ˆØEMÒEY”F—L’LÐ!1ÕAÐ_cˆ	ØÒ¤§¡°Ô!8¿\Ü2Ð3CÈ|Ó\ˆI÷ Ð)Ð1TÔTÜ-Ð.>È,ÓW×dÐdÐ[dˆIßØ(ÐÜ—'‘'—/‘/Ð"2Ó3€KßÜ$ \Ó?ˆØÐ)Ð)ùò- 3ùÚss   Â8(IÄ	IÄ!!IÅIc                ó^   € V ^8„  d   QhR\         R\         R\        \        ,          R\        /# )r   Úbin_dirrP   rA  r   )r8   r   rÊ   r<   )r   s   "r   r   r   š  s-   € ÷ 	)ñ 	)¤ð 	)¬Cð 	)¼XÄd½^ð 	)ÔW[ñ 	)r   c               óú   € Vf   \         P                  R8H  MTpV'       d7   R Uu. uF)  p\         P                  P                  WV,           4      NK+  	  up# \         P                  P                  W4      .# u upi )aÀ  Launcher paths to try for *name* inside an npx cache's ``.bin``, in order. On Windows that
directory holds the extensionless sh script plus ``<name>.cmd``/``<name>.ps1``; the sh one
cannot be spawned there and ``os.access(X_OK)`` is only an existence check, so select by
extension (same precedence as ``hermes_constants._candidate_node_command_names``). ``windows``
is injectable so the branch is testable without patching ``os.name`` process-wide.rD  )z.cmdz.exe)r-   rP   r£   r�   )r_  rP   rA  rH  rÿ   s   &&$  r   Ú_npx_bin_candidatesra  š  s^   € ð %,¢O”—‘˜D’¸€JßÙ=MÓNÑ=M°c”—‘—‘˜W¨S¥jÖ1Ñ=MÑNÐNÜ�G‰G�L‰L˜Ó'Ð(Ð(ùò Os   ¦/A8c                óF   € V ^8„  d   QhR\         R\        \        ,          /# )r   rO   r   )r<   r   r  )r   s   "r   r   r   ¦  s   € ÷ >ñ >œ$ð >¤8¬E¥?ñ >r   c                ó€  € \        V \        4      '       d	   V '       g   R# \        V 4      pV'       d"   V^ ,          R9   d   VP                  ^ 4       K)  V'       g   R# \        ;QJ d#    R VR,           4       F  '       g   K   RM	  RM! R VR,           4       4      '       d   R# \	        V^ ,          4      pRVP                  R4      9   d   R# V'       d   VP                  R4      '       d   R# \        P                  P                  R4      ;'       g>    \        P                  P                  \        P                  P                  R	4      R
4      p\        P                  P                  VR4      p\        P                  P                  V4      '       g   R#  \        P                  ! V4      pT EF  p\        P                  P                  YFR4      p \!        TRRR7      ;_uu_ 4       p\"        P$                  ! T4      ;'       g    / P                  R4      ;'       g    / p	RRR4       TX	9  d   K†  \        P                  P                  YFRTR4      p
 \!        T
RRR7      ;_uu_ 4       p\"        P$                  ! T4      ;'       g    / P                  R4      pRRR4       \        X\        4      '       d"   \        P                  P+                  T4      .pMC\        T\,        4      '       d+   \/        T4      ^8X  d   \        TP1                  4       4      pMEKq  \        P                  P                  YFRR4      p\3        YÜ^ ,          4       Fc  p\        P                  P5                  T4      '       g   K*  \        P6                  ! T\        P8                  4      '       g   KW  YáR,          3u u # 	  EK  	  R#   \         d     R# i ; i  + '       g   i     EL¸; i  \        \&        \(        3 d     EKR  i ; i  + '       g   i     ELp; i  \        \&        \(        3 d     EK„  i ; i)um  Resolve ``npx -y <pkg>`` to the already-installed binary, or None.

``npx`` resolves the package and then FORKS, staying resident as the real server's parent
for nothing (~48 MB private memory per MCP server, measured); Hermes already supervises the
child (shared death supervisor). When the package is in npx's cache we spawn its binary
directly. Deliberately conservative â€” None (caller keeps plain ``npx``, so a cold machine
still installs) for a cache miss, a version pin (``pkg@1.2.3``), extra npx flags, a manifest
without one obvious bin, or any unreadable cache entry. Returns ``(binary_path, remaining_args)``.Nc              3   ó>   "  € T F  p\        V4      R9   x € K  	  R# 5i©ú-yN©rf  z--yesr“   ©r|   r   s   & r   r~   Ú"_npx_cached_bin.<locals>.<genexpr>¸  s   é € Ð
7©h¨Œ3ˆq‹6�_Ö$«hùó   ‚ºé   NNTFÚ@Ú-Únpm_config_cacher¶   z.npmÚ_npxúpackage.jsonÚrú	utf-8-sigr"   ÚdependenciesÚnode_modulesr<  z.binrg  )ró   r<   r=   r  r8   Úremoveprefixræ   r-   rá   r&   r£   r�   r·   r  Úlistdirr@   r(   ÚjsonÚloadrƒ   Ú	TypeErrorr±   rÖ   ÚlenrB   ra  Úexistsr	  r  )rO   rv   ÚspecÚ
cache_rootÚnpx_rootÚentriesÚentryÚmanifestr2   ÚdepsÚpkg_jsonÚ	bin_fieldrN  r_  r  s   &              r   Ú_npx_cached_binr†  ¦  sí  € ô �dœD×!Ò!¯Ùä�‹:€Dß
�4˜•7˜oÔ-Ø�‰�ŽßÙç
ƒsÑ
7¨d°2®hÓ
7‡s‡s‚sÑ
7¨d°2®hÓ
7×7Ò7Ùäˆt�A�w‹<€Dà
ˆt× Ñ  Ó%Ô&Ùß�4—?‘? 3×'Ò'Ùä—‘—‘Ð 2Ó3×dÐd´r·w±w·|±|ÄBÇGÁG×DVÑDVÐWZÓD[Ð]cÓ7d€JÜ�w‰w�|‰|˜J¨Ó/€HÜ�7‰7�=‰=˜×"Ò"ÙðÜ—*’*˜XÓ&ˆô ˆÜ—7‘7—<‘< °Ó@ˆð	Ü�h ¨k×:Õ:¸bÜŸ	š	 "›×+Ð+¨×0Ñ0°Ó@×FÐFÀB�÷ ;ð �tÔÙÜ—7‘7—<‘< °ÀÀ~ÓVˆð	Ü�h ¨k×:Õ:¸bÜ!ŸYšY r›]×0Ð0¨b×5Ñ5°eÓ<�	÷ ;ô �i¤×%Ò%Ü—W‘W×%Ñ% dÓ+Ð,‰EÜ˜	¤4×(Ò(¬S°«^¸qÔ-@Ü˜Ÿ™Ó)Ó*‰EâÜ—'‘'—,‘,˜x°ÀÓGˆÜ,¨W¸AµhÖ?ˆIÜ�w‰w�~‰~˜i×(Ô(¬R¯YªY°yÄ"Ç'Á'×-JÔ-JØ  r¥(Ð*Ô*ô @ñ- ñ2 øô9 ô Úðú÷ ;×:Ð:ûäœ¤YÐ/ô 	Ûð	ú÷ ;×:Ð:ûäœ¤YÐ/ô 	Ûð	úsx   Æ O
 ÇO0Ç36OÈ*OÈ-O0É!P"É70PÊ'P"Ï
OÏOÏO-Ï'O0Ï-O0Ï0PÐ
PÐPÐP"ÐP"Ð"P=Ð<P=c                óR   € V ^8„  d   QhR\         R\        R\        \        ,          /# )r   rì   rO   r   )r8   r<   r   r  )r   s   "r   r   r   ç  s*   € ÷ @?ñ @?¤ð @?¬Dð @?´X¼eµ_ñ @?r   c                óÂ
  € ^ RI HpHp V! 4       '       d   \        V\        4      '       g   R# V! R4       Uu/ uF#  p\
        P                  P                  V4      VbK%  	  ppVP                  \
        P                  P                  \
        P                  P                  \        V 4      4      4      4      p\        P                  ! R\
        P                  P                  V! R4      4      R7      p\
        P                  P                  T;'       g    RRRRR	4      pVe*   Ve&   \
        P                  P                  V4      '       g   R# \	        V4      p	V	'       d"   V	^ ,          R&9   d   V	P!                  ^ 4       K)  V	'       d   \        V	^ ,          4      MRp
V
'       d`   V
P#                  R
4      '       gI   \$        ;QJ d#    R V	R,           4       F  '       g   K   RM	  RM! R V	R,           4       4      '       d   R# RV
9   g6   V
P#                  R'4      '       g   RV
9   d   V
P#                  R4      '       g   R# V
P#                  R4      '       d   V
P'                  R4      MRRV
3w  r¼pVP)                  R4      w  rìpV'       d   V R2MRT,           p^ RIHp \/        V! 4       4      R,          R,          \0        P2                  ! V
P5                  4       4      P7                  4       R,          ,          pVR,          V,          R,          p\8        P:                  ! RV4      RJpV'       d   VP=                  4       '       gÈ   WxRR\        V4      RRRRRV
.p \>        P@                  ! VRRRR \>        PB                  R!RR"7      pVPJ                  ^ 8w  g   VP=                  4       '       g_   \L        PO                  R#T
VPP                  ;'       g    VPR                  PU                  4       R(R 4       VP=                  4       '       g   R#  \V        PX                  ! VP[                  R$R%7      4      ;'       g    / P                  R4      p\        T\^        4      '       dN   TP                  T4      ;'       g5    \a        T4      ^8X  d#   \c        \e        TPg                  4       4      4      MRp\        T\        4      '       g   R# T\        TPh                  T,          4      .T	R,          O3# u upi   \>        PD                  \F        3 d.   p\>        PH                  ! T^R\        T4      4      p Rp?EL°Rp?ii ; i  \F        \\        3 d     R# i ; i))a‰  ``(node.exe, [bin script, *args])`` for ``npx [-y] <pkg> ...`` when *command* is a sealed
Windows payload's own npx, else None.

That npx starts the package bin through cmd.exe, and cmd.exe cannot start the packaged
``node.exe`` (``pm.user_facing``). Hermes gets here only without a host Node and without
a copy that PM may make. The payload's Python CAN start the packaged ``node.exe``, so the
package is installed with npm's own script and the bin's script runs on that node.
Install scripts stay off, because npm runs them through cmd.exe too. None keeps plain
npx (an honest failure) for any other argv shape, a non-registry spec (git, URL, path:
npm installs those under a name the spec does not show), a failed install, or an
unclear bin.

Like npx, only an exact version is reused as installed. Any other spec re-resolves on
each start and keeps the previous install when npm cannot run (offline).
)Ú_sealed_dirsÚappliesNr  r  r  rf   ru  r<  z
npm-cli.jsrn  c              3   ó>   "  € T F  p\        V4      R9   x € K  	  R# 5ire  r“   rh  s   & r   r~   Ú&_packaged_npx_entry.<locals>.<genexpr>  s   é € Ð.[ÑRZÈQ¬s°1«v¸Ö/HÓRZùrj  rk  TFÚ:rÁ   rm  r;  Úcachezmcp-npx:Né   Nrq  z%\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.+-]+)?Úinstallz--prefixz	--no-savez--ignore-scriptsz
--no-auditz	--no-fundz--loglevel=errorr   r   iX  )Úcapture_outputrÆ   r   r   Ústdinr†   Úcheckz3npm install of %s with the packaged node failed: %srs  r"   rg  )Ú.rÁ   Ú\r¶   iþÿÿ)5r6  r‰  rŠ  ró   r<   r-   r£   rV  r&   rW  r8   r)  r*  r  r�   r  r=   ræ   r  Ú
rpartitionÚ	partitionr#   r   r   ÚhashlibÚsha256ÚencodeÚ	hexdigestrS  Ú	fullmatchÚis_fileÚ
subprocessÚrunÚDEVNULLÚSubprocessErrorr@   ÚCompletedProcessÚ
returncoder+   rA   r0   Ústdoutr¢   rx  ÚloadsÚ	read_textrƒ   rÖ   r{  r  ÚiterÚvaluesr(  )rì   rO   r‰  rŠ  r/  Únpm_dirsÚnpm_dirr  Únpm_clirv   r}  r6   Ú_ÚbareÚbaseÚversionrP   r   Úprefixr‚  Úexactr�  Úresultr4   r…  s   &&                       r   Ú_packaged_npx_entryr³  ç  s  € ÷  5á�9Š9œJ t¬T×2Ò2ÙÙ0<¸UÔ0CÓDÑ0C¨1”—‘× Ñ  Ó# QÒ&Ñ0C€HÐDØ�l‰lœ2Ÿ7™7×+Ñ+¬B¯G©G¯O©O¼CÀ»LÓ,IÓJÓK€GÜ�<Š<˜¤R§Z¡Z§_¡_±\À&Ó5IÓ%JÔK€DÜ�g‰g�l‰l˜7Ÿ=˜= b¨.¸%ÀÈÓU€GØ‚˜$š,¬b¯g©g¯n©n¸W×.EÒ.EÙÜ�‹:€Dß
�4˜•7˜oÔ-Ø�‰�ŽßŒ3ˆt�A�wŒ< R€Dß�4—?‘? 3×'Ò'¯3«3Ñ.[ÐRVÐWYÖRZÓ.[¯3¯3ª3Ñ.[ÐRVÐWYÖRZÓ.[×+[Ò+[ÙØ
ˆd„{�d—o‘oÐ&;×<Ò<ÀÈÄÐUY×UdÑUdÐeh×UiÒUiÙØ-1¯_©_¸S×-AÒ-A�T—_‘_ SÔ)ÈÈBÐPTÀ~�N€EˆdØ—~‘~ cÓ*Ñ€DˆWß ˆuˆg�Q‰K b¨DÕ0€DÝ0ä‘/Ó#Ó$ wÕ.°Õ:¼W¿^º^ÈDÏKÉKËMÓ=Z×=dÑ=dÓ=fÐgjÕ=kÕk€FØ˜Õ&¨Õ-°Õ>€HÜ�LŠLÐAÀ7ÓKÐSWÐW€Eß�h×&Ñ&×(Ò(Ø )¨Z¼¸V»ÀkÐSeØ Ð.@À$ðHˆð	KÜ—^’^ G¸DÀtÐV]ÐfoÜ*4×*<Ñ*<ÀcÐQVôXˆFð ×Ñ Ô!¨×)9Ñ)9×);Ò);Ü�N‰NÐPÐRVØ"ŸM™M×:Ð:¨V¯]©]×AÑAÓCÀDÀEÐJôLà×#Ñ#×%Ò%ÙðÜ—Z’Z × 2Ñ 2¸KÐ 2Ó HÓI×OÐOÈR×TÑTÐUZÓ[ˆ	ô �)œT×"Ò"Ø—M‘M $Ó'÷ Mð MÜ.1°)«nÀÔ.AŒD”�i×&Ñ&Ó(Ó)Ô*Àtð 	ä�i¤×%Ò%ÙØ”#�h—o‘o¨	Õ1Ó2Ð>°T¸"µXÐ>Ð>Ð>ùòY Eøô8 ×*Ñ*¬GÐ4ô 	KÜ×0Ò0°¸!¸RÄÀSÃÓJŽFûð	Kûô ”ZÐ ô Úðús5   ¸)S9Í%,S> Ð,U	 ÑU	 Ó>UÔ"UÕUÕ	UÕUc                ó\  aa€ ^ RI Ho \        V \        4      '       dŽ   \        V \        4      '       d   V P
                  '       g   V # \        V RV 4      p. oVV3R lp\        P                  V4      '       g   V # \        P                  W!4      p\	        W1\        S4      SV.8H  R7      # \        V \        4      '       d/   V P                  4        UUu/ uF  w  rEV\        V4      bK  	  upp# \        V \        4      '       d   V  Uu. uF  p\        V4      NK  	  up# V # u uppi u upi )ai  Recursively resolve ``${VAR}`` / Cursor ``${env:VAR}`` placeholders and context vars. Env
refs resolve from the active profile's secret scope when multiplexing (the routed profile's
value, not another profile's in ``os.environ``). Unset (or empty) vars keep the literal placeholder;
a templated string comes back as a ``_RenderedStr`` recording how it resolved.rØ   rÇ   c                 óF  <€ \         P                  V P                  ^4      P                  4       4      pVe   V! 4       # S! \	        V P                  ^4      4      R4      pV'       g!   SP                  V P                  ^ 4      4       T;'       g    V P                  ^ 4      # )rl  N)Ú_CONTEXT_VAR_RESOLVERSr&   Úgroupr¢   r   Úappend)ÚmÚresolverr  Ú_get_secretrÈ   s   &  €€r   Ú_replaceÚ'_interpolate_env_vars.<locals>._replace6  sx   ø€ Ü-×1Ñ1°!·'±'¸!³*×2BÑ2BÓ2DÓEˆHØÒ#Ù“zÐ!Ù"¤=°·±¸³Ó#<¸dÓCˆHßØ—‘˜aŸg™g a›jÔ)Ø×)Ð)˜qŸw™w q›zÐ)r   )rÈ   rÉ   )rß   rÙ   ró   r8   rÄ   rÈ   r›   Ú_ENV_VAR_PATTERNÚsearchrT  rÊ   rÖ   râ   Ú_interpolate_env_varsr<   )rè   rÇ   r¼  rÆ   rõ   rö   r»  rÈ   s   &     @@r   rÀ  rÀ  *  sö   ù€ õ
 =Ü�%œ×ÒÜ�eœ\×*Ò*°5·<·<°<ØˆLÜ˜5 *¨eÓ4ˆØˆö	*ô  ×&Ñ& x×0Ò0ØˆLÜ×#Ñ# HÓ7ˆÜ˜D´4¸³<È6ÐV^ÐU_ÑK_Ô`Ð`Ü�%œ×ÒØ8=¿¹¼ÔF¹±°�Ô(¨Ó+Ò+¹ÒFÐFÜ�%œ×ÒÙ27Ó8±%¨QÔ% aÖ(±%Ñ8Ð8Ø€Lùó Gùâ8s   ÃD#Ä
D)c                ó<   € V ^8„  d   QhR\         R\        R\        /# ©r   r’   Úconfigr   rí   )r   s   "r   r   r   I  s!   € ÷ ñ ¬#ð ´tð Äñ r   c                óÄ  € RV9  d   V# VP                  R4      ;'       g    R.VP                  R4      ;'       g    / P                  4       Op\        V UUu0 uF8  p\        P	                  \        V4      4       F  qDP                  ^4      kK  	  K:  	  upp4      pV'       d4   RP                  R V 4       4      p\        RV  RV R24      pR	Vn	        VhV# u uppi )
zð*config* back, unless it is a remote server whose ``url`` / ``headers`` still carry a literal
``${VAR}`` after rendering: sending that is a guaranteed 401 that reads as a bad credential
(#119092), so fail closed naming the variable instead.Úurlrf   Úheadersú, c              3   ó.   "  € T F  pR V R2x € K  	  R# 5i)z${Ú}Nr¸   )r|   Úrefs   & r   r~   Ú+_require_rendered_remote.<locals>.<genexpr>R  s   é € Ð=±*¨3˜3˜s˜e 2�³*ùs   ‚zMCP server 'z': zB in url/headers is not set in this profile's .env or secret sourceÚmissing_credentials)
r&   r¨  Úsortedr¾  Úfinditerr8   r·  r�   rƒ   Úfailure_class)r’   rÃ  r¨  rè   r¹  Ú
unresolvedÚrefsÚunsets   &&      r   Ú_require_rendered_remoterÓ  I  sÔ   € ð �FÔØˆØ�j‰j˜Ó×%Ð% 2ÐO¨¯©°IÓ)>×)DÐ)DÀ"×(LÑ(LÓ(NÐO€FÜ±Ôg±¨ÔAQ×AZÑAZÔ[^Ð_dÓ[eÖAf¸AŸ™ žÑAf™±ÒgÓh€JßØ�y‰yÑ=±*Ó=Ó=ˆÜ˜\¨+¨°c¸$¸ð @3ð 3ó 4ˆà3ˆÔØˆØ€Mùó hs   Á>C
c                óR   € V ^8„  d   QhR\         R\        R\        \         ,          /# rÂ  )r8   rÖ   r<   )r   s   "r   r   r   ^  s%   € ÷ ñ ¬ð ´dð ¼tÄC½yñ r   c                óº   aa€ . oR VV3R lloS! VR4       S F=  pW3\         9  g   K  \         P                  W34       \        P                  RW4       K?  	  S# )z÷Warn once per (server, key path) about string values with leading/trailing whitespace (a
pasted newline causes opaque auth failures). Advisory only: values are never mutated (could be
intentional) nor logged (often secrets). Returns flagged paths.c                ó4   € V ^8„  d   QhR\         R\        RR/# )r   rè   r£   r   N)r   r8   )r   s   "r   r   Ú-_warn_hidden_whitespace.<locals>.__annotate__d  s!   € ÷ )ñ )”Sð )¤ð )¨ñ )r   c                 ó˜  <€ \        V \        4      '       d(   W P                  4       8w  d   SP                  V4       R# \        V \        4      '       d<   V P                  4        F%  w  r#S! Y1'       d   V R V 2M
\        V4      4       K'  	  R# \        V \        4      '       d%   \        V 4       F  w  rCS! W1 RV R24       K  	  R# R# )r”  Ú[Ú]N)ró   r8   r¢   r¸  rÖ   râ   r<   Ú	enumerate)rè   r£   rõ   rö   ÚiÚ_walkÚflaggeds   &&   €€r   rÝ  Ú&_warn_hidden_whitespace.<locals>._walkd  s™   ø€ Ü�eœS×!Ò! e¯{©{«}Ô&<Ø�N‰N˜4Ö Ü˜œt×$Ò$ØŸ™ž‘�Ù�a®$˜D˜6  1 #™´C¸³FÖ;ó &ä˜œt×$Ò$Ü! %Ö(‘�Ù�a˜6  1 # Q˜Ö(ó )ñ %r   rf   uÕ   MCP server '%s': config value '%s' has hidden leading or trailing whitespace â€” this often causes authentication or connection failures. Check for stray spaces/newlines in config.yaml (or the referenced env var).)Ú_whitespace_warnedÚaddr+   rA   )r’   rÃ  Úkey_pathrÝ  rÞ  s   && @@r   Ú_warn_hidden_whitespacerã  ^  sc   ù€ ð €G÷)ñ )ñ 
ˆ&�"ÔÛˆØÐ"Ô*<Ö<Ü×"Ñ" KÐ#:Ô;Ü�N‰Nð/à0;öGñ ð €Nr   c                óR   € V ^8„  d   QhR\         R\        R\        \         ,          /# )r   rP   Úcfgr   )r8   r   r   )r   s   "r   r   r   x  s%   € ÷ ñ ¤ð ¬#ð ´(¼3µ-ñ r   c                óœ   € ^ RI Hp  T! T \        V\        4      '       d   TMR4       R#   \         d   p\        T4      u Rp?# Rp?ii ; i)zÈWhy a server's ``tool_costs``/``spend_limit``/``cost_unit`` is unusable, else None. A budget the
user declared must never be silently dropped while its server keeps spending, so the server is skipped.)Úconfig_cost_policyN)Útools.mcp_tool_costsrç  ró   rÖ   rƒ   r8   )rP   rå  rç  r4   s   &&  r   Ú_malformed_cost_tableré  x  sD   € õ 8ðÙ˜4¬
°3¼×(=Ò(=¡À4ÔHñ øô ô Ü�3‹x�ûðús   ˆ!+ «A¶
AÁ AÁAc                ót   € V ^8„  d   QhR\         \        \         3,          R\         \        \         3,          /# )r   Úserversr   ©rÖ   r8   )r   s   "r   r   r   ƒ  s*   € ÷ ñ ¬D´´d°­Oð ÄÄSÌ$ÀYÅñ r   c                óv  €  ^ RI Hp / pV P                  4        Fˆ  w  r4V'       d   \	        V\
        4      '       d	   V! W44      MRpV'       d)   \        P                  RVRP                  V4      4       K]  \        W44      ;pe   \        P                  RW64       K„  WBV&   KŠ  	  V#   \         d    Rp L¯i ; i)zkDrop exfiltration-shaped MCP configs, and servers with a malformed cost table, before any stdio spawn path.)Úvalidate_mcp_server_entryNz'Skipping suspicious MCP server '%s': %sz; zRSkipping MCP server '%s': %s (fix tool_costs/spend_limit/cost_unit in config.yaml))Úhermes_cli.mcp_securityrî  r*   râ   ró   rÖ   r+   rA   r�   ré  Úerror)rë  rî  Úsafe_serversrP   rå  ÚissuesÚ	bad_costss   &      r   Ú_filter_suspicious_mcp_serversrô  ƒ  s«   € ð)ÝEð €LØ—]‘]–_‰	ˆß9RÔWaÐbeÔgk×WlÒWlÑ*¨4Ô5ÐrvˆßÜ�N‰NÐDÀdÈDÏIÉIÐV\ÓL]Ö^Ü0°Ó;Ð;ˆiÒHÜ�L‰LÐmØö*ð "%˜Óñ %ð Ðøô ô )Ø$(Ò!ð)ús   ‚B( Â(B8Â7B8c                ól   € V ^8„  d   QhR\         \        \         3,          R\        \        ,          RR/# )r   rñ  Úrejectedr   N)rÖ   r8   Ú	frozenset)r   s   "r   r   r   –  s3   € ÷ Kñ K¬¬S´$¨Y­ð KÄ9ÌSÅ>ð KÐdhñ Kr   c                ó^  € ^ RI Hp  ^ RIHpHp V! 4        V! 4       P                  4       p\        V4      P                  4        F¶  w  rgWa9   d   \        P                  RV4       K#  W`9   d�   W,          pV U	u/ uF  q™V9   g   K  W˜9  g   K  W—V	,          bK  	  p
p	V
'       d1   / VCV
CW&   \        P                  RVRP                  V
4      4       K‘  \        P                  RV4       K©  \        V4      W&   K¸  	  R
# u up	i   \         d    \        P                  RRR	7        R
# i ; i)aL  Merge plugin-provided (portable) MCP servers into *safe_servers*; native config wins on a clash. Never raises.

The package's declared costs are facts about its server, so a same-name native entry (the way a user widens
a package server's trust) keeps them unless it sets the cost key itself; ``spend_limit: 0`` turns the limit off.)ÚCONFIG_KEYS)Údiscover_pluginsÚget_plugin_managerzLPortable MCP server '%s' skipped: the native entry of that name was rejectedzlPortable MCP server '%s' conflicts with native config; using the native entry with the package's declared %srÇ  z?Portable MCP server '%s' conflicts with native config; skippingz#Failed to load portable MCP serversTr:   N)rè  rù  Úhermes_cli.pluginsrú  rû  Úget_portable_mcp_serversrô  râ   r+   rA   r�   rÖ   r*   r,   )rñ  rö  rù  rú  rû  ÚportablerP   rå  Únativerõ   Úcarrieds   &&         r   Ú_portable_mcp_serversr  –  s  € õ
 1ðKßKÙÔÙ%Ó'×@Ñ@ÓBˆÜ7¸ÓA×GÑGÖI‰IˆDØÔÜ—‘ÐmÐosÖtØÔ%Ø%Õ+�Ù.9ÓZ©k¨À#¹Xœ9È!É/œ9˜1 !�fš9©k�ÐZßØ)>¨FÐ)>°gÐ)>�LÑ&Ü—N‘Nð $DØEIÈ4Ï9É9ÐU\ÓK]ö_ô —N‘NÐ#dÐfjÖkä%)¨#£Y�Ó"ó Jùò
 [øô ô KÜ�‰Ð:ÀTˆ×JðKús1   ˆA2D Á:DÂDÂDÂA#D ÄD Ä"D,Ä+D,c                óF   € V ^8„  d   QhR\         \        \         3,          /# r   rì  )r   s   "r   r   r   ²  s   € ÷ ñ œ$œs¤D˜y�/ñ r   c                 ó^  a
a€ ^ RI Hp  V ! 4       '       d   / #  ^ RIHp ^ RIHp V! R4      '       d   / # T! 4       P                  R4      o ^ RIHp V! 4        / p\        S\        4      '       d   SM/ o\        S4      o
S
P                  4        F7  w  rV\        V4      p\        V\        4      '       g   K(  \        WW4       WtV&   K9  	  \!        V
V3R lS 4       4      p\#        WH4       V#   \         d     L¢i ; i  \         d#   p	\$        P'                  RT	4       / u R	p	?	# R	p	?	ii ; i)
zm``mcp_servers`` from config.yaml as ``{name: config}`` (empty on error / safe mode), ``${VAR}`` interpolated.)Úsafe_worker_enabled)Úload_config)Úenv_var_enabledÚHERMES_SAFE_MODEÚmcp_servers)Úload_hermes_dotenvc              3   óf   <"  € T F&  qS9  g   K  \        VSV,          4      f   K"  Vx € K(  	  R # 5ir{   )ré  )r|   ÚnÚkeptrë  s   & €€r   r~   Ú#_load_mcp_config.<locals>.<genexpr>Ì  s+   øé € Ðv© 1¸D±=œQÔEZÐ[\Ð^eÐfgÕ^hÓEiŸQšQ«ùs   ƒ1�1§
1zFailed to load MCP config: %sN)Úagent.safe_worker_policyr  Úhermes_cli.configr  Úutilsr  r&   rà   r	  r*   ró   rÖ   rô  râ   rÀ  rã  r÷  r  r+   r,   )r  r  Ú_env_enabledr	  rñ  rP   rå  Úinterpolatedrö  r4   r  rë  s             @@r   Ú_load_mcp_configr  ²  s  ù€ å<Ù×ÒØˆ	ðÝ1Ý9ÙÐ*×+Ò+ØˆIÙ“-×#Ñ# MÓ2ˆð	Ý@ÙÔ ð )+ˆÜ'¨´×6Ò6‘'¸BˆÜ-¨gÓ6ˆØŸ™ž‰IˆDÜ0°Ó5ˆLÜ˜,¬×-Ô-Ü'¨Ô;Ø%1˜TÓ"ñ	 &ô Õv©ÓvÓvˆÜ˜lÔ5ØÐøô ô 	Ùð	ûô ô Ü�‰Ð4°cÔ:Ø�	ûðúsR   ™C? ³C? µC? ÁC. ÁAC? Â85C? Ã.C<Ã9C? Ã;C<Ã<C? Ã?D,Ä
D'Ä!D,Ä'D,c                óÂ   € V ^8„  d   Qh/ ^ \         9   d   \        \        \        3,          ;R&   ^\         9   d&   \        \
        \        \        3,          ,          ;R&   # )r   r%   rà  )Ú__conditional_annotations__rÖ   r8   r   Úsetr  )r   s   "r   r   r      sK   € ÷ añ a÷* (Ò '”Dœœc˜•NÑ 'ñ+a÷t 1Ò 0”Cœœc¤3˜h�Õ(Ñ 0òuar   >   ÚHOMEÚLANGr  ÚTERMÚUSERÚSHELLÚLC_ALLÚTMPDIR>   ÚOSÚTMPÚTEMPÚPUBLICÚWINDIRÚAPPDATAÚCOMSPECrñ   ÚHOMEPATHÚUSERNAMEÚ	HOMEDRIVEÚ
SYSTEMROOTÚ
USERDOMAINÚPROGRAMDATAÚSYSTEMDRIVEÚUSERPROFILEÚCOMPUTERNAMEÚLOCALAPPDATAÚPROGRAMFILESÚPROGRAMW6432ÚALLUSERSPROFILEÚCOMMONPROGRAMFILESÚCOMMONPROGRAMW6432ÚNUMBER_OF_PROCESSORSÚPROCESSOR_ARCHITECTUREúPROGRAMFILES(X86)úCOMMONPROGRAMFILES(X86)r{   )Fr  rŽ   rj   r˜  rx  Úloggingr-   rS  r)  rž  r/   rX   Úpathlibr   Útypingr   r   r   r   r   r   Úhermes_cli.stderr_timestampr	   r
   Útools.mcp_tool_commonr   r   Ú	getLoggerr+   r%   ÚLockr$   r5   rD   rF   r•   r§   r÷  rã   rå   Úcompiler¾  r®   r³   r¶  r8   rÄ   rê   r  r"  r1  r8  r@  rG  rI  rO  r]  ra  r†  r³  rÀ  rÓ  r  rà  rã  ré  rô  r  r  r   )r  s   @r   Ú<module>r@     sÉ  øðöaó Û Û Û Û 	Û 	Û Û Û 
Û Ý ß 8× 8ß =ß >à	×	Ò	Ð+Ó	,€à%'Ð Ó 'Ø —~’~Ó'Ð õð2\°T÷ \÷(<ñ (<õVð¸dð ÐUV÷ ñ6 Ò`Óa€ñ #,ò -ó #Ð ð —:’:Ð.Ó/Ð õõ8ð Ñ/Ð1BÑD_ØÐ2°OÁ^ÐUXÑZhðjÐ ô
�3ô õ/õ>ð< ˜U E¨5°&¸%ÀÀtÈUÐTXÐYÐ õõ0Qõ@ð$ SÐ ñGÈt÷ Gð Gñ&ØSW÷ð õ2)*ðX	)Èd÷ 	)õ>õB@?òFõ>ñ$ ,/«5Ð Ó 0õõ4õñ& U^ÓT_÷ K÷8r   