+
    lHàj  ã                  óÎ   € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	H
t
Ht ^ RIHtHt ]P                  ! ]4      tRtRtRtRtR	 R
 ltR R ltRRRRRR/R R llt. ROtR# )a   Spill oversized hook-injected context to disk with a preview placeholder.

Hook ``{"context": ...}`` output rides EVERY subsequent API call, so a large blob
inflates every turn and breaks the prompt-cache prefix. Above
``hooks.output_spill.max_chars`` (default 10000) the text is written under
``hooks.output_spill.directory`` (default ``<HERMES_HOME>/hook_outputs/<session>``)
and the payload becomes a ``preview_head``/``preview_tail`` excerpt plus the path.
``enabled: false`` disables. Never raises: an I/O failure still returns a preview.
)ÚannotationsN)ÚPath)ÚAnyÚDictÚOptional)Ú_coerce_intÚ_coerce_positive_inti'  iô  Tc               ó   € V ^8„  d   QhRR/# )é   Úreturnzdict[str, Any]© )Úformats   "Ú</home/ubuntu/.hermes/hermes-agent/tools/hook_output_spill.pyÚ__annotate__r      s   € ÷ ñ ˜.ñ ó    c                 ó¦  € / p  ^ RI Hp V! 4       ;'       g    / p\        V\        4      '       d   VP	                  R4      MRp\        V\        4      '       d/   \        VP	                  R4      \        4      '       d
   VR,          p T P	                  R\        4      pT P	                  R4      pRTe   \        T4      M\        R\        T P	                  R4      \        4      R\        T P	                  R4      \        ^ 4      R	\        T P	                  R	4      \        ^ 4      R\        T\        4      '       d   T/# R/#   \
         d    / p  LÇi ; i)
z7Return resolved hook output-spill config. Never raises.)Úload_configÚhooksNÚoutput_spillÚenabledÚ	directoryÚ	max_charsÚpreview_headÚpreview_tail)Úhermes_cli.configr   Ú
isinstanceÚdictÚgetÚ	ExceptionÚDEFAULT_ENABLEDÚboolr   ÚDEFAULT_MAX_CHARSr   ÚDEFAULT_PREVIEW_HEADÚDEFAULT_PREVIEW_TAILÚstr)Úsectionr   Úcfgr   Úenabled_rawr   s         r   Úget_spill_configr(      s"  € à €GðÝ1Ù‹m×!Ð!˜rˆÜ$.¨s´D×$9Ò$9�—‘˜Ô ¸tˆÜ�eœT×"Ò"¤z°%·)±)¸NÓ2KÌT×'RÒ'RØ˜NÕ+ˆGð —+‘+˜i¬Ó9€KØ—‘˜KÓ(€Ià¨Ò(?”4˜Ô$Ä_ØÔ)¨'¯+©+°kÓ*BÔDUÓVàœ G§K¡K°Ó$?ÔAUÐWXÓYØœ G§K¡K°Ó$?ÔAUÐWXÓYØ¤*¨Y¼×"<Ò"<�Yðð ð CGðð øô	 ô ØŠðús   „E  ˜A0E  Å EÅEc               ó$   € V ^8„  d   QhRRRRRR/# )r
   Údirectory_overrideúOptional[str]Ú
session_idr   r   r   )r   s   "r   r   r   5   s"   € ÷ "ñ "¨=ð "Àmð "ÐX\ñ "r   c                ó&  € V '       d*   \        \        P                  P                  V 4      4      pM^ RIHp \        V! 4       4      R,          pT;'       g    RP                  RR4      P                  RR4      P                  RR4      pW$,          # )zQPer-session spill directory; session id is sanitised so it can't escape ``base``.)Úget_hermes_homeÚhook_outputsz
no-sessionÚ/Ú_Ú\z..)r   ÚosÚpathÚ
expanduserÚhermes_constantsr.   Úreplace)r*   r,   Úbaser.   Úsession_segments   &&   r   Ú_resolve_spill_dirr:   5   st   € çÜ”B—G‘G×&Ñ&Ð'9Ó:Ó;‰å4Ü‘OÓ%Ó&¨Õ7ˆØ!×1Ð1 \×:Ñ:¸3ÀÓD×LÑLÈTÐSVÓW×_Ñ_Ð`dÐfiÓj€OØÕ!Ð!r   r,   ÚsourceÚhookÚconfigc          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r
   Útextr$   r,   r+   r;   r=   zOptional[dict[str, Any]]r   r   )r   s   "r   r   r   @   s4   € ÷ 1ñ 1Ø
