+
    „WÝj½r  ã                  ó–  € R t ^ RIH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]
P                  R8H  tRsRtRtR R ltR	 R
 ltR>R R lltR R lt ! R R]P*                  P,                  ]P*                  P.                  4      tR R ltR R lt^tR?R R lltR R ltR R ltR R ltR?R R llt R R  lt!]! 4        ]! 4        ]! 4        ]! 4        ^ R!I"H#t# ]#! ]$4      PK                  4       PL                  t' ]PP                  ! 4        R" R# lt+] ! ],! ]'4      4       R$ R% lt-]-! 4        R& R' lt.].! 4        ]+! ]
P^                  R(,          4      t0]0e   ^ R)I1H2t2 ]0w  t3t4]5! ]2! ]3]4R*7      4      h ! R+ R,]54      t6^ R-I7H8t8H9t9 ^ R.I:H;t; ^ R/I<H=t= ]=! ]
P^                  R(,          4      R0,          R1R2.8H  t>]>'       gÊ   ^ R3I?H@t@HAtA  ]@! ]']
P^                  R(,          4      tB]Be’   ]C! ]
Pˆ                  P‹                  R44      R5R4      tF]A! ]B]']
P^                  ]
PŽ                  ]C! ]FR6R4      4      tH]P’                  R78X  d   ^ RIJtJ]6! ]JP–                  ! ]H4      4      h]P˜                  ! ],! ]B4      ]H4        ];! ]'4       ]8! ]'4       ]! 4        ]!! 4        R#   ]) d    ]PT                  ! ]'4        EL§i ; i  ]M dc   tN]O! ]N]P4      '       d2   ]9! ]']N4      ;tQ'       d!   ]R! R8]Q 2]
P¦                  R97       ]5! ^4      Rh]R! R:]N R;2]
P¦                  R97        RtNANL¥RtNANii ; i  ]T]U3 d“   tN]O! ]N]P4      '       d2   ]9! ]']N4      ;tQ'       d!   ]R! R8]Q 2]
P¦                  R97       ]5! ^4      Rh]=! ]
P^                  R(,          4      R<,          R1.8w  d"   ]R! R8]N R=2]
P¦                  R97       ]5! ^4      Rh RtNANEL2RtNANii ; i)@u—  Process bootstrap for Hermes entry points: Windows UTF-8 stdio and ANSI console, import-path
hardening, durable lazy-install target, and dual-stack (Happy Eyeballs) connects.

Windows binds stdio to the console code page (cp1252), so ``print("cafÃ©")`` raises
``UnicodeEncodeError``, and Python children inherit the same default unless
``PYTHONUTF8``/``PYTHONIOENCODING`` are set. Import this module first in every entry
point (``hermes``, ``hermes-agent``, ``hermes-acp``, ``gateway.run``, ``batch_runner``,
``cron/scheduler``). It does NOT re-exec with ``-X utf8``: ``open()`` in the current
process still needs an explicit ``encoding="utf-8"`` (ruff ``PLW1514``). POSIX is left
alone deliberately â€” users' ``LANG``/``LC_*`` choices are respected.

Stdlib only: entry points import this before ``harden_import_path()`` runs, so nothing
here may pull in a Hermes package that a project-local directory could shadow.
)ÚannotationsNÚwin32Fg      Ð?zurllib3.util.connectionc               ó    € V ^8„  d   QhRRRR/# )é   Ú	addrinfoszlist[tuple]Úreturn© )Úformats   "ÚDC:\Users\johnn\AppData\Local\hermes\hermes-agent\hermes_bootstrap.pyÚ__annotate__r   !   s   € ÷ ñ  [ð °[ñ ó    c                óL  € / p\        4       pV  FH  pVw  rErgpWEWh3V9  g   K  VP                  WEWh34       VP                  V. 4      P                  V4       KJ  	  . p	\	        VP                  4       4      '       d)   V	P                  R VP                  4        4       4       KG  V	# )z[Round-robin the resolved address families (deduped), preserving resolver order within each.c              3  óV   "  € T F  q'       g   K  VP                  ^ 4      x € K!  	  R# 5i©é    N)Úpop)Ú.0Úqueues   & r
   Ú	<genexpr>Ú(_interleave_addrinfos.<locals>.<genexpr>,   s   é € ÐN±_¨EËœ<˜5Ÿ9™9 QŸ<˜<³_ùs   ‚	)�))ÚsetÚaddÚ
setdefaultÚappendÚanyÚvaluesÚextend)
r   ÚqueuesÚseenÚaddrinfoÚfamilyÚsocktypeÚprotoÚ
_canonnameÚsockaddrÚinterleaveds
   &         r
   Ú_interleave_addrinfosr&   !   s•   € à%'€FÜ“u€DÛˆØ8@Ñ5ˆ˜%¨XØ˜eÐ.°dÖ:Ø�H‰H�f¨Ð8Ô9Ø×Ñ˜f bÓ)×0Ñ0°Ö:ñ	 ð
  "€KÜ
ˆf�m‰m‹o×
Ò
Ø×ÑÑN°V·]±]´_ÓNÖNØÐr   c               ó   € V ^8„  d   QhRR/# ©r   r   ÚNoner   )r	   s   "r
   r   r   0   s   € ÷ ñ ¨ñ r   c                óN   €  V P                  V4       R #   \         d     R # i ; i©N)Ú
unregisterÚ	Exception)ÚselectorÚsocks   &&r
   Ú_quiet_unregisterr0   0   s'   € ðØ×Ñ˜DÖ!øÜô Úðús   ‚ •$£$c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úaddressztuple[str, int]Útimeoutzfloat | NoneÚsource_addressztuple[str, int] | Noner   )r	   s   "r
   r   r   7   s'   € ÷ [ñ [¨ð [Èð [Ø6Lñ[r   c           
     óÊ  aaaa€ V w  rE\        \        P                  ! WE\        P                  R7      4      pV'       g   \	        RV 24      h\
        P                  ! 4       o\        4       oRpRpVf   RM%\        P                  ! 4       \        VR4      ,           p	\        P                  ! 4       p
