Ë
    ãß²j–
  ã                  ó„   — U d Z ddlmZ ddlmZmZ ddlmZ dZdZ	dZ
i Zded<   dd	„Zdd
„Zdd„Zdd„Zdd„Zdd„Zdd„Zy)a‡  Configurable tool-output truncation limits (``tool_output`` in config.yaml):
``max_bytes`` (terminal output cap), ``max_lines`` (read_file pagination cap),
``max_line_length`` (per-line cap before '... [truncated]'). Defaults equal the
constants once hardcoded in terminal_tool / file_operations and the reader never
raises, so behaviour is unchanged when the section is absent or malformed.é    )Úannotations)ÚAnyÚDict)Úhermes_home_keyiPÃ  iÐ  zDict[str, Dict[str, int]]Ú_cached_limitsc                óZ   — 	 t        | «      }||k  r|S |S # t        t        f$ r |cY S w xY w)zGReturn ``value`` as an int >= ``minimum``, or ``default`` on any issue.)ÚintÚ	TypeErrorÚ
ValueError)ÚvalueÚdefaultÚminimumÚivs       ú=/home/ubuntu/.hermes/hermes-agent/tools/tool_output_limits.pyÚ_coerce_intr      s>   € ðÜ�‹Zˆð ˜7’lˆ7Ð*¨Ð*øô ”zÐ"ò ØŠðús   ‚ –*©*c                ó   — t        | |d«      S )Né   )r   )r   r   s     r   Ú_coerce_positive_intr      s   € Ü�u˜g qÓ)Ð)ó    c                 óÈ  — t        «       } t        j                  | «      }|�|S 	 ddlm}  |«       xs i }t        |t        «      r|j                  d«      nd}t        |t        «      si }t        |j                  d«      t        «      t        |j                  d«      t        «      t        |j                  d«      t        «      dœxt        | <   }|S # t        $ r d}Y Œ‡w xY w)	u®   Resolved ``{max_bytes, max_lines, max_line_length}``; never raises. Cached per profile
    home for the process â€” ``_reset_tool_output_limits_cache()`` forces a fresh read.Nr   )Úload_configÚtool_outputÚ	max_bytesÚ	max_linesÚmax_line_length)r   r   r   )r   r   ÚgetÚhermes_cli.configr   Ú
isinstanceÚdictÚ	Exceptionr   ÚDEFAULT_MAX_BYTESÚDEFAULT_MAX_LINESÚDEFAULT_MAX_LINE_LENGTH)ÚkeyÚcachedr   ÚcfgÚsectionÚlimitss         r   Úget_tool_output_limitsr)   "   sØ   € ô Ó
€CÜ×Ñ Ó$€FØÐØˆðÝ1Ù‹mÒ!˜rˆÜ,6°s¼DÔ,A�#—'‘'˜-Ô(Àtˆô �gœtÔ$Øˆä)¨'¯+©+°kÓ*BÔDUÓVÜ)¨'¯+©+°kÓ*BÔDUÓVÜ/Ø�K‰KÐ)Ó*Ô,CóEñ$Fð F„N�3Ñ˜&ð
 €Møô ò ØŠðús   ¥4C ÃC!Ã C!c                 ó,   — t         j                  «        y)uA   Reset the cached limits â€” for tests or after config hot-reload.N)r   Úclear© r   r   Ú_reset_tool_output_limits_cacher-   9   s   € ä×ÑÕr   c                 ó   — t        «       d   S )Nr   ©r)   r,   r   r   Úget_max_bytesr0   >   ó   € Ô#9Ó#;¸KÑ#HÐHr   c                 ó   — t        «       d   S )Nr   r/   r,   r   r   Úget_max_linesr3   ?   r1   r   c                 ó   — t        «       d   S )Nr   r/   r,   r   r   Úget_max_line_lengthr5   @   s   € Ô)?Ó)AÐBSÑ)TÐ"Tr   N)r   r   r   r	   r   r	   Úreturnr	   )r   r   r   r	   r6   r	   )r6   zDict[str, int])r6   ÚNone)r6   r	   )Ú__doc__Ú
__future__r   Útypingr   r   Úhermes_constantsr   r!   r"   r#   r   Ú__annotations__r   r   r)   r-   r0   r3   r5   r,   r   r   ú<module>r=      sU   ðòNõ #ç å ,àÐ ØÐ ØÐ ð -/€Ð)Ó .ó+ó*óó.ó
 IÛ HÜ Tr   