+
    „WÝjç  ã                  óÎ   € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	 ^ RI
Ht RtR R ltR R	 ltR
 R ltR R ltR R ltR R ltR R ltR R ltRR/R R lltR# )u£  Frozen compat surface for releases that finish `hermes update` via the post-swap hand-off.

Releases from 2026-09-16 (94ced1a2b2) lazily import ``hermes_cli.update_handoff``
from the NEW tree after the checkout swap. Like every other retired updater
hook, this module keeps that import working by routing into the historical
takeover (``hermes_cli._old_updater`` â†’ ``_update_takeover.py``) instead of
re-executing ``hermes update --post-swap``; the pulled tree is never imported
into the pre-pull interpreter.

Guarded by tests/compat/old_updater_surface.json â€” do not remove a public name
without regenerating the frozen surface and proving no shipped release loads it.
)ÚannotationsN)ÚPath)ÚAnyÚHERMES_UPDATE_POST_SWAPc               ó   € V ^8„  d   QhRR/# )é   ÚreturnÚbool© )Úformats   "ÚMC:\Users\johnn\AppData\Local\hermes\hermes-agent\hermes_cli\update_handoff.pyÚ__annotate__r      s   € ÷ 0ñ 0˜Dñ 0ó    c                 óN   € \         P                  P                  \        4      R 8H  # )Ú1)ÚosÚenvironÚgetÚPOST_SWAP_ENVr
   r   r   Úis_post_swap_childr      s   € Ü�:‰:�>‰>œ-Ó(¨CÑ/Ð/r   c               ó    € V ^8„  d   QhRRRR/# )r   Úpayloadúdict[str, Any]r   r   r
   )r   s   "r   r   r       s   € ÷ ñ ˜>ð ¨dñ r   c                óþ   € ^ RI Hp V! 4       R,          R,          pVP                  RRR7       VR\        P                  ! 4        R2,          pVP                  \        P                  ! V ^\        R7      R	R
7       V# )zTPersist the post-swap payload beside the receipts (the ROOT home); returns its path.)Úget_default_hermes_rootÚlogsÚupdate_receiptsT)ÚparentsÚexist_okÚ
post_swap_z.json)ÚindentÚdefaultzutf-8©Úencoding)	Úhermes_constantsr   Úmkdirr   ÚgetpidÚ
write_textÚjsonÚdumpsÚstr)r   r   Ú	directoryÚpaths   &   r   Úwrite_handoffr-       sc   € å8á'Ó)¨FÕ2Ð5FÕF€IØ‡O�O˜D¨4€OÔ0Ø˜¤B§I¢I£K =°Ð6Õ6€DØ‡O�O”D—J’J˜w¨q¼#Ô>È€OÔQØ€Kr   c               ó    € V ^8„  d   QhRRRR/# )r   r,   ú
str | Pathr   r   r
   )r   s   "r   r   r   +   s   € ÷ ñ �zð  nñ r   c                ó®   € \         P                  ! \        V 4      P                  R R7      4      p\	        V\
        4      '       g   \        RV  R24      hV# )z	utf-8-sigr"   zpost-swap hand-off z is not a JSON object)r(   Úloadsr   Ú	read_textÚ
isinstanceÚdictÚ
ValueError)r,   r   s   & r   Úread_handoffr6   +   sJ   € Ü�jŠjœ˜d›×-Ñ-°{Ð-ÓCÓD€GÜ�gœt×$Ò$ÜÐ.¨t¨fÐ4IÐJÓKÐKØ€Nr   c               ó   € V ^8„  d   QhRR/# )r   r   r   r
   )r   s   "r   r   r   2   s   € ÷  ñ  ˜$ñ  r   c                 ó‚  € \         P                  R8w  d   \        \         P                  4      # ^ RIHp  ^ RIHp ^ RIH	p V! \        \        4      P                  4       P                  ^,          4      pVe0   V ! 4       '       d#   V! VRR7      pVP                  4       '       d   V# \        \         P                  4      # )u  Interpreter for the child: the project venv's python when this process runs from (or
