+
    lHàjñ%  ã                  ó¬   € R t ^ RIHt ^ RIt]P                  ! R]P
                  4      tR R ltR R ltR R	 lt	R
 R lt
R R ltR R ltR R ltR# )a¬  Conservative heredoc masking for shell-command scanners ('&' guard, blocked-command checks,
cron lifecycle_guard) that false-positive on heredoc *bodies*. Stripping every body is unsafe the
other way (a fake ``<<`` in quotes can swallow an operator; unquoted bodies expand; ``bash <<'EOF'``
executes), so a body is masked ONLY when every delimiter is quoted, every heredoc has an exact
terminator line, the owning simple command is an allowlisted non-shell interpreter, and no list
operator follows the heredoc. Otherwise the command is returned untouched: a false positive is
acceptable, hiding shell syntax from a guard is not.
Masked bodies keep their newline count (re.MULTILINE).)ÚannotationsNzq^\s*(?:[A-Z_][A-Z0-9_]*=\S+\s+)*(?:env\s+)?(?:[A-Za-z0-9_./-]+/)?(?:python(?:3(?:\.\d+)*)?|osascript|cat)(?=\s|$)c               ó(   € V ^8„  d   QhRRRRRRRR/# )é   ÚcommandÚstrÚcursorÚintÚcloserÚreturn© )Úformats   "Ú8/home/ubuntu/.hermes/hermes-agent/tools/shell_heredoc.pyÚ__annotate__r      s(   € ÷ ñ �sð  Cð °ð ¸ñ ó    c                óÆ   € V^,           pV\        V 4      8  dH   W,          V8X  d
   V^,           # Y0V,          R8X  d   V^,           \        V 4      8  d   ^M^,          pKW  V# )z>Index just past the backslash-aware span opened at ``cursor``.Ú\©Úlen)r   r   r	   Úends   &&& r   Ú	_span_endr      sS   € à
�1�*€CØ
”�G“Ô
Ø�<˜6Ô!Ø˜•7ˆNØ˜C•L DÔ(¨S°1­W´s¸7³|Ô-C‰qÈÕJŠØ€Jr   c               ó    € V ^8„  d   QhRRRR/# ©r   r   r   r
   r   )r   s   "r   r   r       s   € ÷ ñ  ð ¨ñ r   c                óF  € . p^ pV\        V 4      8  dþ   W,          pVR9   d¨   VR8X  d!   V P                  RV^,           4      ^,           M\        WR4      pWV pVP                  V4      '       g   VP	                  WR 4       MŒVR8H  ;'       d    RV9   ;'       g    RV9   pTP	                  V'       d   TMV^,          4       TpKÆ  VR8X  d$   \        WR4      pVP	                  WV 4       TpKð  VP	                  V4       V^,          pEK  RP                  V4      # )zDBlank inert quoted spans; keep ``$(``/backtick-bearing ones visible.ú'"Ú'Ú"Nú$(Ú`Ú )r   Úfindr   ÚendswithÚappendÚjoin)r   Úresultr   Úcharr   ÚsegmentÚkeeps   &      r   Ú_mask_simple_quotesr'       s  € à€FØ€FØ
”3�w“<Ô
Ø�ˆØ�5Œ=Ø8<À¼�7—<‘<  V¨a¥ZÓ0°1Ö4Ü! '°3Ó7ð à SÐ)ˆGØ×#Ñ# D×)Ò)Ø—‘˜g gÐ.Ô/ØØ˜3‘;×FÐF D¨G¡O×$EÐ$E°s¸g±~ˆDØ�M‰M§T™'¨t°a­xÔ8ØŠFØ�SŒ[Ü˜G¨SÓ1ˆCØ�M‰M˜'¨Ð-Ô.ØŠFà�M‰M˜$ÔØ�a�K‹FØ�7‰7�6‹?Ðr   c               ó    € V ^8„  d   QhRRRR/# )r   r   r   Úindexr   r   )r   s   "r   r   r   :   s   € ÷ +:ñ +: Sð +:°ñ +:r   c                óº  € V P                  RV4      '       d   V P                  RV4      '       d   R# V P                  RV^,           4      pV'       d
   V^,           MV^,           pV\        V 4      8  d   W,          R9   d   V^,          pK(  V\        V 4      8¼  g   W,          R9   d   R# . pRpV\        V 4      8  Edv   W,          P                  4       '       EgY   W,          R9   EgK   W,          pVR	8X  dY   V^,           \        V 4      8¼  g   W^,           ,          R9   d   R# R
pVP                  W^,           ,          4       V^,          pK£  VR9   dÀ   R
pV^,          pV\        V 4      8  d‡   W,          V8w  dz   W,          pVR9   d   R# VR8X  dF   VR	8X  d?   V^,           \        V 4      8¼  d   R# W^,           ,          R9   d   V^,          pW,          pVP                  V4       V^,          pK–  V\        V 4      8¼  d   R# V^,          pEKi  VP                  V4       V^,          pEK†  V'       g   V'       g   R# VRP	                  V4      W%3# )zRParse one ``<<`` opener -> ``(end_index, delimiter, strip_tabs, quoted)`` or None.ú<<ú<<<NÚ-z 	z
Fz;&|<>()r   Tr   r   z$`"\
r   )Ú
startswithr   Úisspacer!   r"   )r   r)   Ú
strip_tabsr   Ú	delimiterÚquotedr$   Úcurrents   &&      r   Ú_parse_heredoc_operatorr4   :   sè  € à×Ñ˜d E×*Ò*¨g×.@Ñ.@ÀÈ×.NÒ.NÙØ×#Ñ# C¨°­Ó3€Jß$ˆU�QŽY¨%°!­)€FØ
”3�w“<Ô
 G¥O°uÔ$<Ø�!�ŠØ”�W“Ô ¥°FÔ!:ÙØ€IØ€FØ
”3�w“<Õ
¨­×)@Ñ)@×)BÓ)BÀgÅoÐYbÕFbØ�ˆØ�4Œ<Ø˜�zœS ›\Ô)¨W¸aµZÕ-@ÀFÔ-JÙØˆFØ×Ñ˜W¨a¥ZÕ0Ô1Ø�a�KŠFØ�UŒ]ØˆFØ�a�KˆFØœ3˜w›<Ô'¨G­O¸tÔ,CØ!�/�Ø˜fÔ$ÙØ˜3”; 7¨d¤?Ø •z¤S¨£\Ô1Ù#Ø¨�zÕ*¨iÔ7Ø !�˜Ø")¥/˜Ø× Ñ  Ô)Ø˜!•’Øœ˜W›Ô%ÙØ�a�K‹Fà×Ñ˜TÔ"Ø�a�K‹FßŸVÙØ�2—7‘7˜9Ó% zÐ9Ð9r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   r)   r   r
   Úboolr   )r   s   "r   r   r   h   s!   € ÷ *ñ * sð *°3ð *¸4ñ *r   c                ó¨   € V'       d   W^,
          ,          MRpV^,           \        V 4      8  d   W^,           ,          MRpVR9   ;'       g    VR8H  # )zNReturn whether ``&`` at ``index`` belongs to ``>&``/``<&``/``&>`` redirection.r   z<>Ú>r   )r   r)   ÚbeforeÚafters   &&  r   Ú_is_fd_redirect_ampersandr;   h   sE   € ç#(ˆW˜Q•YÖ¨b€FØ"'¨!¥)¬c°'«lÔ":ˆG˜A•IÖÀ€EØ�T‰>×)Ð)˜U c™\Ð)r   c               ó    € V ^8„  d   QhRRRR/# )r   r   r   Ústartr   r   )r   s   "r   r   r   o   s   € ÷ 2Tñ 2T¨ð 2T°Cñ 2Tr   c                ó’  € TpRpRp. pRpRpTpV\        V 4      8  Ed¥   W,          p	V	R8X  d   V'       g   Vf   EM‡V	R8H  ;'       d2    VR8g  ;'       d%    V'       * ;'       d    V^,           \        V 4      8  p
V'       g   Vf	   V
'       d   W“8X  d   RpY*'       d   ^M^,          pKœ  V	R9   d   T	pV^,          pK°  V	R8X  dL   W!8X  g8   W^,
          ,          P                  4       '       g   W^,
          ,          R9   d   R	pV^,          pEK  V P                  R
V4      '       d   V^,          pEK&  V P                  RV4      '       d9   \        W4      pVf   R	pV^,          pEK[  Vw  r,rÞVP	                  WÍV34       EKv  V	R9   d-   V	R8X  d   \        W4      '       g   V'       d   R	pM	V^,           pV^,          pEKµ  W%WgV3# )a  Scan one logical command.

Return ``(end, specs, unknown_operator, post_heredoc_list_operator, owner_start)``.
List operators before the first heredoc select the simple command that owns it. A list
operator after a heredoc keeps the body visible because another command may consume it.
NFÚ
r   r   z'"`Ú#z;&|()Tr,   r+   z;|&Ú&)r   r/   r.   r4   r!   r;   )r   r=   r   ÚquoteÚcommentÚspecsÚunknown_operatorÚpost_heredoc_list_operatorÚowner_startr$   ÚescapedÚparsedr1   r0   r2   s   &&             r   Ú_scan_heredoc_command_unitrJ   o   s¡  € ð €FØ€EØ€GØ€EØÐØ!&ÐØ€KØ
”3�w“<Õ
Ø�ˆØ�4Œ<ŸW¨ªÙà˜$‘,×]Ð] 5¨C¡<×]Ð]¸´K×]Ð]ÀFÈQÅJÔQTÐU\ÓQ]ÑD]ˆß�eÒ'¯7ØŒ}Ø�Øž7‘a¨Õ)ŠFØ�VŒ^ØˆEØ�a�KŠFØ�SŒ[˜fœo°À!½Õ1D×1LÑ1L×1NÒ1NØ!(°!­Õ!4¸Ô!?ØˆGØ�a�K‹FØ×Ñ  v×.Ò.Ø�a�K‹FØ×Ñ  f×-Ò-Ü,¨WÓ=ˆFØŠ~Ø#'Ð Ø˜!•“à8>Ñ5� :Ø—‘˜i°VÐ<×=à�uŒ}Ø˜”Ô 9¸'× JÒ JçØ15Ñ.à"(¨1¥*�KØ�a�K‹FØÐ*ÈÐSÐSr   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
r   r   r   Ú
body_startr   r1   r0   r6   r
   z
