§
    ‰eîiø  ã                   ón   — d Z ddlZ ej        dej        ¦  «        Z ej        d¦  «        Zdedefd„ZdS )uH  Strip ANSI escape sequences from subprocess output.

Used by terminal_tool, code_execution_tool, and process_registry to clean
command output before returning it to the model.  This prevents ANSI codes
from entering the model's context â€” which is the root cause of models
copying escape sequences into file writes.

Covers the full ECMA-48 spec: CSI (including private-mode ``?`` prefix,
colon-separated params, intermediate bytes), OSC (BEL and ST terminators),
DCS/SOS/PM/APC string sequences, nF multi-byte escapes, Fp/Fe/Fs
single-byte escapes, and 8-bit C1 control characters.
é    NzÒ\x1b(?:\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]|\][\s\S]*?(?:\x07|\x1b\\)|[PX^_][\s\S]*?(?:\x1b\\)|[\x20-\x2f]+[\x30-\x7e]|[\x30-\x7e])|\x9b[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]|\x9d[\s\S]*?(?:\x07|\x9c)|[\x80-\x9f]z[\x1b\x80-\x9f]ÚtextÚreturnc                 ót   — | rt                                | ¦  «        s| S t                               d| ¦  «        S )uÚ   Remove ANSI escape sequences from text.

    Returns the input unchanged (fast path) when no ESC or C1 bytes are
    present.  Safe to call on any string â€” clean text passes through
    with negligible overhead.
    Ú )Ú_HAS_ESCAPEÚsearchÚ_ANSI_ESCAPE_REÚsub)r   s    ú2/home/div/.hermes/hermes-agent/tools/ansi_strip.pyÚ
strip_ansir   #   s<   € ð ð •{×)Ò)¨$Ñ/Ô/ð ØˆÝ×Ò˜r 4Ñ(Ô(Ð(ó    )Ú__doc__ÚreÚcompileÚDOTALLr	   r   Ústrr   © r   r   ú<module>r      sy   ððð ð 
€	€	€	à�"”*ð
ð „Iñô €ð  ˆbŒjÐ+Ñ,Ô,€ð	)�Sð 	)˜Sð 	)ð 	)ð 	)ð 	)ð 	)ð 	)r   