under) the project's Windows console shim â€” the shim can never be re-executed on Windows
because it holds itself open for the whole process lifetime (#88838, #89599) â€” else the
running interpreter.Úwin32)Ú_is_windows)Úproject_venv_dir)Úvenv_pythonT)Úwindows)ÚsysÚplatformr   Ú
executableÚhermes_cli._launchersr:   r$   r;   Úpm.environmentsr<   Ú__file__Úresolver   Úis_file)r:   r;   r<   Úvenv_dirÚ	candidates        r   Úpost_swap_pythonrH   2   s†   € ô
 ‡|�|�wÔÜ”C—N‘NÓ#Ð#Ý1Ý1Ý+á¤¤X£× 6Ñ 6Ó 8× @Ñ @ÀÕ CÓD€HØÒ¡§¢Ù °$Ô7ˆ	Ø×Ñ×ÒØÐÜ”—‘ÓÐr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úhandoff_pathr   Ú	argv_tailú	list[str]r   r
   )r   s   "r   r   r   E   s!   € ÷ .ñ . Dð .°Yð .À9ñ .r   c                óN   € \        \        4       4      RRR.VORN\        V 4      N# )a*  ``python -m hermes_cli.main update <original flags> --post-swap <file>``.

Historical command shape; kept so a printed manual-continuation line reads
exactly as older releases expect. The takeover child this tree actually
spawns (see :func:`continue_update_in_fresh_interpreter`) ignores the flag.
z-mzhermes_cli.mainÚupdatez--post-swap)r*   rH   )rJ   rK   s   &&r   Úpost_swap_commandrO   E   s=   € ô Ô Ó"Ó# TÐ+<¸hð .Èð .Øð.Ü˜|Ó,ð.ð .r   c               ó   € V ^8„  d   QhRR/# )r   r   zdict[str, str]r
   )r   s   "r   r   r   P   s   € ÷ ñ ˜^ñ r   c                 ó¦   € ^ RI Hp  / \        P                  C\        RRR/CpVP                  V \        \        P                  ! 4       4      4       V# )zðEnvironment for the child. ``HERMES_UPDATE_REEXEC`` marks it as already off the Windows
shim (no second re-exec at the sync boundary). The lock hand-off pid is only claimed when
nobody upstream (Tauri/Electron updater) already named theirs.)ÚHANDOFF_PID_ENVr   ÚHERMES_UPDATE_REEXEC)Úhermes_cli.update_lockrR   r   r   r   Ú
setdefaultr*   r&   )rR   Úenvs     r   Úpost_swap_child_envrW   P   s?   € õ 7à
IŒR�Z‰ZÐ
Iœ¨Ð-CÀSÑ
I€CØ‡N�N�?¤C¬¯	ª	«Ó$4Ô5Ø€Jr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   rK   úlist[str] | Noner   r
   )r   s   "r   r   r   [   s"   € ÷ ñ ˜~ð Ð:Jð È~ñ r   c           	     ó  € \        V 4      pVP                  R\        V P                  RR4      4      4       VP                  RV P                  R4      4       TP                  RRT;'       g    . 9   4       VP                  RR4       V# )	a¤  Map a historical post-swap payload onto the takeover request schema.