int | Noner   )r   s   "r   r   r   ¤   s4   € ÷ ñ ØðØ"%ðØ25ðØCGðØLVñr   c                ó  € Tp V P                  RV4      pVR8X  d   \        V 4      MV^,           pWV P                  R4      P                  R4      pV'       d   VP                  R4      MTpW‚8X  d   V# VR8X  d   R# TpK€  )zAReturn the position after an exact shell heredoc terminator line.r?   ÚÚ	Néÿÿÿÿ)r   r   ÚremovesuffixÚlstrip)	r   rL   r1   r0   r   Únewliner:   ÚlineÚ	candidates	   &&&&     r   Ú_find_heredoc_closerV   ¤   s}   € ð €FØ
Ø—,‘,˜t VÓ,ˆØ '¨2¤”�G”°7¸Qµ;ˆØ˜eÐ$×1Ñ1°$Ó7×DÑDÀTÓJˆß)3�D—K‘K Ô%¸ˆ	ØÔ!ØˆLØ�bŒ=ÙØŠr   c               ó    € V ^8„  d   QhRRRR/# r   r   )r   s   "r   r   r   ´   s   € ÷ 3/ñ 3/¨ð 3/°ñ 3/r   c           	     ó°  a€ RV 9  d   V # V P                  R4      p. p^ pW18:  Ed_   \        W4      w  pppppV'       d   V # V'       g   V\        V 4      8¼  d   EM)V^,           pKG  V\        V 4      8¼  d   V # V^,           p	. p
V F.  w  r¼p\        W	W¼4      pVf   V u # V
P	                  Wž34       Tp	K0  	  \
        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       d�   V'       g‡   \        WV 4      o\        WV 4      p\        ;QJ d    V3R lR	 4       F  '       g   K   RM	  RM! V3R lR	 4       4      '       g-   \        P                  V4      '       d   VP                  V
