+
    …WÝjá  ã                  óÖ   € R t ^ RIHt ^ RIt^ RIt^ RIHt ]P                  ! ]4      t	Rt
R R ltRRRR	R
R/R R lltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR# )aô  The terminal's PATH: the user's own tools first, Hermes's after them.

Hermes's process puts its store's tool dirs first (``pm.install.activate``), so Hermes's own
code resolves the pinned binaries. Terminal commands belong to the user and the agent, so they
run the tools the user installed, and Hermes's tools are the fallback for a machine without
them. Hermes's own operations must not depend on this PATH: they resolve pinned tools
through PM (``pm.env_for``, ``pm.installed_package``).

A sealed Windows payload's store sits under ``WindowsApps``. In the process tree that the
app's execution alias starts, a program whose own executable is outside the package cannot
start one inside it: cmd.exe running npm's ``npx.cmd`` gets "Access is denied" from the
packaged ``node.exe``, and a venv's ``Scripts\python.exe`` redirector exits 101 when it
starts the packaged Python. A copy of the same files outside the package starts without
error, so there :func:`copies` swaps those dirs for PM's verified copies.
)ÚannotationsN)ÚPathc               ó   € V ^8„  d   QhRR/# )é   ÚreturnÚbool© )Úformats   "ÚBC:\Users\johnn\AppData\Local\hermes\hermes-agent\pm\user_facing.pyÚ__annotate__r      s   € ÷ =ñ =�ñ =ó    c                 ód   € ^ RI Hp  ^ RIHp V! 4       P	                  R4      ;'       d    V ! 4       # )zQTrue for a sealed payload on Windows, the only layout with the restriction above.)Úsealed)Úcurrent_targetÚwin32)Ú
pm.installr   Úpm.storer   Ú
startswith)r   r   s     r
   Úappliesr      s&   € å!Ý'áÓ×&Ñ& wÓ/×<Ð<±F³HÐ<r   ÚrealizeTÚexplicitFÚwhyz&a copy outside the package is requiredc               ó(   € V ^8„  d   QhRRRRRRRR/# )r   ÚnameÚstrr   r   r   r   r   )r	   s   "r
   r   r   $   s)   € ÷  "ñ  "˜ð  "¨ð  "Àð  "Øñ "r   c          	     óÎ  € ^ RI Hp ^ RIHp ^ RIHpHpHpHp	H	p
 ^ RI
Hp ^ RIHp ^ RIHpHp V! V 4      V! 4       V! 4       pppV! VVV4      pVf   R# V! VP#                  4       4      pV^,          P$                  V8X  d   V# V! VVVVV3R7      pVf	   V'       g   V# V'       g   V
! 4       '       g	   V	! W4      hV! V4      V! VR	,          4      ppV! VVVVVVR
7       VV3# )a¾  ``(facts, store)`` of PM's verified copy of the installed *name* in the writable store.

The first call copies the installed entry and checks its digest. It downloads nothing.
If the install already lives in the writable store, that install is the answer. Returns
``None`` when *name* is not installed, or when no copy exists and *realize* is false.
Raises the lazy-install refusal, naming *why*, when a copy is needed and lazy installs
are off.
)Úpaths)Ú	long_root)Ú_installÚ_installed_locationÚ	_lockfileÚ_refuse_lazyÚlazy_installs_allowed)ÚFacts)Úget_package)ÚStorer   N)ÚverifyÚrootsz
facts.json)Ú	copy_from)Úpmr   Úpm.filesystemr   r   r   r   r    r!   r"   Úpm.lockr#   Úpm.registryr$   r   r%   r   Úwritable_store_rootÚroot)r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r   ÚpackageÚlockfileÚtargetÚlocationÚwritableÚcopiedÚ
copy_storeÚ
copy_factss   &$$$                   r
   Úwritable_copyr7   $   sß   € õ Ý'ßhÕhÝÝ'ß.á +¨DÓ 1±9³;ÁÓ@P�vˆX€GÙ" 7¨H°fÓ=€HØÒÙá˜×2Ñ2Ó4Ó5€HØ�…{×Ñ˜8Ô#ØˆÙ  ¨(°FÀ8ÐT\ÐS^Ô_€FØÒ§ØˆßÑ1×3Ò3Ù˜4Ó%Ð%Ù" 8›_©e°H¸|Õ4KÓ.L�
€JÙˆW�h 
¨J¸È(ÕSØ�zÐ!Ð!r   c               ó    € V ^8„  d   QhRRRR/# ©r   r   r   r   ú	list[str]r   )r	   s   "r
   r   r   G   s   € ÷ Qñ Q˜cð Q iñ Qr   c                óô   € ^ RI Hp V P                  W!P                  4      P	                  R4      ;'       g    . p\        V\        4      '       d   V.MT Uu. uF  qU'       g   K  V! V4      NK  	  up# u upi )zMThe PATH dirs that *store*'s install of *name* contributes, natively spelled.)ÚnativeÚPATH)r*   r<   Úenv_forr.   ÚgetÚ