ð1Ø+ð1Ø<?ð1ØRjð1àñ1r   c               óP  € V f   R# \        V \        4      '       g    \        V 4      p Ve   TM	\        4       pVP	                  RR4      '       g   V # \        V 4      \        VP	                  R4      ;'       g    \        4      8:  d   V # \        VP	                  R4      ;'       g    ^ 4      p\        VP	                  R4      ;'       g    ^ 4      pRp \        VP	                  R4      V4      p^ R	I	H
p	Hp
 V	! VRR
7       V\        P                  ! 4       P                   R2,          pT
! Y°P                  R4      '       d   T MV R,           RR
7       \        V4      p\        V 4      pRV RVR R2V'       d   RV R2MR,           .pV^ 8”  d"   V RV '       d   VP%                  RV RV .4       V^ 8”  d   WÕ8”  d   VP%                  RW) R .4       RP'                  V4      #   \         d     R# i ; i  \         d!   p\         P#                  RT4        Rp?L¿Rp?ii ; i)a  Spill ``text`` to disk if it exceeds the configured cap.

Returns ``text`` unchanged (under cap, disabled, or empty) or a preview
string pointing at the full content. Non-string input is ``str()``-coerced;
``source`` labels the preview header; ``config`` overrides config.yaml.
NÚ r   Tr   r   r   r   )Úensure_spill_dirÚwrite_text_exclusive)Úprivatez.txtÚ
zhook output spill failed: %sÚ[u    output truncated â€” Ú,z chars; full content z	saved to Ú]u#   unavailable â€” spill write failed]z--- head ---z--- tail ---)r   r$   r   r(   r   ÚlenÚintr!   r:   Útools.spill_safetyrB   rC   ÚuuidÚuuid4ÚhexÚendswithÚloggerÚwarningÚextendÚjoin)r?   r,   r;   r=   r&   ÚheadÚtailÚ
saved_pathÚ	spill_dirrB   rC   Ú
spill_pathÚexcÚtotalÚpartss   &$$$           r   Úspill_if_oversizedr\   @   sô  € ð ‚|ÙÜ�dœC× Ò ð	Ü�t“9ˆDð Ò&‰&Ô,<Ó,>€CØ�7‰7�9˜d×#Ò#ØˆÜ
ˆ4ƒy”C˜Ÿ™ Ó,×AÐAÔ0AÓBÔBØˆÜˆs�w‰w�~Ó&×+Ð+¨!Ó,€DÜˆs�w‰w�~Ó&×+Ð+¨!Ó,€Dð !%€Jð<Ü& s§w¡w¨{Ó';¸ZÓHˆ	ßMñ 	˜¨DÕ1Ø¤D§J¢J£L×$4Ñ$4Ð#5°TÐ!:Õ:ˆ
á˜Z·±¸t×1DÒ1D©È$ÐQUÍ+Ð_cÕdÜ˜“_ˆ
ô �‹I€Eà
ˆFˆ8Ð)¨%°¨Ð2GÐHß(2ˆY�z�l !Ñ$Ð8]õ	_ð€Eð ˆa„x�D˜˜$—KØ�‰�n d¨5¨D kÐ2Ô3Øˆa„x�E”LØ�‰�n d¨5¨6 lÐ3Ô4Ø�9‰9�UÓÐøôG ô 	Úð	ûô. ô <Ü�‰Ð5°s×;Ñ;ûð<ús*   žG( ÃBG: Ç(G7Ç6G7Ç:H%ÈH È H%)r   r!   r"   r#   r(   r\   )Ú__doc__Ú
__future__r   Úloggingr3   rL   Úpathlibr   Útypingr   r   r   Útools.tool_output_limitsr   r   Ú	getLoggerÚ__name__rP   r!   r"   r#   r   r(   r:   r\   Ú__all__r   r   r   Ú<module>rf      s|   ðñõ #ã Û 	Û Ý ß &Ñ &ç Fà	×	Ò	˜8Ó	$€ð Ð ØÐ ØÐ Ø€õõ."ð1Ø.2ð1ØBHð1Ømq÷1òh‚r   