\        V4      p^ \        P                  \        P                  \        P                  \        P                   \#        \        RR4      0oVVVV3R lp V'       g
   S'       Ed�   \        P                  ! 4       pV	e   WÙ8¼  d   \%        R4      hV'       d2   WÚ8¼  d,    V! VP'                  ^ 4      4      pTe   EM6T\(        ,           p
V	f   RM\        RW�,
          4      pV'       d%   \        RW­,
          4      pVf   TM\+        VV4      pSP-                  V4       F�  w  ppVP.                  pVP1                  \        P2                  \        P4                  4      pSP7                  V4       SP9                  V4       V^ 8X  d   Tp M4VP;                  4        \	        V\<        P>                  ! V4      4      pKŸ  	  Ve   M.S'       d   EKz  V'       g   EK…  \        P                  ! 4       p
EK�  Vf   Ve   Vh\	        R	V R
V 24      h\A        SV4       SP9                  V4       VPC                  V4       T;'       g    R F  pVPD                  ! V!   K  	  VPE                  \        PF                  \        PH                  ^4       TS F  p\A        SV4       VP;                  4        K!  	  SP;                  4        #   \         d   pTpS'       g   Tp
 Rp?EK�  Rp?ii ; i  S F  p\A        ST4       TP;                  4        K!  	  SP;                  4        i ; i)zØRFC 8305-style connect: staggered non-blocking attempts across families.

``socket.create_connection`` tries addresses serially, so broken-but-
advertised IPv6 can burn the whole timeout per AAAA record before IPv4.
)Útypez&getaddrinfo returned no addresses for Ng        ÚWSAEWOULDBLOCKi3'  c                ó~  <€ V w  rr4p\         P                   ! WV4      p Seg   \         P                  ! S^ ,          S^,          WR7      pV'       g   \        RV RS^ ,           24      hVP                  V^ ,          ^,          4       VP	                  R4       VP                  V4      pV^ \        P                  39   d   V# VS
9  d!   \        V\        P                  ! V4      4      hSP                  V\        P                  4       S	P                  V4       R #   \         d    TP                  4        h i ; i)N)r    r6   zgetaddrinfo returned no local z address for F)ÚsocketÚgetaddrinfoÚOSErrorÚbindÚsetblockingÚ
connect_exÚerrnoÚEISCONNÚosÚstrerrorÚregisterÚ	selectorsÚEVENT_WRITEr   r-   Úclose)r   r    r!   r"   r#   r$   Ú	candidateÚlocal_infosÚresultÚactiveÚin_progressr.   r4   s   &        €€€€r
   Ústart_attemptÚ8_happy_eyeballs_create_connection.<locals>.start_attemptL   s  ø€ Ø8@Ñ5ˆ˜%¨XÜ—M’M &°EÓ:ˆ	ð	ØÒ)Ü$×0Ò0°ÀÕ1BÀNÐSTÕDUÐ^dÔt�ß"Ü!Ð$BÀ6À(È-ÐXfÐghÕXiÐWjÐ"kÓlÐlØ—‘˜{¨1�~¨aÕ0Ô1Ø×!Ñ! %Ô(Ø×)Ñ)¨(Ó3ˆFØ˜!œUŸ]™]Ð+Ô+Ø Ð Ø˜[Ô(Ü˜f¤b§k¢k°&Ó&9Ó:Ð:Ø×Ñ˜i¬×)>Ñ)>Ô?Ø�J‰J�yÔ!ÙøÜô 	Ø�O‰OÔØð	ús    B$D ÃAD ÄD<z	timed outzCould not connect to Ú:r   )%r&   r9   r:   ÚSOCK_STREAMr;   rD   ÚDefaultSelectorr   ÚtimeÚ	monotonicÚmaxÚlistr?   ÚEINPROGRESSÚEWOULDBLOCKÚEALREADYÚEINTRÚgetattrÚTimeoutErrorr   Ú_HAPPY_EYEBALLS_DELAY_SECONDSÚminÚselectÚfileobjÚ
