+
    lHàjõ  ã                   ó$  € R t ^ RIt]P                  ! R]P                  4      t]P                  ! R4      t]P                  ! R4      t]P                  ! R4      t]P                  ! R4      t]P                  ! R4      t	R R	 lt
R
 R ltR R ltR# )zåStrip ANSI escape sequences from subprocess output so they never reach the
model's context (models otherwise copy them into file writes). Covers full
ECMA-48: CSI, OSC (BEL/ST), DCS/SOS/PM/APC, nF, Fp/Fe/Fs and 8-bit C1 controls.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]z[\x00-\x08\x0b-\x1f\x7f-\x9f]z[\U000E0000-\U000E007F]z [\x00-\x08\x0b\x0c\x0e-\x1f\x7f]zF(\U0001F3F4[\U000E0020-\U000E007E]+\U000E007F)|[\U000E0000-\U000E007F]c                ó0   € V ^8„  d   QhR\         R\         /# ©é   ÚtextÚreturn©Ústr)Úformats   "Ú5/home/ubuntu/.hermes/hermes-agent/tools/ansi_strip.pyÚ__annotate__r   .   s   € ÷ )ñ )”Sð )œSñ )ó    c                óx   € V '       d   \         P                  V 4      '       g   V # \        P                  RV 4      # )zNRemove ANSI escape sequences; clean text passes through unchanged (fast path).Ú )Ú_HAS_ESCAPEÚsearchÚ_ANSI_ESCAPE_REÚsub©r   s   &r
   Ú
strip_ansir   .   s-   € ç”{×)Ñ)¨$×/Ò/ØˆÜ×Ñ˜r 4Ó(Ð(r   c                ó0   € V ^8„  d   QhR\         R\         /# r   r   )r	   s   "r
   r   r   5   s   € ÷ +ñ +¤ð +¬ñ +r   c                óà   € V '       d   \         P                  V 4      '       g   V # \        V 4      p RV 9   d#   V P                  RR4      P                  RR4      p \        P                  RV 4      # )u  Sanitize stored/untrusted text before echoing it to a terminal: strips ANSI
sequences AND bare control chars, keeping only newlines/tabs (CRs become newlines
so ``\r``-overwrite spoofing can't hide content). Rich's ``Text()`` does NOT
neutralize raw escape bytes, so a replayed ``/resume`` message must not be able
to clear the screen, retitle the window, or restyle UI.

Use this when re-rendering conversation history or other persisted text in a terminal UI (e.g. the
``/resume`` recap): a message that arrived with embedded escapes â€” pasted content, gateway-origin text,
or model output echoing injected tool results â€” must not be able to clear the screen, retitle the
window, move the cursor, or restyle adjacent UI when replayed. Mirrors openai/codex#31494
(``sanitize_user_text``).
Úz
Ú
r   )Ú_HAS_CONTROLr   r   ÚreplaceÚ_CONTROL_CHARS_REr   r   s   &r
   Úsanitize_display_textr   5   s]   € ÷ ”|×*Ñ*¨4×0Ò0ØˆÜ�dÓ€DØˆt„|Ø�|‰|˜F DÓ)×1Ñ1°$¸Ó=ˆÜ× Ñ   TÓ*Ð*r   c                ó0   € V ^8„  d   QhR\         R\         /# r   r   )r	   s   "r
   r   r   J   s   € ÷ 	Eñ 	EœSð 	E¤Sñ 	Er   c                óz   € V '       d   \         P                  V 4      '       g   V # \        P                  R V 4      # )a  Remove invisible Unicode TAG chars (a prompt-injection smuggling channel in
untrusted tool output); valid emoji tag sequences are preserved.

Returns the input unchanged (fast path) when no plane-14 tag characters are present. Ported from
block/goose#10746.
c                 ó8   € V P                  ^4      ;'       g    R# )é   r   )Úgroup)Úms   &r
   Ú<lambda>Ú$strip_unicode_tags.<locals>.<lambda>S   s   € ¨Q¯W©W°Q«Z×-=Ð-=¸2Ð-=r   )Ú_HAS_UNICODE_TAGr   Ú_UNICODE_TAG_SUB_REr   r   s   &r
   Ústrip_unicode_tagsr'   J   s1   € ÷ Ô'×.Ñ.¨t×4Ò4ØˆÜ×"Ñ"Ñ#=¸tÓDÐDr   )Ú__doc__ÚreÚcompileÚDOTALLr   r   r   r%   r   r&   r   r   r'   © r   r
   Ú<module>r-      s”   ðñSó 
à—*’*ð
ð ‡I�Ió€ð �jŠjÐ+Ó,€Ø�zŠzÐ:Ó;€Ø—:’:Ð8Ó9Ð ð —J’JÐBÓCÐ ð —j’jð óÐ õ)õ+÷*	Er   