+
    lHàj)	  ã                   óJ   € R t ^ RIt^ RIHt R	R R lltR	R R lltR R ltR# )
uz  Checkpoint-enablement resolution for TUI-created agents (issue #79625).

Desktop sessions (``hermes serve`` â†’ TUI gateway) never set ``HERMES_TUI_CHECKPOINTS``
(that env var is only set by the ``hermes --tui --checkpoints`` CLI path), so agent
creation previously gated filesystem checkpointing on the env var alone and silently
ignored ``checkpoints.enabled`` in config.yaml. These helpers resolve enablement the
way the messaging gateway does (``gateway/run.py`` ``_checkpoint_agent_kwargs``):
the env var (explicit CLI opt-in) wins when set, otherwise the ``checkpoints``
config section applies with ``DEFAULT_CONFIG`` defaults.
N)Úis_truthy_valuec                ó>   € V ^8„  d   QhR\         R,          R\        /# ©é   ÚcfgNÚreturn©ÚdictÚbool)Úformats   "Ú</home/ubuntu/.hermes/hermes-agent/tui_gateway/checkpoints.pyÚ__annotate__r      s"   € ÷ Qñ Q¤4¨$¥;ð Q¼$ñ Qó    c                óþ   € T ;'       g    / P                  R/ 4      p\        V\        4      '       d   RV/pM\        V\        4      '       g   / p^ RIHp \        VP                  RVR,          R,          4      4      # )z×Whether filesystem checkpoints are enabled for TUI-created agents.

Keeps the legacy ``checkpoints: true`` bool form working and falls back to the
``DEFAULT_CONFIG`` default when the section is absent or malformed.
ÚcheckpointsÚenabled)ÚDEFAULT_CONFIG)ÚgetÚ
isinstancer
   r	   Úhermes_cli.configr   )r   Úcp_cfgr   s   &  r   Ú_load_checkpoints_enabledr      sf   € ð �iˆi�R�_‰_˜]¨BÓ/€FÜ�&œ$×ÒØ˜VÐ$‰Ü˜¤×%Ò%ØˆÝ0Ü�—
‘
˜9 n°]Õ&CÀIÕ&NÓOÓPÐPr   c                ó>   € V ^8„  d   QhR\         R,          R\        /# r   r   )r   s   "r   r   r       s   € ÷ *ñ *¤T¨D¥[ð *¼Dñ *r   c                ót   € \         P                  P                  R4      pVe   \        V4      # \	        V 4      # )uP  Resolve checkpoint enablement with the env-var override first.

``HERMES_TUI_CHECKPOINTS`` (set by ``hermes --tui --checkpoints``) is the
explicit opt-in and wins when present; otherwise fall back to the
``checkpoints`` config section (issue #79625 â€” the desktop backend never
sets the env var, so config was being silently ignored).
ÚHERMES_TUI_CHECKPOINTS)ÚosÚenvironr   r   r   )r   Úenv_vals   & r   Úresolve_checkpoints_enabledr       s3   € ô �j‰j�n‰nÐ5Ó6€GØÒÜ˜wÓ'Ð'Ü$ SÓ)Ð)r   c                ó<   € V ^8„  d   QhR\         R\         R\         /# )r   ÚcwdÚrefr   )Ústr)r   s   "r   r   r   .   s&   € ÷ 	Nñ 	N¤sð 	N´ð 	N¼ñ 	Nr   c                ó  €  V P                  V4      p\        V4      ^,
          p^ Tu;8:  d   \        T4      8  d   M MY4,          P	                  RT4      # \        R\        T4       R24      h  \         d    Tu # i ; i)uS   ``/rollback N`` style number â†’ the checkpoint's hash; a real hash passes through.Úhashz!Invalid checkpoint number. Use 1-Ú.)Úlist_checkpointsÚintÚ
ValueErrorÚlenr   )Úmgrr    r!   r   Úidxs   &&&  r   Ú_resolve_checkpoint_hashr,   .   s   € ðØ×*Ñ*¨3Ó/ˆÜ�#‹h˜�lˆð 	ˆCÖ"”#�kÓ"×"ØÕ×#Ñ# F¨CÓ0Ð0Ü
Ð8¼¸[Ó9IÐ8JÈ!ÐLÓ
MÐMøô	 ô ØŠ
ðús   ‚#A0 Á0B Á?B )N)Ú__doc__r   Úutilsr   r   r   r,   © r   r   Ú<module>r0      s#   ðñ	ó 
å !÷Q÷*÷	Nr   