+
    jHàj  ã                   ó  € R t ^ RIt^ RIt^ RIt^ RIHt ]P                  ! R4      tRtR R lt	R R lt
R	 R
 ltR R ltR R ltR R ltR R ltR^´RRRR/R R lltR R ltRR&RRRR/R R lltR R!/R" R# lltR R!/R$ R% lltR# )'zòDashboard build freshness/serialization and checkout bytecode sweep.

Split out of ``hermes_cli/main.py``. Names that still live in main (``PROJECT_ROOT``, ...)
are imported lazily inside the functions that use them (avoids an import cycle).
N©ÚPathzhermes_cli.mainz.bytecode-fingerprintc                ó   € V ^8„  d   QhRR/# ©é   ÚreturnN© )Úformats   "Ú>/home/ubuntu/.hermes/hermes-agent/hermes_cli/main_web_build.pyÚ__annotate__r      s   € ÷ Gñ G dñ Gó    c                 ó@  € ^ RI Hp Hp  V! V 4      pV'       g   R# V \        ,          pVP	                  VP
                  R,           4      pVP                  VRR7       VP                  V4       R#   \         d"   p\        P                  RT4        Rp?R# Rp?ii ; i)zNPersist the current checkout fingerprint after a bytecode sweep. Never raises.)ÚPROJECT_ROOTÚ_read_git_revision_fingerprintNz.tmpzutf-8©Úencodingz)Could not record bytecode fingerprint: %s)Úhermes_cli.mainr   r   Ú_BYTECODE_FINGERPRINT_FILEÚ	with_nameÚnameÚ
write_textÚreplaceÚOSErrorÚloggerÚdebug)r   r   ÚfingerprintÚ
stamp_pathÚtmp_pathÚexcs         r
   Ú_record_bytecode_fingerprintr      s„   € çLð	GÙ4°\ÓBˆßÙØ!Ô$>Õ>ˆ
Ø×'Ñ'¨
¯©¸&Õ(@ÓAˆØ×Ñ˜K°'ÐÔ:Ø×Ñ˜Ö$øÜô GÜ�‰Ð@À#×FÒFûðGús   ŠA1 œAA1 Á1BÁ<BÂBc                ó   € V ^8„  d   QhRR/# r   r   )r	   s   "r
   r   r   %   s   € ÷ !Dñ !D°4ñ !Dr   c                 óº  € ^ RI Hp HpHp  V! V 4      pV'       g   R# V \        ,          p VP                  RR7      P                  4       pWS8X  d   R# V! V 4      pV'       d,   \        P                  RT;'       g    RY6V^8X  d   RMR	4       \        4        R#   \         d    Rp L^i ; i  \         d"   p\        P                  R
T4        Rp?R# Rp?ii ; i)aÁ  Clear ``__pycache__`` at launch when the checkout fingerprint changed since the last sweep.

Update-time clears can't close the stale-bytecode class: ``hermes update`` runs
the PRE-pull updater code and manual pulls never run it. Cheap file reads, no
git subprocess. Never raises.

The stale-bytecode bug class (issues #6207, #60242; Dhruv's WhatsApp ``cannot import name
'parse_model_flags_detailed'`` report) has one shared shape: the checkout's ``.py`` files change (git
pull inside ``hermes update``, a manual ``git pull``, a ZIP update, a file-sync restore) while
``__pycache__`` retains bytecode from the previous revision, and a later process trusts the stale
``.pyc`` instead of the fresh source.
)r   Ú_clear_bytecode_cacher   Nz	utf-8-sigr   Ú zVCheckout changed since last launch (%s -> %s): cleared %d stale __pycache__ director%sÚunknownÚyÚiesz&Stale-bytecode launch sweep failed: %s)r   r   r"   r   r   Ú	read_textÚstripr   r   Úinfor   Ú	Exceptionr   )r   r"   r   r   r   ÚrecordedÚremovedr   s           r
   Ú)_sweep_stale_bytecode_if_checkout_changedr-   %   sÏ   € ÷ dÑcðDÙ4°\ÓBˆßÙØ!Ô$>Õ>ˆ