getsockoptÚ
SOL_SOCKETÚSO_ERRORr,   ÚdiscardrF   rA   rB   r0   Ú
settimeoutÚ
setsockoptÚIPPROTO_TCPÚTCP_NODELAY)r2   r3   r4   Úsocket_optionsÚhostÚportr   ÚwinnerÚ
last_errorÚdeadlineÚnext_launchÚpendingrL   ÚnowÚexcÚwait_timeoutÚuntil_launchÚkeyÚ_maskrG   Ú
error_codeÚoptionrJ   rK   r.   s   &&f&                  @@@r
   Ú!_happy_eyeballs_create_connectionrw   7   s&  û€ ð �J€DÜ%¤f×&8Ò&8¸Ì&×J\ÑJ\Ô&]Ó^€IßÜÐ>¸t¸fÐEÓFÐFä×(Ò(Ó*€HÜ!$£€FØ€FØ!%€JØ’‰t¬D¯NªNÓ,<¼sÀ7ÈCÓ?PÕ,P€HÜ—.’.Ó"€KÜ�9‹o€GØ”e×'Ñ'¬×):Ñ):¼E¿N¹NÌEÏKÉKÔY`ÔafÐhxÐzó  ZAð  B€K÷ð ð,0ßŸ˜Ü—.’.Ó"ˆCØÒ#¨¬Ü" ;Ó/Ð/ß˜3Ô-ðÙ*¨7¯;©;°q«>Ó:�Fð Ò%ÙØ!Ô$AÕA�Ø#+Ò#3™4¼¸SÀ(Å.Ó9QˆLßÜ" 3¨Õ(9Ó:�Ø/;Ò/C™|ÌÈ\Ð[gÓIh�Ø&Ÿo™o¨lÖ;‘
��UØŸK™K�	Ø&×1Ñ1´&×2CÑ2CÄVÇ_Á_ÓU�
Ø×#Ñ# IÔ.Ø—‘˜yÔ)Ø ”?Ø&�FÙØ—‘Ô!Ü$ Z´·²¸ZÓ1HÓI’
ñ <ð Ò!Øß’6ŸgšgÜ"ŸnšnÓ.“àŠ>Ø *Ò 6�*Ðj¼GÐF[Ð\`Ð[aÐabÐcgÐbhÐDiÓ<jÐjÜ˜( FÔ+Ø�‰�vÔØ×Ñ˜'Ô"Ø$×*Ð*¨Ò*ˆFØ×Ò˜vÔ&ñ +à×Ñœ&×,Ñ,¬f×.@Ñ.@À!ÔDØãˆIÜ˜h¨	Ô2Ø�O‰OÖñ  ð 	�‰ÕøôQ ô Ø!$�Jß!Ø&)˜Þûð	ûóJ  ˆIÜ˜h¨	Ô2Ø�O‰OÖñ  ð 	�‰Õúsc   ÄN+ ÄN+ Ä'1N+ ÅN+ Å N Å72N+ Æ*C N+ ÊN+ ÊA)N+ ÌA
N+ ÎN(ÎN#ÎN+ Î#N(Î(N+ Î+7O"c               ó   € V ^8„  d   QhRR/# r(   r   )r	   s   "r
   r   r   •   s   € ÷ .ñ .°ñ .r   c                óŽ   a€ \        V P                  RR4      '       d   R# V P                  oSRR3V3R llpRVn        Wn        R# )zYPoint ``urllib3.util.connection.create_connection`` (its own serial walker) at the racer.Ú_hermes_happy_eyeballsFNc           	     ó€   <€ VSJ d   \         P                  ! 4       MTp\        YT\        T;'       g    R4      R 7      # ))r4   rg   r   )r9   Úgetdefaulttimeoutrw   Útuple)r2   r3   r4   rg   Ú	effectiveÚurllib3_sentinels   &&&& €r
   Ú_urllib3_racerÚ8_patch_urllib3_create_connection.<locals>._urllib3_racer›   sC   ø€ Ø29Ð=MÓ2M”F×,Ò,Ô.ÐSZˆ	ô 1Ø¨~ÌeÐTb×ThÐThÐfhÓNiôkð 	kr   T)rY   Úcreate_connectionÚ_DEFAULT_TIMEOUTrz   )Úmoduler€   r   s   & @r
   Ú _patch_urllib3_create_connectionr…   •   sF   ø€ äˆv×'Ñ'Ð)AÀ5×IÒIÙØ×.Ñ.Ðà(8ÈÐ^b÷ kð -1€NÔ)Ø-Ör   c                  ó0   € ] tR t^¦tRtRR ltR tR tRtR# )Ú_Urllib3ConnectionPatcherzëOne-shot import hook: patch urllib3's connect walker the moment the module loads.

Importing urllib3 eagerly costs ~50 ms on every CLI start, and ``hermes`` / the TUI
gateway never load it unless something actually calls ``requests``.
Nc                	ó  € V\         8w  d   R # V \        P                  9   d    \        P                  P                  V 4       \        P
                  P                  V4      pVe   VP                  f   R # VP                  V n        Wn        V# r+   )	Ú_URLLIB3_CONNECTION_MODULEÚsysÚ	meta_pathÚremoveÚ	importlibÚutilÚ	find_specÚloaderÚ_inner)ÚselfÚfullnameÚpathÚtargetÚspecs   &&&& r
   r�   Ú#_Urllib3ConnectionPatcher.find_spec­   sf   € ØÔ1Ô1ÙØ”3—=‘=Ô Ü�M‰M× Ñ  Ô&Ü�~‰~×'Ñ'¨Ó1ˆØŠ<˜4Ÿ;™;Ò.ÙØ—k‘kˆŒØŒØˆr   c                	ó8   € V P                   P                  V4      # r+   )r‘   Úcreate_module)r’   r–   s   &&r
   r™   Ú'_Urllib3ConnectionPatcher.create_module¹   s   € Ø�{‰{×(Ñ(¨Ó.Ð.r   c                	óR   € V P                   P                  V4       \        V4       R # r+   )r‘   Úexec_moduler…   )r’   r„   s   &&r
   rœ   Ú%_Urllib3ConnectionPatcher.exec_module¼   s   € Ø�‰×Ñ Ô'Ü(¨Ö0r   )r‘   r+   )	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r�   r™   rœ   Ú__static_attributes__r   r   r
   r‡   r‡   ¦   s   † ñô
ò/ö1r   r‡   c               ó   € V ^8„  d   QhRR/# r(   r   )r	   s   "r
   r   r   Á   s   € ÷ =ñ =¨tñ =r   c                 ó
  € \        \        P                  RR4      '       d   R# \        P                  R3RR/R llp RV n        V \        n        \
        P                  P                  \        4      pVe   \        V4       R# \        ;QJ d*    R \
        P                   4       F  '       g   K   RM	  RM! R \
        P                   4       4      '       g+   \
        P                  P                  ^ \        4       4       R# R# )uÝ  Race IPv6/IPv4 for every sync TCP connect in the process (RFC 8305, #114265).

