+
    iHàj  ã                   ó  € R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RI	H
t
Ht ]P                  ! ]4      t]P                  ! R4      t]P                  ! R4      tRtR R	 ltR
 R ltR R ltR R ltR R ltRR R lltR# )zmShared SKILL.md preprocessing helpers: ``${HERMES_*}`` template tokens and
inline ``!`cmd``` shell expansion.N)ÚPath)Úelide)Ú
IS_WINDOWSÚwindows_hide_flagsz*\$\{(HERMES_SKILL_DIR|HERMES_SESSION_ID)\}z!`([^`\n]+)`i   c                ó$   € V ^8„  d   QhR\         /# )é   Úreturn)Údict)Úformats   "Ú>/home/ubuntu/.hermes/hermes-agent/agent/skill_preprocessing.pyÚ__annotate__r      s   € ÷ 	ñ 	œDñ 	ó    c                 óØ   €  ^ RI Hp  V ! 4       ;'       g    / P                  R4      p\        V\        4      '       d   V#  / #   \
         d    \        P                  RRR7        / # i ; i)z9Load the ``skills`` section of config.yaml (best-effort).)Úload_config_readonlyÚskillszCould not read skills configT©Úexc_info)Úhermes_cli.configr   ÚgetÚ
isinstancer	   Ú	ExceptionÚloggerÚdebug)r   Ú
skills_cfgs     r   Úload_skills_configr      sn   € ðDÝ:Ù*Ó,×2Ð2°×7Ñ7¸ÓAˆ
Ü�j¤$×'Ò'ØÐð (ð €Iøô ô DÜ�‰Ð3¸dˆÕCØ€IðDús   ‚A –)A Á"A)Á(A)c                ód   € V ^8„  d   QhR\         R\        R,          R\         R,          R\         /# )r   ÚcontentÚ	skill_dirNÚ
session_idr   )Ústrr   )r
   s   "r   r   r   $   s8   € ÷ Wñ W¤cð W´d¸Tµkð WÌsÐUYÍzð WÔ^añ Wr   c                ó¤   a€ V '       g   V # RV'       d   \        V4      MRRV'       d   \        V4      MR/o\        P                  V3R lV 4      # )zYReplace ${HERMES_SKILL_DIR} / ${HERMES_SESSION_ID}; tokens without a value stay in place.ÚHERMES_SKILL_DIRNÚHERMES_SESSION_IDc                 óf   <€ SV P                  ^4      ,          ;'       g    V P                  ^ 4      # )é   )Úgroup)ÚmÚvaluess   &€r   Ú<lambda>Ú*substitute_template_vars.<locals>.<lambda>,   s%   ø€ ¨F°1·7±7¸1³:Õ,>×,LÐ,LÀ!Ç'Á'È!Ã*Ð,Lr   )r   Ú_SKILL_TEMPLATE_REÚsub)r   r   r   r'   s   &&&@r   Úsubstitute_template_varsr,   $   sB   ø€ çØˆà¯iœC 	œN¸TØ·
œS œ_Àð€Fô ×!Ñ!Ô"LÈgÓVÐVr   c                óV   € V ^8„  d   QhR\         R\        R,          R\        R\         /# )r   ÚcommandÚcwdNÚtimeoutr   ©r   r   Úint)r
   s   "r   r   r   /   s,   € ÷ '3ñ '3œcð '3¬¨t­ð '3¼cð '3Äcñ '3r   c                ó\  € \         '       d   R\        4       /M/ p^ RIHp  Rp\         '       d   ^ RIHp V! 4       p\        P                  ! VRV .3RV'       d   \        V4      MRRR	R
R	RRRRR\        ^\        V4      4      RRR\        P                  RV! 4       /	VB pTP"                  ;'       g    RP%                  R4      ;'       g&    TP&                  ;'       g    RP%                  R4      p	TP(                  ^ 8w  d   T	'       g   RTP(                   RT  R2# \+        T	\,        4      #   \        P                   d    RT RT  R2u # \         d     R# \         dE   p\        T\         4      '       d   R\        T4      9   d   RT RT  R2u Rp?# RT R2u Rp?# Rp?ii ; i)z×Run one inline-shell snippet and return its stdout (trimmed; stderr when
stdout is empty). Failures return an ``[inline-shell ...]`` marker instead
of raising, so one bad snippet can't wreck the whole skill message.Úcreationflags)Údelegated_child_subprocess_envÚbash)Ú
_find_bashz-cr/   NÚcapture_outputTÚtextÚencodingzutf-8ÚerrorsÚreplacer0   ÚcheckFÚstdinÚenvz[inline-shell timeout after zs: Ú]z$[inline-shell error: bash not found]z"live-system guard: blocked os.killz[inline-shell error: Ú Ú
z[inline-shell exit z with no output: )r   r   Úagent.delegation_contextr5   Útools.environments.localr7   Ú
subprocessÚrunr   Úmaxr2   ÚDEVNULLÚTimeoutExpiredÚFileNotFoundErrorr   r   ÚRuntimeErrorÚstdoutÚrstripÚstderrÚ
returncoder   Ú_INLINE_SHELL_MAX_OUTPUT)
r.   r/   r0   Ú_popen_kwargsr5   r6   r7   Ú	completedÚexcÚoutputs
   &&&       r   Úrun_inline_shellrU   /   sÑ  € ÷ @J»z�_Ô&8Ó&:Ñ;Èr€MÝGð.Øˆß‹:õ <Ù“<ˆDÜ—N’NØ�4˜Ð!ñ

ç”�C” Tð

ð  ð

ð ð	

ð !(ð	

ð 1:ð	

ô
 ˜œ3˜w›<Ó(ð

ð ð

ô ×$Ñ$ð

ñ /Ó0ð

ð ñ

ˆ	ð* ×Ñ×$Ð$ "×,Ñ,¨TÓ2×[Ð[°y×7GÑ7G×7MÐ7MÈ2×6UÑ6UÐVZÓ6[€FØ×Ñ˜qÔ ¯ð % Y×%9Ñ%9Ð$:Ð:KÈGÈ9ÐTUÐVÐVÜ�Ô1Ó2Ð2øô ×$Ñ$ô EØ-¨g¨Y°c¸'¸À!ÐDÒDÜô 6Ú5Üô .ô �cœ<×(Ò(Ð-QÔUXÐY\ÓU]Ô-]Ø1°'°¸#¸g¸YÀaÐHÕHØ& s e¨1Ð-Õ-ûð.úsM   ¢D0 °*D0 ÁAD0 Ä0F+ÅF+ÅF+ÅF+Å&F+Å'.F&ÆF+ÆF&Æ F+Æ&F+c                óV   € V ^8„  d   QhR\         R\        R,          R\        R\         /# )r   r   r   Nr0   r   r1   )r
   s   "r   r   r   Y   s,   € ÷ 3ñ 3¤ð 3´¸µð 3Äsð 3Ìsñ 3r   c                óV   aa€ RV 9  d   V # R VV3R llp\         P                  W04      # )zLReplace every !`cmd` snippet with its stdout, run with the skill dir as CWD.z!`c                óD   € V ^8„  d   QhR\         P                  R\        /# )r   Úmatchr   )ÚreÚMatchr   )r
   s   "r   r   Ú)expand_inline_shell.<locals>.__annotate__]   s"   € ÷ Hñ HœŸ™ð H¤Sñ Hr   c                 óp   <€ V P                  ^4      P                  4       pV'       d   \        VSS4      # R# )r$   rA   )r%   ÚstriprU   )rY   Úcmdr   r0   s   & €€r   Ú_replaceÚ%expand_inline_shell.<locals>._replace]   s0   ø€ Ø�k‰k˜!‹n×"Ñ"Ó$ˆß<?Ô  Y°Ó8ÐGÀRÐGr   )Ú_INLINE_SHELL_REr+   )r   r   r0   r`   s   &ff r   Úexpand_inline_shellrc   Y   s/   ù€ à�7ÔØˆ÷Hñ Hô ×Ñ Ó2Ð2r   c                ó>   € V ^8„  d   QhR\         R,          R\        /# )r   r   Nr   )r   Úbool)r
   s   "r   r   r   c   s   € ÷ (ñ (¤t¨d¥{ð (´tñ (r   c                óÞ  € V f   R#  ^ RI Hp ^ RIHp V P	                  4       pV! 4       P
                  P	                  4       V! 4       P	                  4       /pVP                   Fj  pVP                  R8X  g   K  VR,          R,          P                  4       '       g   K<  VP                  VR,          R,          P	                  4       V4       Kl  	  VP                  4        EF  w  reVP                  V4      '       d   VP                  4       '       g   K5   \        P                  ! VP                  RR7      4      R	,          pVP                  4        Uu. uF  p\!        V\"        4      '       g   K  VNK  	  p	pT	 Fx  p