isinstancer   )ÚfactsÚstorer   r<   ÚdirsÚds   &&&   r
   Ú_dirsrE   G   s_   € å$à�=‰=˜Ÿz™zÓ*×.Ñ.¨vÓ6×<Ð<¸"€DÜ*4°T¼3×*?Ò*? ¡ÀTÐ IÓPÑ I˜!ËaŒI‰F�1ŽIÑ IÑPÐPùÒPs   Á	A5Á&A5c               ó    € V ^8„  d   QhRRRR/# r9   r   )r	   s   "r
   r   r   O   s   € ÷ Xñ X�sð X˜yñ Xr   c                óŽ   € ^ RI HpHp V! 4       V! 4       rCVP                  V RVP                  4      '       d   \        W4V 4      # . # )é    )Ú_factsÚ_storeN)r   rI   rJ   Ú	installedr.   rE   )r   rI   rJ   rA   rB   s   &    r
   Ú_sealed_dirsrL   O   s9   € ß)á“8™V›Xˆ5Ø(-¯©¸¸dÀEÇJÁJ×(OÒ(OŒ5�˜tÓ$ÐWÐUWÐWr   c               ó    € V ^8„  d   QhRRRR/# r9   r   )r	   s   "r
   r   r   V   s   € ÷ 	Bñ 	B�Sð 	B˜Yñ 	Br   c                ó²   € ^ RI Hp  \        V 4      pTe   \        . TOT N5!  # . #   T\        3 d#   p\        P                  RY4       . u Rp?# Rp?ii ; i)z_The PATH dirs of *name*'s writable copy, made on first use, or ``[]`` when PM may not make one.)ÚInstallErrorz*user-facing %s stays the packaged copy: %sN)Ú
pm.packagerO   r7   ÚOSErrorÚLOGÚdebugrE   )r   rO   r2   Úexcs   &   r
   Ú
_copy_dirsrU   V   s^   € å'ðÜ  Ó&ˆð &.Ò%9Œ5Ð!�(Ð!˜DÓ!ÐA¸rÐAøð œ'Ð"ô Ü�	‰	Ð>ÀÔJØ�	ûðús   ˆ' §A´AÁAÁAc               ó    € V ^8„  d   QhRRRR/# )r   rC   r:   r   r   )r	   s   "r
   r   r   b   s   € ÷ \ñ \�ð \˜yñ \r   c                ó4  aa€ \        4       '       g   \        V 4      # / o\         FH  p\        V4      pV'       d   \	        V4      M. oS'       g   K-  SP                  V3R lV 4       4       KJ  	  \        \        P                  V3R lV  4       4      4      # )z¯*dirs* with each packaged npm, node and python dir swapped for its writable copy on a
sealed Windows payload. A packaged dir stays when PM may not copy it (lazy installs off).c              3  óf   <"  € T F&  p\         P                  P                  V4      S3x € K(  	  R # 5i©N)ÚosÚpathÚnormcase)Ú.0rD   r4   s   & €r
   Ú	<genexpr>Úcopies.<locals>.<genexpr>l   s%   øé € ÐF¹v¸!œŸ™×)Ñ)¨!Ó,¨fÕ5»vùs   ƒ.1c              3  ó”   <"  € T F=  pSP                  \        P                  P                  V4      V.4       F  q"x € K  	  K?  	  R # 5irY   )r?   rZ   r[   r\   )r]   rD   ÚcÚswaps   &  €r
   r^   r_   m   s9   øé € ÐZ© A°t·x±xÄÇÁ×@PÑ@PÐQRÓ@SÐVWÐUXÖ7Y°!œaÑ7Y™a«ùs   ƒAA)r   ÚlistÚCOPIEDrL   rU   ÚupdateÚdictÚfromkeys)rC   r   r   r4   rb   s   &  @@r
   Úcopiesrh   b   sp   ù€ ô �9Š9Ü�D‹zÐØ!#€DßˆÜ˜dÓ#ˆß%+”˜DÔ!°ˆß‰6Ø�K‰KÔF¹vÓFÖFñ	 ô
 ”—‘ÔZ©ÓZÓZÓ[Ð[r   c               ó    € V ^8„  d   QhRRRR/# )r   Ú	directoryr   r   r   r   )r	   s   "r
   r   r   p   s   € ÷ ñ  ð ¨ñ r   c                ó”  € \        V 4      P                  RR  Uu. uF"  p\        P                  P	                  V4      NK$  	  ppV\        P                  P	                  R4      \        P                  P	                  R4      .8w  d   R#  \        \        V 4      P                  R4      4      '       * # u upi   \         d     R# i ; i)a  True for the Windows app-alias dir when its ``python.exe`` is only the Store stub.

The stub opens the Microsoft Store instead of running Python. A real Store Python puts its
aliases in the same dir, and it also ships a ``python3.N.exe``, which the stub does not.
NÚ	MicrosoftÚWindowsAppsFzpython3.*.exeTéþÿÿÿ)r   ÚpartsrZ   r[   r\   ÚanyÚglobrQ   )rj   Úpartro   s   &  r
   Ú_python_stub_dirrs   p   s¤   € ô 15°Y³×0EÑ0EÀbÀcÑ0JÓKÑ0J¨ŒR�W‰W×Ñ˜dÖ#Ñ0J€EÐKØ”—‘×!Ñ! +Ó.´·±×0@Ñ0@ÀÓ0OÐPÔPÙðÜ”t˜I“×+Ñ+¨OÓ<Ó=Ô=Ð=ùò	 Løô
 ô Úðús   ›(B3Â'B8 Â8CÃCc               ó   € V ^8„  d   QhRR/# )r   r   r:   r   )r	   s   "r
   r   r      s   € ÷ hñ h�iñ hr   c                 ó¼   € ^ RI Hp  V ! RRR/R7      P                  RR4      P                  \        P
                  4       Uu. uF  q'       g   K  VNK  	  up# u upi )rH   )r>   Úpythonr=   Ú )Úbase_env)r   r>   r?   ÚsplitrZ   Úpathsep)r>   rD   s     r
   Ú_python_dirsr{      sN   € Ý"á˜x°6¸2°,Ô?×CÑCÀFÈBÓO×UÑUÔVX×V`ÑV`ÔaÓgÑa�!Óef�AˆAÑaÑgÐgùÒgs   Á	AÁAc               ó    € V ^8„  d   QhRRRR/# )r   r[   r   r   r   )r	   s   "r
   r   r   …   s   € ÷ Uñ U˜3ð U 3ñ Ur   c                ó¸  € ^ RI Hp V! 4       pV'       g   V # \        V4      p. VOVO Uu0 uF"  p\        P                  P                  V4      kK$  	  ppV P                  \        P                  4       Uu. uF4  qf'       g   K  \        P                  P                  V4      V9  g   K2  VNK6  	  pp\        \        4       4       Uu0 uF"  p\        P                  P                  V4      kK$  	  pp\        R \        V4       4       \        V4      4      p	V Uu. uF+  p\        P                  P                  V4      V9   g   K)  VNK-  	  p
pV Uu. uF+  p\        P                  P                  V4      V9  g   K)  VNK-  	  pp\        P                  P                  \        P                  . VRV	 OV
OWyR OVO4      4      # u upi u upi u upi u upi u upi )zù*path* with Hermes's store tool dirs (their writable copies, see :func:`copies`) moved
behind the user's own entries.

Hermes's Python stops just before the app-alias dir that holds the Store stub, so a
machine without Python still runs a real one.
)Ú_store_path_dirsc              3  óP   "  € T F  w  r\        V4      '       g   K  Vx € K  	  R # 5irY   )rs   )r]   ÚiÚps   &  r
   r^   Ú#user_facing_path.<locals>.<genexpr>•   s   é € ÐE™o‘d�aÔ1AÀ!×1D—’›oùs   ‚&œ
&N)r   r~   rh   rZ   r[   r\   ry   rz   r{   ÚnextÚ	enumerateÚlenÚjoinrf   rg   )r[   r~   rB   ÚoursrD   Úkeysr�   Úkeptrv   ÚcutÚearlyÚlates   &           r
   Úuser_facing_pathr�   …   su  € õ ,áÓ€EßØˆÜ�%‹=€DØ)8¨5¨°4©Ó9© AŒB�G‰G×Ñ˜QÖ©€DÐ9Ø—z‘z¤"§*¡*Ô-ÓWÑ-�!³ŒA´r·w±w×7GÑ7GÈÓ7JÐRVÑ7V�AˆAÑ-€DÐWÜ+1´,³.Ô+AÓBÑ+A aŒb�g‰g×Ñ˜qÖ!Ñ+A€FÐBÜ
ÑEœi¨œoÓEÄsÈ4ÃyÓ
Q€CÙÓ>™�1¤§¡× 0Ñ 0°Ó 3°vÑ =�QˆQ™€EÐ>ÙÓA‘t�!œrŸw™w×/Ñ/°Ó2¸&Ñ@�AˆA‘t€DÐAÜ�:‰:�?‰?œ4Ÿ=™=Ð)R¨4°°¨:Ð)R¸Ð)RÀÀTÀ
Ð)RÈTÐ)RÓSÓTÐTùò :ùÚWùÚBùâ>ùÚAs5   «(GÁ6	GÂ!GÂ*GÃ(GÄ&GÅGÅ&GÅ<G)ÚnpmÚnoderv   )Ú__doc__Ú
__future__r   ÚloggingrZ   Úpathlibr   Ú	getLoggerÚ__name__rR   rd   r   r7   rE   rL   rU   rh   rs   r{   r�   r   r   r
   Ú<module>r–      sy   ðñõ #ã Û 	Ý à×Ò˜Ó!€ð 
#€õ=ð "°ð  "Àuð  "ØE÷ "õFQõXõ	Bõ\õõh÷Ur   