The startup path does not build its HTTP clients in one place: the model catalog
fetch goes through ``requests``/``urllib3``, sync LLM and OAuth clients through
httpcore, plugins through ``urllib``/``http.client``. All of them funnel their TCP
connect into ``socket.create_connection`` (``http.client`` re-reads it per connection;
httpcore looks it up at call time) or into urllib3's own serial copy in
``urllib3.util.connection``. The stock implementations walk the ``getaddrinfo``
results serially â€” on a network whose advertised IPv6 route is blackholed, each AAAA
record burns the full connect timeout before IPv4 answers. Idempotent, best-effort.
rz   FNÚ
all_errorsc               ór   € V\         P                  J d   \         P                  ! 4       MTp\        WVR 7      # ))r4   )r9   Ú_GLOBAL_DEFAULT_TIMEOUTr|   rw   )r2   r3   r4   r¦   r~   s   &&&$ r
   Ú_socket_racerÚ<install_happy_eyeballs_socket_connect.<locals>._socket_racerÐ   s2   € ð 3:¼V×=[Ñ=[Ó2[”F×,Ò,Ô.Ðahˆ	ô 1°ÐTbÔcÐcr   Tc              3  óB   "  € T F  p\        V\        4      x € K  	  R # 5ir+   )Ú
isinstancer‡   )r   Úfinders   & r
   r   Ú8install_happy_eyeballs_socket_connect.<locals>.<genexpr>ß   s   é € Ð[É]À6”˜FÔ$=×>Ð>Ë]ùs   ‚)rY   r9   r‚   r¨   rz   rŠ   ÚmodulesÚgetr‰   r…   r   r‹   Úinsertr‡   )r©   Úurllib3_connections     r
   Ú%install_happy_eyeballs_socket_connectr³   Á   s´   € ô Œv×'Ñ'Ð)AÀ5×IÒIÙä'-×'EÑ'EÐVZñ dÐjoõ dð ,0€MÔ(Ø,„FÔäŸ™Ÿ™Ô)CÓDÐØÒ%Ü(Ð);Ö<ß‹SÑ[ÌSÏ]Ê]Ó[�S�SŠSÑ[ÌSÏ]Ê]Ó[×[Ò[Ü�‰×Ñ˜QÔ 9Ó ;Ö<ñ \r   c               ó   € V ^8„  d   QhRR/# ©r   r   Úboolr   )r	   s   "r
   r   r   ã   s   € ÷ ñ  dñ r   c                 óZ  € \         '       d   \        '       d   R# \        P                  P	                  RR4       \        P                  P	                  RR4       R F0  p \        \        \        V R4      RR4      pVf   K%   V! RRR	7       K2  	  R
sR
#   \        \        3 d     KL  i ; i)zPApply the Windows UTF-8 bootstrap once; True only when it was applied this call.FÚ
PYTHONUTF8Ú1ÚPYTHONIOENCODINGzutf-8NÚreconfigureÚreplace)ÚencodingÚerrorsT)ÚstdoutÚstderrÚstdin)	Ú_IS_WINDOWSÚ_bootstrap_appliedrA   Úenvironr   rY   rŠ   r;   Ú
ValueError)Ústream_namer»   s     r
   Úapply_windows_utf8_bootstraprÇ   ã   sœ   € ÷ ‹;×,Ó,Ùô ‡J�J×Ñ˜,¨Ô,Ü‡J�J×ÑÐ,¨gÔ6ó 5ˆÜœg¤c¨;¸Ó=¸}ÈdÓSˆØÒÙð	Ù °×;ñ 5ð ÐÙøô	 œÐ$ô 	Úð	ús   Â
BÂB*Â)B*c               ó   € V ^8„  d   QhRR/# rµ   r   )r	   s   "r
   r   r     s   € ÷ #ñ # tñ #r   c                óš  € \         '       g   R# ^ RIp^ RIp^ RIHp VP	                  RRR7      pRpV f!   \
        P                  \
        P                  3MT  Fª  p VP                  VP                  4       4      pTP                  4       pTP                  YqP                  T4      4      '       g   K[  TP                   \"        ,          '       d   Kz  TP%                  YxP                   \"        ,          4      '       d   K¨  RpK¬  	  V'       g!   \&        P(                  P+                  RR4       V#   \        \        \        3 d     Kñ  i ; i)	u  Opt the console behind stdout/stderr in to ANSI escape processing.

``hermes_cli.colors`` and the skins emit raw SGR codes whenever stdout is a TTY. A
conhost console (PowerShell 5.1, cmd.exe, the installer's ``hermes setup``) prints
them as ``â†�[35m`` until the output handle has ENABLE_VIRTUAL_TERMINAL_PROCESSING, and
shells hand native children a console with it off. The mode belongs to the console
buffer, so setting it here also covers the relaunched child. Handles that are not a
console (pipes, files, NUL, a windowless pythonw) fail GetConsoleMode and are left
alone. A console that refuses VT (pre-Windows 10) gets NO_COLOR instead, which
``should_use_color`` and rich honour, so it shows plain text rather than garbage.
Returns False only in that fallback case.
TN)ÚwintypesÚkernel32)Úuse_last_errorFÚNO_COLORr¹   )rÂ   ÚctypesÚmsvcrtrÊ   ÚWinDLLrŠ   r¿   rÀ   Úget_osfhandleÚfilenoÚAttributeErrorr;   rÅ   ÚDWORDÚGetConsoleModeÚbyrefÚvalueÚ#_ENABLE_VIRTUAL_TERMINAL_PROCESSINGÚSetConsoleModerA   rÄ   r   )	ÚstreamsrÎ   rÏ   rÊ   rË   ÚenabledÚstreamÚhandleÚmodes	   &        r
   Úenable_windows_vtrß     sÿ   € ÷ ‹;ÙÛÛÝà�}‰}˜Z¸ˆ}Ó=€HØ€GØ.5ªo”3—:‘:œsŸz™zÑ*À7ÒJˆð	Ø×)Ñ)¨&¯-©-«/Ó:ˆFð �~‰~ÓˆØ×&Ñ& v¯|©|¸DÓ/A×BÒBÙØ�:‰:Ô;×;Ô;ÙØ×&Ñ& v¯z©zÔ<_Õ/_×`Ô`ØŠGñ K÷ Ü
�
‰
×Ñ˜j¨#Ô.Ø€Nøô ¤¬Ð4ô 	Úð	ús   ÁD0Ä0E
Å	E
c               ó   € V ^8„  d   QhRR/# r(   r   )r	   s   "r
   r   r   )  s   € ÷ ñ  tñ r   c                 óŽ   € \         '       g   R#  ^ RIp \        V R4      '       d   RR lpWn        R# R#   \         d     R# i ; i)uë  Stub ``platform._syscmd_ver`` on Windows â€” decode-crash + console-flash guard.