4       T	pEKe  . p^ pV F.  w  ppVV VV RV P                  RVV4      ,          .,          pTpK0  	  RP                  V4      V VR ,           # )
zHMask heredoc bodies that are provably inert data (see module docstring).r+   Nc              3  ó*   "  € T F	  w  rq3x € K  	  R # 5i©Nr   )Ú.0Ú
_delimiterÚ_strip_tabsr2   s   &   r   Ú	<genexpr>Ú-strip_inert_heredoc_bodies.<locals>.<genexpr>Ö   s   é € ÐD¹eÑ:˜:°F”»eùs   ‚FTc              3  ó.   <"  € T F
  pVS9   x € K  	  R # 5irZ   r   )r[   ÚmarkerÚmasked_openers   & €r   r^   r_   Û   s   øé € ð áI�Fð ˜-Ö'ÛIùs   ƒr?   r   )r   r   z<(z>(Ú(Ú)Ú{Ú})ÚrfindrJ   r   rV   r!   Úallr'   ÚanyÚ_INERT_HEREDOC_CONSUMER_REÚsearchÚextendÚcountr"   )r   Úlast_opener_indexÚrangesÚcommand_startÚcommand_endrD   rE   rF   rG   Úbody_cursorÚbody_rangesr1   r0   Ú_quotedÚ	close_endÚmasked_ownerÚpartsÚpreviousr=   r   rb   s   &                   @r   Ústrip_inert_heredoc_bodiesry   ´   sÈ  ø€ ð �7ÔØˆØŸ™ dÓ+ÐØ$&€FØ€MØ
Õ
,ô ' wÓ>ñ	
ØØØØ&ØçØˆNßØœc '›lÔ*ÙØ'¨!�OˆMÙØœ#˜g›,Ô&ØˆNØ! A•oˆØ-/ˆÛ.3Ñ*ˆI 7Ü+¨GÀ)ÓXˆIØÒ Ø’Ø×Ñ Ð7Ô8Ø#ŠKñ /4÷ ‹CÑD¹eÓD�C�CŠCÑD¹eÓD×DÒDß.ä/°ÀkÐ0RÓSˆMÜ.¨wÀ;Ð/OÓPˆLß“3ô áIó—3—3’3ô áIó÷ ò ô -×3Ñ3°L×AÒAØ—‘˜kÔ*Ø#‹à€EØ€HÛ‰
ˆˆsØ�'˜( 5Ð)¨4°'·-±-ÀÀeÈSÓ2QÕ+QÐRÕRˆØŠñ ð �7‰7�5‹>˜G H IÐ.Õ.Ð.r   )Ú__doc__Ú
__future__r   ÚreÚcompileÚ
IGNORECASErj   r   r'   r4   r;   rJ   rV   ry   r   r   r   Ú<module>r      sU   ðñ:õ #ã 	ð  ŸZšZð8à‡M�MóÐ õõõ4+:õ\*õ2Tõj÷ 3/r   