\3        T
P5                  R4      ;'       g    R4      pT
P5                  R4      R8X  g   K?  T'       g   KI  TP                  Y[,          P	                  4       4      '       g   Kv    R# 	  EK  	  R# u upi   \$        \&        \(        \*        \,        3 d    \.        P1                  R
TRR7         R# i ; i  \6         d    \.        P1                  RRR7        R# i ; i)un  Whether *skill_dir* is a hub-installed skill the scan gate classifies as community trust.

The hub's INSTALL_POLICY blocks a community install on a caution/dangerous verdict â€” but
``--force`` (or a pre-scanner install) puts that skill on disk anyway, and the inline-shell
DSL scans as high severity, so auto-executing it on view would re-arm exactly what the
gate refused (#63307). Provenance is the hub lock entry (trusted/builtin entries expand;
anything without one â€” bundled-synced, user-created, project/external â€” keeps the flag's
contract). It covers every SKILL.md nested inside a community install and is read from
the lock that owns the skills tree the dir lives in, not only the active profile's
(``external_dirs`` can expose another profile's installs). A lock that exists but cannot
be read fails closed for skills in its tree; no lock means no hub installs.
F)ÚHubLockFile)Ú_skills_dirr   z.hubz	lock.jsonz	utf-8-sig)r:   Ú	installedz;Unreadable hub lock %s; inline shell stays off for its treeTr   Úinstall_pathrA   Útrust_levelÚ	communityz?Could not resolve hub provenance for inline-shell trust scoping)Útools.skills_hubrg   Útools.skills_toolrh   ÚresolveÚpathÚparentsÚnameÚis_fileÚ
setdefaultÚitemsÚis_relative_toÚjsonÚloadsÚ	read_textr'   r   r	   ÚOSErrorÚ
ValueErrorÚKeyErrorÚ	TypeErrorÚAttributeErrorr   r   r   r   r   )r   rg   rh   ÚtargetÚlocksÚrootÚ	lock_pathri   ÚeÚentriesÚentryÚrels   &           r   Ú_is_community_hub_skillr‡   c   sä  € ð ÒÙðÝ0Ý1à×"Ñ"Ó$ˆÙ“×#Ñ#×+Ñ+Ó-©{«}×/DÑ/DÓ/FÐGˆØ—N”NˆDØ�y‰y˜HÖ$¨$°­-¸+Õ*E×)NÑ)N×)PÔ)PØ× Ñ  $¨¥-°+Õ"=×!FÑ!FÓ!HÈ$ÖOñ #ð  %Ÿ{™{Ÿ}‰OˆIØ×)Ñ)¨$×/Ò/°I×4EÑ4E×4GÒ4GÙðÜ ŸJšJ y×':Ñ':ÀKÐ':Ó'PÓQÐR]Õ^�	Ø&/×&6Ñ&6Ô&8ÓPÑ&8 ¼JÀqÌ$×<OŸ1˜1Ñ&8�ÐPó !�Ü˜%Ÿ)™) NÓ3×9Ð9°rÓ:�Ø—9‘9˜]Ó+¨{Ö:¿s¹sÀv×G\ÑG\Ð^bÕ^h×]qÑ]qÓ]s×GtÔGtÛô !ñ  -ñ ùò QøÜœZ¬´9¼nÐMô Ü—‘ÐZÐ\eÐpt�ÔuÛðûô ô Ü�‰ÐVÐaeˆÔfÚðús   ˆA-I Á:!I Â A4I ÄI Ä?HÅHÅ4HÅ:HÅ<!I ÆI Æ=I Ç(I Ç4I Ç8I ÈHÈ8IÈ>I ÉIÉI É"I,É+I,c          
      ó~   € V ^8„  d   QhR\         R\        R,          R\         R,          R\        R,          R\         /# )r   r   r   Nr   r   r   )r   r   r	   )r
   s   "r   r   r   Ž   sF   € ÷ ñ Üðä�d�{ðô �d•