``platform.win32_ver()`` (reached via ``platform.platform()``, which the OpenAI SDK
calls) shells out ``cmd /c ver`` with ``shell=True`` and no ``CREATE_NO_WINDOW``: a
windowless parent (pythonw gateway, slash/kanban workers) flashes a console per call,
and Python 3.11.0/3.11.1 (no ``encoding="locale"`` fix) strict-utf-8-decodes the OEM
code page output under PEP 540 mode and raises (#69413). Returning the inputs makes
``win32_ver()`` fall back to ``sys.getwindowsversion()`` â€” same data, no subprocess.
Mirrors ``hermes_cli._subprocess_compat.suppress_platform_ver_console`` for callers
that never import ``hermes_cli.main``; double application is harmless.
NÚ_syscmd_verc                ó
   € WV3# r+   r   )ÚsystemÚreleaseÚversionÚsupported_platformss   &&&&r
   Ú_quiet_syscmd_verÚ8suppress_platform_ver_console.<locals>._quiet_syscmd_ver;  s   € à¨Ð/Ð/r   )Ú rê   rê   )r   Úwin16Údos)rÂ   ÚplatformÚhasattrrâ   r-   )rí   rè   s     r
   Úsuppress_platform_ver_consolerï   )  sG   € ÷ ‹;Ùð
Ûä�8˜]×+Ò+ô0ð $5Ö ñ ,øô ô Úðús   �!5 µAÁAc               ó   € V ^8„  d   QhRR/# rµ   r   )r	   s   "r
   r   r   D  s   € ÷ 	ñ 	˜dñ 	r   c                 óÊ  € \         P                  P                  R4      '       g   R#  \        P                  ! R4      ;'       g    RP                  R4      w  rpV R8H  ;'       d\    \        ;QJ d*    . R VP                  R4      R	,           4       F  NK  	  5M#! R VP                  R4      R	,           4       4      R
8  #   \        \        \        \        3 d     R# i ; i)z¨True on glibc < 2.41, whose ``setenv`` of a NEW name reallocs the ``environ`` array
and frees the old one (2.41+ never frees it, so a concurrent ``getenv`` stays safe).ÚlinuxFÚCS_GNU_LIBC_VERSIONrê   Ú Úglibcc              3  ó8   "  € T F  p\        V4      x € K  	  R # 5ir+   )Úint)r   Úps   & r
   r   Ú'_glibc_frees_environ.<locals>.<genexpr>K  s   é € Ð(PÑ9O°A¬¨Q¯¨Ó9Oùs   ‚Ú.ºNr   N)r   é)   )rŠ   rí   Ú
startswithrA   ÚconfstrÚ	partitionr}   ÚsplitrÓ   r;   Ú	TypeErrorrÅ   )ÚlibcÚ_ræ   s      r
   Ú_glibc_frees_environr  D  s°   € ô �<‰<×"Ñ" 7×+Ò+ÙðÜŸJšJÐ'<Ó=×CÐCÀ×NÑNÈsÓSÑˆ�Ø�w‰×ZÐZ§5¤5Ñ(P¸¿¹ÀsÓ9KÈBÖ9OÓ(P§5¡5Ñ(P¸¿¹ÀsÓ9KÈBÖ9OÓ(PÓ#PÐSZÑ#ZÐZøÜœG¤Y´
Ð;ô Úðús$   ©C Á C Á'C Á3AC ÃC"Ã!C"c               ó   € V ^8„  d   QhRR/# r(   r   )r	   s   "r
   r   r   P  s   € ÷ _0ñ _0 Dñ _0r   c            	     óà  aaaaaa	a
