Ë
    ãß²j¨  ã                  ó>   — d Z ddlmZ dZdddœdd„Zdd„Zdd	œdd
„Zy)a  Head/tail truncation for oversized tool output (terminal, execute_code, MCP results).

One algorithm and one notice wording: 40% head (errors surface early) / 60% tail (the most
recent lines matter most) around a single ``... [<LABEL> TRUNCATED - N <unit> omitted out of
T total] ...`` marker, so downstream code that recognises the marker sees one shape. Limits
live in ``tools/tool_output_limits.py``; line-snapped, path-bearing footers (web/browser,
read_file pagination) are different products and stay separate.
é    )Úannotationsgš™™™™™Ù?ÚOUTPUTÚchars)ÚlabelÚunitc          	     ó$   — d|› d| d›d|› d|d›d�	S )Nz

... [z TRUNCATED - ú,Ú z omitted out of z total] ...

© )ÚomittedÚtotalr   r   s       ú?/home/ubuntu/.hermes/hermes-agent/tools/tool_output_truncate.pyÚtruncation_noticer      s*   € Ø�u�g˜]¨7°1¨+°Q°t°fÐ<LÈUÐSTÈIÐUdÐeÐeó    c                ó4   — t        | t        z  «      }|| |z
  fS )z8``(head, tail)`` character budgets for ``budget`` total.)ÚintÚ
HEAD_RATIO)ÚbudgetÚheads     r   Úhead_tail_splitr      s    € äˆvœ
Ñ"Ó#€DØ�˜$‘ÐÐr   ©r   c               ó¨   — t        | «      |k  r| S t        |«      \  }}t        | «      |z
  |z
  }| d| t        |t        | «      |¬«      z   | | d z   S )z™``text`` unchanged when it fits ``max_chars``; otherwise head + notice + tail (the kept
    text is exactly ``max_chars`` long, the notice rides on top).Nr   )Úlenr   r   )ÚtextÚ	max_charsr   r   Útailr   s         r   Útruncate_head_tailr      se   € ô ˆ4ƒy�IÒØˆÜ  Ó+�J€Dˆ$Ü�$‹i˜$Ñ Ñ%€GØ��ˆ;Ô*¨7´C¸³IÀUÔKÑKÈdÐTXÐSXÐSYÈlÑZÐZr   N)
r   r   r   r   r   Ústrr   r   Úreturnr   )r   r   r   ztuple[int, int])r   r   r   r   r   r   r   r   )Ú__doc__Ú
__future__r   r   r   r   r   r   r   r   ú<module>r"      s6   ðñõ #à€
ð AIÐV]õ fóð CKö [r   