ð	Ø!×+Ñ+°[Ð+ÓA×GÑGÓIˆHð Ô"ÙÙ'¨Ó5ˆßÜ�K‰KØhØ×%Ð%˜I {ÀGÈqÄL¹SÐV[ôô 	%Ö&øô ô 	ØŠHð	ûô ô DÜ�‰Ð=¸s×CÒCûðDúsQ   ŒB. žB. ¬ B ÁB. ÁB. Á$B. Á=B. ÂB+Â(B. Â*B+Â+B. Â.CÂ9CÃCc                ó0   € V ^8„  d   QhR\         R\         /# ©r   Úweb_dirr   r   )r	   s   "r
   r   r   I   s   € ÷ Vñ Vœtð V¬ñ Vr   c                ó|   € V P                   P                  R8X  d   V P                   P                   # V P                   # )z<Repo root for a frontend dir (``web/`` or ``apps/<name>/``).Úapps)Úparentr   ©r0   s   &r
   Ú_web_project_rootr5   I   s,   € à$+§N¡N×$7Ñ$7¸6Ô$Aˆ7�>‰>× Ñ ÐUÀwÇ~Á~ÐUr   c                ó0   € V ^8„  d   QhR\         R\         /# r/   r   )r	   s   "r
   r   r   N   s   € ÷ Bñ Bœ4ð B¤Dñ Br   c                ó4   € \        V 4      R,          R,          # )zTVite outputs to ``hermes_cli/web_dist/`` (vite.config.ts outDir), NOT ``web/dist/``.Ú
hermes_cliÚweb_dist)r5   r4   s   &r
   Ú_web_dist_dirr:   N   s   € ä˜WÓ%¨Õ4°zÕAÐAr   c                ó0   € V ^8„  d   QhR\         R\        /# r/   ©r   Úbool)r	   s   "r
   r   r   S   s   € ÷ añ a¤$ð a¬4ñ ar   c                 óP   € ^ RI Hp V! \        V 4      R\        V 4      4      '       * # )é    )Úsource_product_currentÚweb)Úhermes_cli.source_buildr@   r5   r:   )r0   r@   s   & r
   Ú_web_ui_build_neededrC   S   s#   € Ý>á%Ô&7¸Ó&@À%ÌÐW^ÓI_Ó`Ô`Ð`r   c                ó4   € V ^8„  d   QhR\         R\         RR/# )r   Úproject_rootr0   r   Nr   )r	   s   "r
   r   r   Y   s!   € ÷ ñ ¬Dð ¼4ð ÀDñ r   c                ó    € ^ RI Hp V! 4        R# )zKHistorical updater entrypoint; current builders publish their own receipts.©Ústop_for_relaunchN©Úhermes_cli._old_updaterrH   )rE   r0   rH   s   && r
   Ú_write_web_ui_build_stamprK   Y   ó   € å9ÙÖr   c                ó(   € V ^8„  d   QhR\         RR/# )r   Útextr   N)Ústr)r	   s   "r
   r   r   _   s   € ÷ Zñ Zœð Z ñ Zr   c                óæ   €  \        V 4       R#   \         dW    \        \        P                  RR4      ;'       g    Rp\        T P                  TRR7      P                  TRR7      4        R# i ; i)zVprint() that survives cp1252-style consoles (arrow/check glyphs) via errors="replace".r   NÚasciir   )Úerrors)ÚprintÚUnicodeEncodeErrorÚgetattrÚsysÚstdoutÚencodeÚdecode)rN   r   s   & r
   Ú_console_printrZ   _   s_   € ðZÜˆdŽøÜô ZÜœ3Ÿ:™: z°4Ó8×CÐC¸GˆÜˆd�k‰k˜(¨9ˆkÓ5×<Ñ<¸XÈiÐ<ÓX×YðZús   ‚ �,A0¼0A0Á/A0Úidle_timeout_secondsÚindentz    Úenvc                óº   € V ^8„  d   QhR\         \        ,          R\        R\        R\        R\        \        \        3,          R,          R\
        P                  /# )r   ÚcmdÚcwdr[   r\   r]   Nr   )ÚlistrO   r   ÚintÚdictÚ
subprocessÚCompletedProcess)r	   s   "r
   r   r   h   sS   € ÷ ñ Ü	Œc�ðÜðÜ8;ðÜKNðä	Œc”3ˆh�˜$Õ	ðä*4×*EÑ*Eñr   c               ó    € ^ RI Hp V! 4        R# ©z>Stop an old updater instead of running the retired build path.rG   NrI   )r_   r`   r[   r\   r]   rH   s   &&$$$ r
   Ú_run_with_idle_timeoutrh   h   ó   € õ :ÙÖr   c                óT   € V ^8„  d   QhR\         \        \        3,          R,          /# r   )rc   rO   )r	   s   "r
   r   r   p   s    € ÷ ñ œ$œs¤C˜x�.¨4Õ/ñ r   c                 ó    € ^ RI Hp  V ! 4        R# rg   rI   rG   s    r
   Ú_nixos_build_envrl   p   rL   r   Ú
extra_argsÚcapture_outputTc                ó¾   € V ^8„  d   QhR\         R\        R\        \         R3,          R\        R\        \         \         3,          R,          R\
        P                  /# )	r   Únpmr`   rm   .rn   r]   Nr   )rO   r   Útupler=   rc   rd   re   )r	   s   "r
   r   r   v   sW   € ÷ ñ Ü	ðÜðÜ(-¬c°3¨h­ðÜNRðä	Œc”3ˆh�˜$Õ	ðä*4×*EÑ*Eñr   c               ó    € ^ RI Hp V! 4        R# rg   rI   )rp   r`   rm   rn   r]   rH   s   &&$$$ r
   Ú_run_npm_install_deterministicrs   v   ri   r   ÚfatalFc                ó<   € V ^8„  d   QhR\         R\        R\        /# ©r   r0   rt   r   r<   )r	   s   "r
   r   r   ~   s!   € ÷ ñ œ4ð ¬4ð ¼Dñ r   c               ót  € ^ RI Hp V R,          P                  4       '       g   R#  \        V 4      R,          P	                  R4      ;_uu_ 4       pV! VP                  4       RR7       \        WR7      uuRRR4       #   + '       g   i     R# ; i  \         d   p\        R	T 24        Rp?R
# Rp?ii ; i)zOSerialize dashboard rebuilds, checking freshness only after acquiring the lock.)Ú_lockúpackage.jsonTz.web_ui_build.lockÚab)Úwait)rt   Nu'     âœ— Could not lock the web UI build: F)	Úhermes_cli.runtime_staterx   Úexistsr5   ÚopenÚfilenoÚ_do_build_web_uir   rZ   )r0   rt   rx   Ú	lock_filer   s   &$   r
   Ú_build_web_uir‚   ~   sŽ   € å.à�nÕ$×,Ñ,×.Ò.ÙðÜ Ó(Ð+?Õ?×EÑEÀd×KÔKÈyÙ�)×"Ñ"Ó$¨4Õ0Ü# GÔ9÷ L×K×KÓKûô ô ÜÐ@ÀÀÐFÔGÝûðús5   §)B Á$A?Á4
B Á?B	Â
B ÂB ÂB7ÂB2Â2B7c                ó<   € V ^8„  d   QhR\         R\        R\        /# rv   r<   )r	   s   "r
   r   r   �   s!   € ÷ ñ œdð ¬dð ¼tñ r   c               ó‚  € ^ RI HpHpHp V R,          P	                  4       '       d   \        V 4      '       g   R# \        V 4      p\        R4        V! 4       pV! WVR7       V! WVR7       \        R4       R#   \        \        P                  \        3 d'   p\        RT'       d   RMR R	T 24        R
p?R# R
p?ii ; i)zKBuild stale dashboard sources; failure is never reported as a usable build.)Úbuild_source_webÚprepare_launch_dependenciesÚsource_build_envry   Tu   â†’ Building web UI...)r]   z  u   âœ—u   âš z Web UI build failed: NFu     âœ“ Web UI built)rB   r…   r†   r‡   r}   rC   r5   rZ   r   rd   ÚSubprocessErrorÚRuntimeError)r0   rt   r…   r†   r‡   rE   r]   r   s   &$      r
   r€   r€   �   s¥   € çgÑgà�nÕ$×,Ñ,×.Ò.Ô6JÈ7×6SÒ6SÙÜ$ WÓ-€LÜÐ+Ô,ðÙÓ ˆÙ# LÕ:Ù˜Õ/ô Ð'Ô(Ùøô	 ”Z×/Ñ/´Ð>ô Ü˜§U™E°Ð6Ð6LÈSÈEÐRÔSÝûðús   ÁA8 Á8 B>ÂB9Â9B>r   )Ú__doc__Úloggingrd   rV   Úpathlibr   Ú	getLoggerr   r   r   r-   r5   r:   rC   rK   rZ   rh   rl   rs   r‚   r€   r   r   r
   Ú<module>rŽ      s¹   ðñó Û Û 
å ð 
×	Ò	Ð,Ó	-€ð
 5Ð õGõ!DõHVõ
Bõ
aõõZðØ>AðØQWðà!%÷õðØ:<ðØUYðà!%÷ð°%÷ ð°U÷ ñ r   