ðô �t•ð	ô
 	ñr   c           
     óV  € V '       g   V # \        V\        4      '       d   TM	\        4       pVP                  RR4      '       d   \	        WV4      p VP                  RR4      '       dA   \        V4      '       g0   \        Y\        VP                  R^
4      ;'       g    ^
4      4      p V # )zBApply configured SKILL.md template and inline-shell preprocessing.Útemplate_varsTÚinline_shellFÚinline_shell_timeout)r   r	   r   r   r,   r‡   rc   r2   )r   r   r   r   Úcfgs   &&&& r   Úpreprocess_skill_contentrŽ   Ž   sˆ   € ÷ ØˆÜ" :¬t×4Ò4‰*Ô:LÓ:N€CØ
‡w�wˆ ×%Ò%Ü*¨7¸zÓJˆØ
‡w�wˆ~˜u×%Ò%Ô.EÀi×.PÒ.PÜ% g¼#¸c¿g¹gÐF\Ð^`Ó>a×>gÐ>gÐegÓ:hÓiˆØ€Nr   )NN)Ú__doc__rw   ÚloggingrZ   rE   Úpathlibr   Úagent.compression_markerr   Úhermes_cli._subprocess_compatr   r   Ú	getLoggerÚ__name__r   Úcompiler*   rb   rP   r   r,   rU   rc   r‡   rŽ   © r   r   Ú<module>r˜      s~   ðñ&ó Û Û 	Û Ý å *ß Hà	×	Ò	˜8Ó	$€ð —Z’ZÐ MÓNÐ à—:’:˜oÓ.Ð àÐ õ	õWõ'3õT3õ(÷Vñ r   