aa€ \        \        P                  RR4      '       g   \        4       '       g   R# ^ RIp ^ RIo SP                  R4      pSP                  P                  VR4      oVP                  oSP                  SP                  .uSn        Sn        \        P                  \        P                   uooT P#                  4       o
\        P$                  ! S
P&                  S
P(                  S
P(                  R7       / o	. o^ .oR TTTTTT	T
T3R llpR TT
T3R	 llpR
Tn        R
Tn        Y#u\        n        \        n        R#   \        \        \        3 d     R# i ; i)a†  Make ``os.environ`` writes safe against native ``getenv`` in other threads.

On glibc < 2.41 adding a name reallocs ``environ`` and frees the old array while a
thread that dropped the GIL (``getaddrinfo``, OpenSSL's ``SSL_CERT_FILE`` lookup) may
still be walking it; the freed slots hold tcache pointers, so the walk segfaults the
whole process. Hermes writes new names at runtime from many places (``session.create``
turns on gateway prompts, the agent build sets ``HERMES_SESSION_ID``) while background
threads fetch catalogs, so the tui_gateway died with SIGSEGV. This is glibc 2.41's own
fix: entry strings are cached per ``NAME=value`` and never freed; a new name is
appended in place to an array with spare room, and only a full array is replaced by
a bigger one, the old one kept forever. Set/del churn of the same names therefore
allocates nothing after the first cycle.

Residual: a NEW-name ``setenv`` from native code (a C or Rust extension, not
``os.environ``) bypasses the lock and still reallocs glibc's own last array, so a
``getenv`` that started walking that array before our swap can still fault. None of
the gateway's crash paths do this.
Ú_hermes_never_free_environFNrÄ   )ÚbeforeÚafter_in_parentÚafter_in_childc               ó   € V ^8„  d   QhRR/# r(   r   )r	   s   "r
   r   Ú0install_never_free_environ.<locals>.__annotate__y  s   € ÷ -+ñ -+˜tñ -+r   c                óŒ  <€ \         P                  ! V 4      \         P                  ! V4      r2V'       d   R V9   g   RW#,           9   d   S! W4       R# \        P                  ! RW#4       VR ,           pS;_uu_ 4        SP	                  WC,           4      ;pf#   SP                  WC,           4      ;pSWC,           &   SP                  V4      p S^ ,          pS! V4      pV'       d   V\        V4      ,
          MRp	SP                  '       d6   SP                  SP                  SP                  SP                  4      4      MRp
^ RrËV
'       d%   W«,          ;p'       d   WÙ8X  d   RpMV^,          pK,  S'       d
   SR,          MRw  rïV'       * ;'       d>    VRJ;'       d-    SP                  V8H  ;'       d    V^,           \        V4      8*  '       * pV'       dh   SP                  \        ^V^,           ,          ^@4      ,          ! . V
'       d   V
RV MROVN5!  pSP                  VSP                  4      P                  pS^ ,          V8X  g   EK‡   S^ ;;,          ^,          uu&   T'       d   YjT&   M2T'       g   RYë^,           &   YnT&   MSP                  XX34       TSn        RRR4       R#   + '       g   i     R# ; i)	ó   =ó    Nz	os.putenvTFéÿÿÿÿ)NNr   )rA   ÚfsencoderŠ   Úauditr°   Úcreate_string_bufferÚ	addressofÚlenr×   ÚcastÚPOINTERÚc_void_prS   r   )rs   r×   ÚnameÚvalÚprefixÚlineÚentryÚstartÚfoundr•   ÚliveÚnÚhitÚcurrentÚownÚown_addrÚgrowÚfreshÚ
fresh_addrÚarraysrÎ   rÄ   ÚgenÚgetenvÚlinesÚlockÚreal_putenvs   &&                 €€€€€€€€r
   Ú_putenvÚ+install_never_free_environ.<locals>._putenvy  s&  ø€ Ü—K’K Ó$¤b§k¢k°%Ó&8ˆcß�t˜t”| u°µ
Ô':Ù˜Ô#ÙÜ�	Š	�+˜tÔ)Ø˜•ˆßŠTØŸ	™	 &¥,Ó/Ð/�Ò8Ø-3×-HÑ-HÈÍÓ-VÐV��u˜V�\Ñ*Ø×$Ñ$ TÓ*ˆEð Ø˜A��ñ ˜t›�ß05˜¤ V£Ö,¸4�ØV]×Vc×VcÐVc�v—{‘{ 7§=¡=°&·.±.ÀÇÁÓ2QÔRÐim�Ø˜E�3ß¨4­7Ð 2 Ö 2ØÔ(Ø"˜ØØ˜•F’Aß.4  r¦
¸,‘�Ø”w×lÐl¨°4¨×(kÐ(k¸G¿M¹MÈXÑ<U×(kÐ(kÐZ[Ð^_ÕZ_ÔcfÐgjÓckÑZkÔ#l�ßØ#Ÿ_™_¬s°1¸¸A½µ;ÀÓ/CÖCÐh×SWÀtÈBÈQÁxÐ]_ÐhÐbgÓh�EØ!'§¡¨U°F·O±OÓ!D×!JÑ!J�JØ�q•6˜U—?Øð ��F�a�K‹FßØ�Q’ßØ!�˜•E‘
Ø�A’à—‘˜u jÐ1Ô2Ø *�”÷M �T�TŠTúsQ   Á=A(J2Ã&%J2ÄAJ2Å+J2Å:J2ÆJ2Æ!J2Æ8"J2ÇA2J2ÉJ2É1J2É>*J2Ê2K	c               ó   € V ^8„  d   QhRR/# r(   r   )r	   s   "r
   r   r  ¨  s   € ÷ ñ ˜$ñ r   c                ó�   <€ S;_uu_ 4        S! V 4       S^ ;;,          ^,          uu&   RRR4       R#   + '       g   i     R# ; ir   r   )rs   r*  r-  Úreal_unsetenvs   &€€€r
   Ú	_unsetenvÚ-install_never_free_environ.<locals>._unsetenv¨  s)   ø€ ßŠTÙ˜#ÔØ��F�a�K‹F÷ �T�TŠTús	   Œ4´A	T)rY   rA   Úputenvr  Ú_threadrÎ   ÚCDLLr  Úin_dllr+  rÓ   r;   rÅ   Úc_char_pÚrestypeÚargtypesÚunsetenvÚRLockÚregister_at_forkÚacquirerå   r  )r7  r  r/  r4  r)  rÎ   rÄ   r*  r+  r,  r-  r.  r3  s       @@@@@@@@@r
   Úinstall_never_free_environrA  P  s  ÿø€ ô& Œr�y‰yÐ6¸×>Ò>ÔFZ×F\ÒF\ÙÛÛðØ�{‰{˜4Ó ˆØ—/‘/×(Ñ(¨¨yÓ9ˆØ—‘ˆð '-§o¡o¸¿¹Ð7HÐ#€F„N�F”OÜ!#§¡¬B¯K©KÐ€K�ð �=‰=‹?€Dä×Ò˜tŸ|™|¸T¿\¹\ÐZ^×ZfÑZfÕgØ')€EØ-/€FØˆ#€C÷-+÷ -+÷^ò ð
 *.€GÔ&Ø+/€IÔ(Ø$Ð„B„IŒrŽ{øôG œG¤ZÐ0ô Úðús   Á9E ÅE-Å,E-c               ó    € V ^8„  d   QhRRRR/# )r   Úsrc_rootz
str | Noner   r)   r   )r	   s   "r
   r   r   ²  s   € ÷ ñ  ð °tñ r   c                óš  € T ;'       gh    \         P                  P                  R4      ;'       gA    \         P                  P	                  \         P                  P                  \        4      4      p\        P                   Uu. uF  q"R9  g   K  VNK  	  up\        P                  R&   \         P                  P                  V4      p\        P                   Uu. uF+  p\         P                  P                  V4      V8w  g   K)  VNK-  	  up\        P                  R&   \        P                  P                  ^ V4       R# u upi u upi )aq  Stop a package in the current directory from shadowing Hermes modules.

Hermes ships top-level modules with common names (``utils``, ``proxy``, ``ui``); a
project with its own ``utils/`` launched from its directory would win the import.
The cwd reaches ``sys.path`` as ``""``/``"."`` (script/``-m`` launches) AND as an
absolute path (venv activation, PYTHONPATH), so both are handled: relative forms are
dropped and the Hermes root is *relocated* to the front, not merely inserted when
absent. ``src_root`` defaults to this module's directory (the repo root for every
shipped entry point), so no spawner env var is required.
ÚHERMES_PYTHON_SRC_ROOT:NNNN)rê   rú   )	rA   rÄ   r°   r”   ÚdirnameÚabspathÚ__file__rŠ   r±   )rC  Úrootrø   Úroot_abss   &   r
   Úharden_import_pathrK  ²  sÛ   € ð ÷ ð ”r—z‘z—~‘~Ð&>Ó?÷ ð Ä2Ç7Á7Ç?Á?Ü
�‰�‰œÓ!óD€Dô "ŸhšhÓ=™h˜°9Ñ*<—1�1™hÑ=„C‡H�HˆQ�Kä�w‰w�‰˜tÓ$€HÜ!ŸhšhÓI™h˜¬"¯'©'¯/©/¸!Ó*<ÀÑ*H—1�1™hÑI„C‡H�HˆQ�KÜ‡H�H‡O�O�A�tÖùò	 >ùò Js   ÂEÂEÃ&EÄEc               ó   € V ^8„  d   QhRR/# r(   r   )r	   s   "r
   r   r   È  s   € ÷ ñ  ñ r   c                 óF   €  ^ RI Hp  V ! 4        R#   \         d     R# i ; i)a¨  Point ``TMPDIR``/``TMP``/``TEMP`` at ``HERMES_HOME/cache/scratch`` unless the user set them.

System temp is tmpfs on most Linux hosts and containers; Hermes' browser profiles, PTY
probes and every ``tempfile`` default a child script makes would eat RAM there. Runs at
import so every entry point and every child they spawn inherits it; ``hermes_cli.main``
re-runs it after ``--profile`` re-homes the process. Never raises.
)Úexport_scratch_tmp_envN)Úhermes_constantsrN  r-   )Ú_exports    r
   rN  rN  È  s!   € ðÝFÙŽ	øÜô Úðús   ‚ ‘ Ÿ )ÚPathc               ó    € V ^8„  d   QhRRRR/# )r   Úargvz	list[str]r   ztuple[Path, list[str]] | Noner   )r	   s   "r
   r   r   ì  s   € ÷ 
2ñ 
2 yð 
2Ð5Rñ 
2r   c                óè   € V '       d   V ^ ,          R8w  d   R#  V P                  R^4      pT^,           \        T 4      8w  d   R# \        Y^,           ,          4      T ^T 3#   \         d     R# i ; i)zGRecognize the exact fresh-checkout command emitted by shipped updaters.ÚupdateNz--post-swap)ÚindexrÅ   r  rQ  )rS  Úmarkers   & r
   Ú_legacy_post_swap_invocationrX  ì  sn   € ç�4˜•7˜hÔ&ÙðØ—‘˜M¨1Ó-ˆð �…z”S˜“YÔÙÜ�˜a•ZÕ Ó! 4¨¨& >Ð1Ð1øô	 ô Úðús   šA" Á"A1Á0A1c               ó   € V ^8„  d   QhRR/# r(   r   )r	   s   "r
   r   r   ÿ  s   € ÷ *ñ * Dñ *r   c            	     óÄ  €  ^ RI Hp  T P                  \        4      '       d   T P                  4        R# R#   \         Ed�    \        R,          R,          p\        R,          P	                  4       '       d   TP	                  4       '       g    R# ^ RIpTP                  R4      p\        TP                  4      \        \        R,          4      .Tn	        T\        P                  R&    ^ RI Hp  T P                  \        4      '       d   T P                  4        \        P                   Uu. uF$  qDR8X  g   TP                  R4      '       g   K"  TNK&  	  Mu upi up F  p\        P                  T K  	  Mb  \        P                   Uu. uF$  qDR8X  g   TP                  R4      '       g   K"  TNK&  	  Mu upi up F  p\        P                  T K  	  i ; i R# i ; i)aë  Put back the tree a killed ``hermes update`` left half-moved, before PM, launch preparation or
any Hermes package imports from it (``hermes_cli._early_recovery``; ``hermes_cli.main`` repeats the
call for entries that never reach this module). A killed ZIP swap can leave ``hermes_cli/`` itself
moved aside: the journal-driven restore then runs from that moved-aside copy, the code that wrote
the journal. Root files are never absent mid-swap (``update_cmd_zip._commit_staged_replacements``).)Ú_early_recoveryzhermes_cli.hermes-update-oldz_early_recovery.pyz.hermes-update-zip-swapNÚ
hermes_clizhermes_cli.)r\  r[  ÚImportErrorÚ_rootÚis_fileÚtypesÚ
ModuleTypeÚstrÚparentÚ__path__rŠ   r¯   Úrestore_interrupted_pullÚrelaunch_after_restorerý   )ÚrecoveryÚmoved_asider`  Úpackager!  r  s         r
   Ú_settle_interrupted_updaterj  ÿ  s^  € ðÝ:ð, ×(Ñ(¬×/Ò/Ø×'Ñ'Ö)ñ 0øô+ õ ÜÐ<Õ<Ð?SÕSˆÜÐ1Õ1×:Ñ:×<Ò<ÀK×DWÑDW×DYÒDYÚÛð
 ×"Ñ" <Ó0ˆÜ × 2Ñ 2Ó3´S¼ÀÕ9MÓ5NÐOˆÔØ$+Œ�‰�LÑ!ð	&Ý>à×0Ñ0´×7Ò7Ø×/Ñ/Ô1ä$'§K¢KÓd¡K˜q¸Ô3DÈÏÉÐUb×HcŸ˜¢Kù×d�Ü—K‘K Ò%ò eø¤C§K¢KÓd¡K˜q¸Ô3DÈÏÉÐUb×HcŸ˜¢Kù×d�Ü—K‘K Ò%ò eúâð)úsY   ‚7 ·A GÁ8GÂAGÃ*1E9ÄGÄ-EÅEÅ"GÅ9GÆF7
Æ0F7
Æ6"GÇGÇGc               ó   € V ^8„  d   QhRR/# r(   r   )r	   s   "r
   r   r   #  s   € ÷ Cñ C˜Dñ Cr   c                 óÔ   € \        \        RR4      '       dQ   \        P                  P	                  R4      '       g*   ^ RIHp  \        V ! 4       4      \        P                  R&   R# R# R# )af  A minted launcher (``hermes_cli._launchers``) pins ``HERMES_HOME`` to the install's default
root. That needs ``hermes_constants`` from the checkout, so the launcher asks for it here, after
the repair above: a merge killed while writing ``hermes_constants.py`` must not keep the repair
from ever running. The flag name is ``_launchers.PIN_DEFAULT_HOME_FLAG``.Ú_hermes_pin_default_homeFÚHERMES_HOME©Úget_default_hermes_rootN)rY   rŠ   rA   rÄ   r°   rO  rp  rb  ro  s    r
   Ú_pin_launcher_homerq  #  sJ   € ô
 ŒsÐ.°×6Ò6¼r¿z¹z¿~¹~Èm×?\Ò?\Ý<ä$'Ñ(?Ó(AÓ$BŒ�
‰
�=Ó!ñ @]Ñ6r   :é   NN)Ú_continue_legacy_post_swap)Ú	argv_tailc                  ó   € ] tR tRtRtRtRtR# )ÚRelaunchExiti;  z±Exit carrying a relaunched child's status: that child already produced this run's output,
so callers that report their own boot failures (the Bot Chat delivery runner) must not.Tr   N)rž   rŸ   r    r¡   r¢   Ú
relaunchedr£   r   r   r
   rv  rv  ;  s   † ñ_à„Jr   rv  )Úactivate_dependenciesÚ install_state_permission_message)Úrecover_if_needed)Úcommand_argvrû   ÚpmÚrepair)Úprepare_launchÚrelaunch_commandÚ__main__Ú__spec__r  Úntzhermes: )Úfilez)hermes: source-update completion failed: uM   ; running with the previous dependencies â€” run `hermes update` to finish it:Nrr  Nz; run `hermes pm repair`)Nr   r+   )Vr¢   Ú
__future__r   r?   Úimportlib.abcr�   Úimportlib.utilrA   rD   r9   rŠ   rQ   rí   rÂ   rÃ   r[   r‰   r&   r0   rw   r…   ÚabcÚMetaPathFinderÚLoaderr‡   r³   rÇ   rØ   rß   rï   r  rA  rK  rN  ÚpathlibrQ  rH  Úresolverc  r^  ÚgetcwdÚFileNotFoundErrorÚchdirrX  rb  rj  rq  rS  Ú_legacy_post_swapÚhermes_cli.update_handoffrs  Ú_handoff_pathÚ
_argv_tailÚ
SystemExitrv  Úpm.environmentsrx  ry  Úhermes_cli._early_recoveryrz  Úhermes_cli._parserr{  Ú
_pm_repairÚhermes_cli.venv_syncr~  r  Ú_launch_pythonrY   r¯   r°   Ú
_main_specÚ	orig_argvÚ_commandr  Ú
subprocessÚcallÚexecvr-   rp   r¬   ÚPermissionErrorÚmessageÚprintrÀ   ÚRuntimeErrorr;   r   r   r
   Ú<module>r¤     s˜  ðñõ #ã Û Û Û 	Û Û Û 
Û à�l‰l˜gÑ%€ØÐ Ø $Ð Ø6Ð õõ÷[õ|.ô"1 	§¡× <Ñ <¸i¿m¹m×>RÑ>Rô 1õ6=õDð: '-Ð #÷#õLõ6	õ_0÷Dõ,ñ& Ô Ù Ô Ù Ô Ù Ô õ áˆX‹×ÑÓ ×'Ñ'€ðØ‡I‚I„Kõ
2ñ  ‘3�u“:Ô õ*ñB Ô õCñ Ô á0°·±¸"µÓ>Ð ØÒ õ Eà 1Ñ€M�:Ù
Ñ/°ÈÔTÓ
UÐUô�:ô ÷ TÝ 8å +ñ ˜#Ÿ(™( 2�,Ó'¨Õ+°°hÐ/?Ñ?€
ßßEðÙ'¨¨s¯x©x¸­|Ó<ˆØÒ%Ù  §¡§¡°Ó!<¸jÈ$ÓOˆJÙ'Ø  s§x¡x°·±Ù˜
 F¨DÓ1óˆHð �w‰w˜$ŒÛ!á" :§?¢?°8Ó#<Ó=Ð=Ø�HŠH‘S˜Ó(¨(Ô3ð	*Ù˜%Ô Ù˜eÔ$ñ &Ô 'Ù Ö øðQ ô ð ‡H‚HˆU‡Oðûðd ô 
Ù�c˜?×+Ò+Ñ<\Ð]bÐdgÓ<hÐ1h°Ö1hÙ�H˜W˜IÐ&¨S¯Z©ZÕ8Ù˜Q“- TÐ)ñ
 	Ð9¸#¸ð ?\ð \à—:‘:÷	ò 	ûð
ûð ˜'Ð"ô *Ù�c˜?×+Ò+Ñ<\Ð]bÐdgÓ<hÐ1h°Ö1hÙ�H˜W˜IÐ&¨S¯Z©ZÕ8Ù˜Q“- TÐ)Ù˜Ÿ™ �Ó% bÕ)¨d¨VÔ3Ù�H˜S˜EÐ!9Ð:ÀÇÁÕLÙ˜Q“- TÐ)õ 4ûð	*úsP   ÄJ! ÇB/K ÊL- Ê!J>Ê=J>ËL*ËL%Ë(8L%Ì%L*Ì-	OÌ6OÍA'OÏO