Payloads written before the takeover seam (e.g. release 0.21.3) name the
desktop flag and the Windows resume token differently and carry no
assume_yes at all; `update_finish.py` reads the new names with bare
subscriptions, so an unmapped payload KeyErrors mid-completion with the
checkout already swapped. New-schema payloads pass through unchanged.
ÚdesktopÚhad_desktop_app_before_updateFÚwindows_resumeÚwindows_gateway_resumeÚ
assume_yesz--yesÚrestart_update)r4   rU   r	   r   )r   rK   Úrequests   && r   Ú_takeover_requestrb   [   s{   € ô �7‹m€GØ×Ñ�y¤$ w§{¡{Ð3RÐTYÓ'ZÓ"[Ô\Ø×ÑÐ'¨¯©Ð5MÓ)NÔOØ×Ñ�| W°·°¸bÑ%AÔBØ×ÑÐ'¨Ô/Ø€Nr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rJ   r/   rK   rL   r   Úintr
   )r   s   "r   r   r   l   s"   € ÷ ñ ¨Zð Àyð ÐUXñ r   c               ó¶   € \        V 4      p \        V 4      P                  4        ^ RIHp V! \        W!4      4      w  rE\        V4      #   \         d     L1i ; i)aL  Complete the command shape shipped before PM owned source updates.

Those releases start the replacement checkout as ``hermes update <flags>
--post-swap FILE``. The replacement bootstrap calls this before importing
its PM or CLI graph, then the existing takeover child prepares and finishes
the update entirely on replacement code.
©Ú
_run_child)r6   r   ÚunlinkÚOSErrorÚhermes_cli._old_updaterrg   rb   rd   )rJ   rK   r   rg   ÚcodeÚ
_completeds   &$    r   Ú_continue_legacy_post_swaprm   l   sZ   € ô ˜<Ó(€GðÜˆ\Ó×!Ñ!Ô#õ 3á!Ô"3°GÓ"GÓHÑ€DÜˆt‹9Ðøô ô Ùðús   �A
 Á
AÁArK   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   rK   rY   r   z
int | Noner
   )r   s   "r   r   r      s#   € ÷ ñ °.ð ÐP`ð Ðlvñ r   c               óÎ  € ^ RI Hp \        V 4      p\        W4      p\	        Y1;'       g    . 4      p\        RV R24       \        P                  P                  4        \        P                  P                  4         V! V4      w  rg\        V4      #   \         dG   p\        RT 24       \        R4       \        R\        P                  ! T4       24        Rp?R# Rp?ii ; i)a  Run the post-swap tail in a child interpreter on the pulled code.

The old caller's payload carries the same fields the completion request
needs (receipt, plan, windows_resume, gateway_mode, ...); ``argv_tail`` is
accepted and ignored because the takeover tail does not re-parse update
flags. Returns the child's exit code, or ``None`` when no child could be
started (the caller then owns the failure bookkeeping). Ctrl-C semantics
mirror the historical hand-off: wait for the child's cleanup instead of
subprocess.run's kill-on-interrupt.
rf   uF   â†’ Post-swap hand-off: completing the update in a fresh interpreter (Ú)u3     âš  Could not start the post-update interpreter: z-  The code update is applied. Finish it with:z    N)rj   rg   r-   rb   rO   Úprintr>   ÚstdoutÚflushÚstderrrd   ri   Ú
subprocessÚlist2cmdline)	r   rK   rg   rJ   ra   Úcmdrk   rl   Úexcs	   &$       r   Ú$continue_update_in_fresh_interpreterry      sÃ   € õ 3ä  Ó)€LÜ Ó3€GÜ
˜L¯/¨/°rÓ
:€CÜ	ÐRÐS_ÐR`Ð`aÐ
bÔcÜ‡J�J×ÑÔÜ‡J�J×ÑÔðÙ% gÓ.ÑˆÜ�4‹yÐøÜô ÜÐCÀCÀ5ÐIÔJÜÐ=Ô>Ü�”Z×,Ò,¨SÓ1Ð2Ð3Ô4Ýûð	ús   Á>B ÂC$Â;CÃC$)Ú__doc__Ú
__future__r   r(   r   ru   r>   ÚtimeÚpathlibr   Útypingr   r   r   r-   r6   rH   rO   rW   rb   rm   ry   r
   r   r   Ú<module>r      se   ðñõ #ã Û 	Û Û 
Û Ý Ý ð *€õ0õõõ õ&.õõõ"ð&Ðcg÷ ñ r   