+
    lHàjÌ   ã            
      óæ  a € 0 t $ R t^ RIHt ^ RIt^ RIHtHt RtR0R R llt	RRR	R
/t
R R lt]	! RR4      ]	! RR]P                  4      ]	! R]4      ]	! RR4      ]	! RR4      ]	! RR4      ]	! RR4      .tR]R&   ^~R^‰R^|R/tR]R &   R!t]P"                  ! R"],           R#,           4      R$3]P"                  ! R%4      R&3.tR']R(&   ]! 0 R1m4      t]P"                  ! R)4      tR* R+ ltR, R- ltR. R/ ltR# )2aâ  Output-pattern failure hints for the terminal tool.

Extends the exit-code semantics table in ``terminal_tool`` with a bounded scan of failed-command
output mapped to ONE short, actionable recovery hint. Rules: only fires on non-zero exit; first
match wins, patterns ordered by observed production frequency; scans only the first
``_SCAN_CHARS`` so hints key on error headers, not deep context; hints state the *next action*
in 1-2 sentences; pure function, no I/O or config reads.
)ÚannotationsN)ÚCallableÚOptionali   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	é   ÚpatternÚstrÚmessagezstr | Callable[[str], str]ÚflagsÚintÚreturnz#Callable[[str, str], Optional[str]]© )Úformats   "Ú9/home/ubuntu/.hermes/hermes-agent/tools/terminal_hints.pyÚ__annotate__r      s*   € ÷ 
ñ 
˜ð 
Ð'Að 
È#ð 
ÐVyñ 
ó    c                óJ   aa€ \         P                  ! W4      oR VV3R llpV# )zTHint firing when ``pattern`` matches; ``{0}`` = first group, or ``message(group1)``.c               ó$   € V ^8„  d   QhRRRRRR/# ©r   Úcommandr   Úoutputr   úOptional[str]r   )r   s   "r   r   Ú!_regex_hint.<locals>.__annotate__   s!   € ÷ ñ �cð  3ð ¨=ñ r   c                óÆ   <€ SP                  V4      pV'       dG   \        S4      '       d   S! VP                  ^4      4      # SP                  ! VP	                  4       !  # R# )é   N)ÚsearchÚcallableÚgroupr   Úgroups)r   r   Úmr	   Úrxs   && €€r   ÚhintÚ_regex_hint.<locals>.hint   sL   ø€ Ø�I‰I�fÓˆßÜ*2°7×*;Ò*;‘7˜1Ÿ7™7 1›:Ó&Ð\ÀÇÂÐQR×QYÑQYÓQ[ÑA\Ð\Ùr   )ÚreÚcompile)r   r	   r
   r!   r    s   &f& @r   Ú_regex_hintr%      s"   ù€ ä	�Š�GÓ	#€B÷ñ ð €Kr   Úpythonun   This system has no bare `python` â€” use `python3`, or the project venv's interpreter (e.g. .venv/bin/python).Úpipuo   This system has no bare `pip` â€” use `pip3`, `python3 -m pip`, or the project venv's pip (e.g. .venv/bin/pip).c               ó    € V ^8„  d   QhRRRR/# )r   Úmissingr   r   r   )r   s   "r   r   r   (   s   € ÷ Iñ I 3ð I¨3ñ Ir   c                óN   € \         P                  V 4      ;'       g
    R V  RV  R2# )Ú`z6` is not installed or not on PATH. Verify with `which zK`; install it or use an absolute path instead of retrying the same command.)Ú_MISSING_COMMAND_HINTSÚget)r)   s   &r   Ú_missing_command_hintr.   (   s=   € Ü!×%Ñ% gÓ.÷ Ið IØ
ˆGˆ9ÐJÈ7È)ð THð 	HðIr   zUnknown JSON field: "?(\w+)u—   The installed gh does not support the JSON field '{0}'. The valid field list is printed in the output above â€” retry using only fields from that list.z-^CONFLICT |Automatic merge failed|needs mergeuÈ   Git merge conflict. Do not retry this command. Resolve the conflicted files listed above (edit, then `git add`), then continue (`git rebase --continue` / commit the merge) â€” or abort with `--abort`.zE(?:bash: line \d+: |bash: |sh: \d*:? ?)?([\w.+-]+): command not foundz?(?:ModuleNotFoundError|ImportError): No module named '?([\w.]+)zèPython cannot import '{0}'. Most often the wrong interpreter is running: activate the project venv (e.g. `source .venv/bin/activate`) or invoke its python directly. Only pip install if the package is genuinely absent from that venv.z+(?:fatal|error):.*?'([^']+)' already existsuŠ   '{0}' already exists â€” retrying unchanged will keep failing. Reuse it, choose another name, or delete it first if it is genuinely stale.z(API rate limit|was submitted too quicklyu{   GitHub API rate limit hit â€” immediate retries will keep failing. Continue with other work and retry this operation later.zPermission denied|EACCESz Permission denied. Check ownership/mode of the target path (`ls -la`); prefer a user-writable location. Only escalate to sudo if the task genuinely requires it.z)list[Callable[[str, str], Optional[str]]]Ú_OUTPUT_HINTSu~   Exit 126: the file was found but is not executable â€” `chmod +x` it or invoke it via its interpreter (e.g. `bash script.sh`).u�   Exit 137: the process was SIGKILLed â€” usually out-of-memory or an external kill. Reduce memory use or check `dmesg | tail` before retrying.z‡Exit 124: the command hit its timeout. Raise timeout= (foreground max 600s) or run it with background=true and notify_on_complete=true.zdict[int, str]Ú_EXIT_CODE_HINTSz,(?:tail|head|cat|tee|less|more|wc|sort|uniq)z(?<!\|)\|(?!\|)\s*z\b[^|]*$u€  exit_code 0 here is the status of the last pipeline command (tail/head/cat/...), NOT of the command before the pipe â€” and the output contains failure indicators. Treat this run as FAILED until proven otherwise: re-run the command WITHOUT the pipe (output is auto-truncated and the full text is saved to a file, so piping through tail/head is never needed) to get the real exit code.z(\|\|\s*(?:echo\b|printf\b|true\b|:\s|:$)uñ   exit_code 0 here is the status of the `||` fallback (echo/true), NOT of the command before it â€” and the output contains failure indicators. Treat this run as FAILED until proven otherwise: re-run the command bare to get its real exit code.z!list[tuple[re.Pattern[str], str]]Ú_MASKING_SHAPESa  (?:error\[E\d+\]|error: could not compile|error: aborting due to|Traceback \(most recent call last\)|(?m:^(?:=+ )?\d+ failed)|(?m:^FAILED (?:\S+::|\S+\.py))|compilation terminated\.|npm ERR!|BUILD FAILED|Build FAILED|FAILED: |(?m:^make(?:\[\d+\])?: \*\*\*))c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r   r   )r   s   "r   r   r   ƒ   s   € ÷ ñ ˜#ð  #ñ r   c                óÖ   € T ;'       g    RP                  4       P                  4        F<  pRV9  g   VP                  R4      '       g   K#  VP                  R^4      R,          u # 	  R# )zCBasename of the command head, skipping leading env-var assignments.Ú Ú=Ú/)r5   z./r6   éÿÿÿÿ)ÚstripÚsplitÚ
startswithÚrsplit)r   Útoks   & r   Ú_first_tokenr=   ƒ   sU   € à—�˜2×$Ñ$Ó&×,Ñ,Ö.ˆØ�cŒ>˜SŸ^™^Ð,<×=Ô=Ø—:‘:˜c 1Ó% bÕ)Ò)ñ /ñ r   c               ó$   € V ^8„  d   QhRRRRRR/# r   r   )r   s   "r   r   r   ‹   s&   € ÷ Pñ P Sð P°#ð P¸-ñ Pr   c                óø   a€ T ;'       g    RoT;'       g    RR\          pS'       d8   V'       d0   \        S4      \        9   g   \        P	                  V4      '       g   R# \        V3R l\         4       R4      # )zSWarning note when an exit-0 result likely masks a failure (caller gates on exit 0).r4   Nc              3  ó^   <"  € T F"  w  rVP                  S4      '       g   K  Vx € K$  	  R # 5i)N)r   )Ú.0r    ÚnoteÚcmds   &  €r   Ú	<genexpr>Ú*annotate_masked_success.<locals>.<genexpr>’   s   øé € ÐH¡o™(˜"¸¿¹À3¿—’£oùs   ƒ-£
-)Ú_SCAN_CHARSr=   Ú_READONLY_HEADSÚ_FAILURE_SHAPESr   Únextr1   )r   r   ÚwindowrC   s   && @r   Úannotate_masked_successrK   ‹   sX   ø€ à
�-ˆ-�R€CØ�lˆl˜˜Lœ[Ð)€Fß—v¤¨cÓ!2´oÔ!EÜ"×)Ñ)¨&×1Ò1ÙÜÔH¥oÓHÈ$ÓOÐOr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r   r   Ú	exit_coder   r   r   r   r   )r   s   "r   r   r   •   s(   € ÷ +ñ +˜cð +¨cð +¸3ð +À=ñ +r   c                óö   € V^ 8X  d   R# T;'       g    RR\          pV'       d   \        MR F#  p T! T ;'       g    RV4      ;p'       d   Vu # K%  	  \        P	                  V4      #   \         d     KJ  i ; i)zFReturn one short recovery hint for a failed command, or None (exit 0).Nr4   r   )rF   r/   Ú	Exceptionr0   r-   )r   rM   r   rJ   Úfnr!   s   &&&   r   Úannotate_failurerQ   •   s}   € à�A„~ÙØ�lˆl˜˜Lœ[Ð)€Fß%�m¨2Ò-ˆð	Ù˜'Ÿ-˜- R¨Ó0Ð0ˆtÖ0Ø’ñ 1ñ .ô ×Ñ 	Ó*Ð*øô ô 	Úð	ús   ±
A)¼A)ÁA)Á)A8Á7A8)é    >   ÚagÚjqÚlsÚrgÚawkÚcatÚsedÚechoÚfindÚgrepÚheadÚtailÚzcatÚdmesgÚprintfÚstringsÚ
journalctl)Ú__conditional_annotations__Ú__doc__Ú
__future__r   r#   Útypingr   r   rF   r%   r,   r.   Ú	MULTILINEr/   Ú__annotations__r0   Ú_PASSTHROUGH_CONSUMERSr$   r1   Ú	frozensetrG   rH   r=   rK   rQ   )rd   s   @r   Ú<module>rl      s—  øðôõ #ã 	ß %à€÷
ð ð 5à	ð 'ðÐ õIñ Ð.ðZó[ñ Ð@ðAàBDÇ,Á,óPñ ÐXØ%ó'ñ ÐRð`óañ Ð>ðMóNñ Ð;ð=ó>ñ Ð+ðcódð-<€Ð8ó ð< ð  
JØð  
YØð  
Sð$Ð �.ó ð IÐ ð
 ‡Z‚ZÐ%Ð(>Õ>ÀÕLÓMð*ð+ð ‡Z‚ZÐ;Ó<ðEðFð6€Ð2ó ñ ò Gó H€ð —*’*ð	ó
€õ õP÷+r   