+
    iHàjï·  ã                  ó¸  € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
HtHtHtHt ^ RIHt ^ RIHtHtHtHtHtHtHtHtHtHtHtHtHtHtH t H!t! ^ RI"H#t$ ^ RI%H&t&H't' ^ R	I(H)t)H*t* ^ R
I+H,t, ]PZ                  ! ].4      t/]P`                  ! R]Pb                  4      t2/ ]3Pi                  RgR4      C]3Pi                  RhR4      Ct5R R lt6R R lt7Rt8R R lt9R 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# R$ ltAR% R& ltBR' R( ltCR) R* ltDR+ R, ltER- R. ltFR/ R0 ltGR1 R2 ltHR3 R4 ltIR5 R6 ltJR7 R8 ltKR9 R: ltLR; R< ltMR= R> ltNR? R@ ltORA RB ltPRC RD ltQRE RF ltRRG RH ltSRI RJ ltTRK RL ltURM RN ltVRO RP ltWRQ RR ltXRS RT ltYRU RV ltZRW RX lt[RY RZ lt\RiR[ R\ llt]RiR] R^ llt^R_ R` lt_RiRaRb/Rc Rd lllt`Re Rf lta. RjOtbR# )kaü  System-prompt assembly for :class:`AIAgent`.

Built once per session and reused across turns (only context compression
triggers a rebuild) so the upstream prefix cache stays warm.  Three tiers are
joined with ``\n\n``: ``stable`` (identity, guidance, env hints, coding brief,
platform hints), ``context`` (workspace snapshot, caller ``system_message``,
context files) and ``volatile`` (skills index, memory, USER.md, external memory
provider, timestamp line).  See ``references/system-prompt-invariant.md``.
)ÚannotationsN)ÚPath)ÚAnyÚDictÚListÚOptionalÚTuple)Úowned_kanban_task)ÚDEFAULT_AGENT_IDENTITYÚEXECUTION_GUIDANCE_MODELSÚ!GOOGLE_MODEL_OPERATIONAL_GUIDANCEÚHERMES_AGENT_HELP_GUIDANCEÚ$HERMES_AGENT_HELP_GUIDANCE_NO_SKILLSÚKANBAN_GUIDANCEÚPARALLEL_TOOL_CALL_GUIDANCEÚPLATFORM_HINTSÚSESSION_SEARCH_GUIDANCEÚSKILLS_GUIDANCEÚSTEER_CHANNEL_NOTEÚTASK_COMPLETION_GUIDANCEÚTELEGRAM_RICH_MESSAGES_HINTÚTOOL_USE_ENFORCEMENT_GUIDANCEÚTOOL_USE_ENFORCEMENT_MODELSÚdrain_truncation_warnings)Úprompt_builder)Úresolve_agent_cwdÚresolve_context_cwd)Úget_default_hermes_rootÚget_hermes_home)Úis_truthy_valuezv^## Plugin Context: (?P<id>[a-z0-9][a-z0-9._-]{0,127})\n<!-- hermes-plugin-section-chars:(?P<chars>[0-9]{1,4}) -->\n\nTFc               ó$   € V ^8„  d   QhRRRRRR/# )é   Úsettingr   ÚmodelúOptional[str]ÚreturnÚbool© )Úformats   "Ú8/home/ubuntu/.hermes/hermes-agent/agent/system_prompt.pyÚ__annotate__r*   )   s!   € ÷ 9ñ 9˜ð 9 ]ð 9Àtñ 9ó    c                óü  a€ V RJ g   V RJ d   V # \        V \        4      '       d5   V P                  4       \        9   d   \        V P                  4       ,          # T;'       g    RP                  4       o\        V \        4      '       d;   \
        ;QJ d    V3R lV  4       F  '       g   K   R# 	  R# ! V3R lV  4       4      # \
        ;QJ d    V3R lV 4       F  '       g   K   R# 	  R# ! V3R lV 4       4      # )z±Resolve a config gate: True/"true"-ish -> on, False/"false"-ish -> off,
list -> case-insensitive model-substring match, anything else ("auto") ->
match against *default_models*.TFÚ c              3  óz   <"  € T F0  p\        V\        4      '       g   K  VP                  4       S9   x € K2  	  R # 5i©N)Ú
isinstanceÚstrÚlower©Ú.0ÚpÚmodel_lowers   & €r)   Ú	<genexpr>Ú_model_gate.<locals>.<genexpr>3   s(   øé € ÐS±W°Ä
È1Ìc×@RÔ+�1—7‘7“9 Ö+³Wùs   ƒ; ;c              3  ó,   <"  € T F	  qS9   x € K  	  R # 5ir/   r'   r3   s   & €r)   r7   r8   4   s   øé € Ð8© A�KÖ«ùs   ƒ)r0   r1   r2   Ú_GATE_WORDSÚlistÚany)r"   r#   Údefault_modelsr6   s   &&&@r)   Ú_model_gater>   )   s¶   ø€ ð �$ƒ˜' UÓ*ØˆÜ�'œ3×Ò G§M¡M£O´{Ô$BÜ˜7Ÿ=™=›?Õ+Ð+Ø—;�;˜B×%Ñ%Ó'€KÜ�'œ4× Ò ß‹sÔS±WÓS�sŒsÐSŠsÐSˆsÔS±WÓSÓSÐSß‹3Ô8©Ó8�3Œ3Ð8Š3Ð8ˆ3Ô8©Ó8Ó8Ð8r+   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r!   Úagentr   Úplatform_keyr1   Údefault_hintr%   r'   )r(   s   "r)   r*   r*   7   s/   € ÷ Gñ G #ð G°Sð GÈð GÐPSñ Gr+   c                óŽ  € \        V RR4      pV'       d(   \        V\        4      '       d   VP                  V4      MRp\        V\        4      '       d   RV/p\        V\        4      '       g   V# R VP                  R4      VP                  R4      3 4       w  rVT;'       g    TpV'       d   V RV 2P                  4       # T# )a  Apply the ``platform_hints.<platform>`` config override: ``replace``
substitutes the default, ``append`` adds text (a bare string is shorthand
for append). Malformed entries fall back to the unmodified default so bad
config can never break prompt assembly or leak across platforms.Ú_platform_hint_overridesNÚappendc              3  ór   "  € T F-  p\        V\        4      '       d   VP                  4       MR x € K/  	  R# 5i©r-   N)r0   r1   Ústrip)r4   Úvs   & r)   r7   Ú)_resolve_platform_hint.<locals>.<genexpr>B   s)   é € Ð |ÑR{ÈQ¬j¸¼C×.@Ò.@ §¡¤ÀbÔ!HÓR{ùs   ‚57Úreplaceú

)Úgetattrr0   ÚdictÚgetr1   rH   )r@   rA   rB   Ú	overridesÚspecÚreplace_textÚappend_textÚbases   &&&     r)   Ú_resolve_platform_hintrU   7   s·   € ô
 ˜Ð9¸4Ó@€Iß*6¼:ÀiÔQU×;VÒ;Vˆ9�=‰=˜Ô&Ð\`€DÜ�$œ×ÒØ˜$ÐˆÜ�dœD×!Ò!ØÐÙ |ÐSW×S[ÑS[Ð\eÓSfÐhl×hpÑhpÐqyÓhzÑR{Ó |Ñ€LØ×'Ð'˜<€Dß1<ˆdˆV�4˜�}Ð%×+Ñ+Ó-ÐFÀ$ÐFr+   uÁ    You're in its embedded terminal pane, beside the GUI chat â€” the user can select your output (Option-drag on macOS, Shift-drag elsewhere) and press Cmd/Ctrl+L to send it to the chat composer.c               ó    € V ^8„  d   QhRRRR/# )r!   Úhintr1   r%   r'   )r(   s   "r)   r*   r*   N   s   € ÷ /ñ / sð /¨sñ /r+   c                ó�   € V '       d1   \         V 9   g&   \        \        P                  ! R4      4      '       g   V # V \         ,           # )z˜Append the desktop embedded-terminal clarifier when ``HERMES_DESKTOP_TERMINAL``
is set (only the desktop's TUI PTY, never the chat backend). Idempotent.ÚHERMES_DESKTOP_TERMINAL)Ú_TUI_EMBEDDED_PANE_CLARIFIERr   ÚosÚgetenv)rW   s   &r)   Ú_tui_embedded_pane_clarifierr]   N   s4   € ÷ Ô/°4Ô7¼ÌrÏyÊyÐYrÓOs×?tÒ?tØˆØÔ.Õ.Ð.r+   c               ó    € V ^8„  d   QhRRRR/# )r!   r@   r   r%   údict[str, str]r'   )r(   s   "r)   r*   r*   V   s   € ÷ ñ  ð ¨ñ r+   c                ó  €  \        \        4       ;'       g    R4      pR Uu/ uF"  q"\        \        WR4      ;'       g    R4      bK$  	  ppVP	                  \        V \        4      VR7       V#   \         d    Rp L`i ; iu upi )zDReturn immutable-at-render-time metadata exposed to prompt sections.r-   N)Úprofile_nameÚcwd)Ú
session_idr#   ÚproviderÚplatform)r1   r   Ú	ExceptionrM   ÚupdateÚ_active_profile_nameÚ_ambient_plugin_profile_name)r@   rb   ÚkÚinfos   &   r)   Ú_plugin_session_inforl   V   s„   € ðÜÔ%Ó'×-Ð-¨2Ó.ˆñ <kÓkÑ;j°aŒs”7˜5 TÓ*×0Ð0¨bÓ1Ò1Ñ;j€DÐkØ‡K�KÔ1°%Ô9UÓVÐ\_€KÔ`Ø€Køô	 ô ØŠðüâks   ‚A0 ˜A0 £(BÁ0B Á?B c               ó   € V ^8„  d   QhRR/# ©r!   r%   r1   r'   )r(   s   "r)   r*   r*   a   s   € ÷ 7ñ 7 cñ 7r+   c                 óB   € ^ RI Hp  \        V ! 4       ;'       g    R4      # )é    ©Úget_active_profile_nameÚdefault)Úhermes_cli.profilesrr   r1   rq   s    r)   ri   ri   a   s   € Ý;ÜÑ&Ó(×5Ð5¨IÓ6Ð6r+   c               ó    € V ^8„  d   QhRRRR/# ©r!   r@   r   r%   r1   r'   )r(   s   "r)   r*   r*   f   s   € ÷ ñ  ð °ñ r+   c                ój   €  \        V 4      pVe   \        V4      # V! 4       #   \         d     R# i ; i)zÎProfile name from the agent's OWN home, else *ambient()*; "default" on any
failure. Ambient resolution misreports on threads that lost the HERMES_HOME
ContextVar, which is why the agent's home is preferred.rs   )Ú_agent_homeÚ_profile_name_for_homerf   )r@   ÚambientÚhomes   && r)   rh   rh   f   s;   € ðÜ˜5Ó!ˆØ/3Ò/?Ô% dÓ+ÐNÁWÃYÐNøÜô Úðús   ‚# œ# £2±2c               ó    € V ^8„  d   QhRRRR/# )r!   r@   r   r%   Útupler'   )r(   s   "r)   r*   r*   q   s   € ÷ ñ ¨#ð °%ñ r+   c                ó¾  € \        V R4      '       d   V P                  # \        V RR4      p\        V\        4      '       d   V'       d   \        V4      pM! ^ RIHp \        V! \        V 4      4      4      pW n        V#   \         dS   p\        T RR4      pT'       d   \        P                  RT4        Rp?LC\        P                  RT4       Rp Rp?L`Rp?ii ; i)	a$  Render plugin sections once per session and freeze them on the agent.
A restored ``_cached_system_prompt`` is parsed instead of re-running plugin
code; a render that raises at a rebuild boundary keeps the previous bytes
(stashed by ``invalidate_system_prompt``) instead of silently vanishing.Ú'_plugin_system_prompt_sections_snapshotÚ_cached_system_promptN)Úrender_system_prompt_sectionsÚ'_plugin_system_prompt_sections_previousz\Plugin system prompt sections failed to re-render (%s); keeping the previous frozen sectionsz7Plugin system prompt sections could not be rendered: %sr'   )Úhasattrr   rM   r0   r1   Ú_restore_plugin_prompt_sectionsÚhermes_cli.pluginsr�   r}   rl   rf   ÚloggerÚwarning)r@   Ústored_promptÚrenderedr�   Úexcs   &    r)   Ú_frozen_plugin_prompt_sectionsr‹   q   sÉ   € ô
 ˆuÐ?×@Ò@Ø×<Ñ<Ð<Ü˜EÐ#:¸DÓA€MÜ�-¤×%Ò%¯-Ü2°=ÓA‰ð		ÝHÜÑ:Ô;OÐPUÓ;VÓWÓXˆHð 5=Ô1Ø€Oøô ô 	Ü˜uÐ&OÐQUÓVˆHßÜ—‘Ð}ð  @C÷  Dñ  Dä—‘ÐXÐZ]Ô^Ø•ûð	ús   Á A? Á?CÂ
+CÂ:CÃCc               ó    € V ^8„  d   QhRRRR/# )r!   Úpromptr1   r%   r}   r'   )r(   s   "r)   r*   r*   Š   s   € ÷ Xñ X¨Cð X°Eñ Xr+   c           
     ó~  € ^ RI HpHpHpHpHp V P                  V4      pV^ 8¼  d"   V P                  W&\        V4      ,           4      MR	pV^ 8  d   R
# V\        V4      ,           pWR P                  R4      '       g   R
# WV p	. p
\        P                  V	4       F†  p\        VP                  R4      4      pW›P                  4       VP                  4       V,            pWÁ8”  g   \        V4      V8w  d   K\  V
P                  V! VP                  R4      VRRR7      4       Kˆ  	  V! V
4      V	8X  d   \!        V
4      # R
# )u¨   Recover frozen section bytes from the persisted full prompt.  Only the
exact canonical container emitted by core is accepted â€” user/project text
may resemble a frame.)ÚMAX_SYSTEM_PROMPT_SECTION_CHARSÚPLUGIN_SECTIONS_ENDÚPLUGIN_SECTIONS_STARTÚ!RenderedPluginSystemPromptSectionÚformat_system_prompt_sectionsNz

Conversation started:ÚcharsÚidÚafter_memoryzpersisted-prompt)r•   ÚcontentÚpositionÚpluginéÿÿÿÿr'   )r…   r�   r�   r‘   r’   r“   ÚrfindÚfindÚlenÚ
startswithÚ_PLUGIN_SECTION_FRAME_REÚfinditerÚintÚgroupÚendrE   r}   )r�   r�   r�   r‘   r’   r“   Ústartr£   Ú	after_endÚframedÚrestoredÚmatchÚcontent_lenr—   s   &             r)   r„   r„   Š   s(  € ÷õ ð �L‰LÐ.Ó/€EØRWÐ[\ÔR\ˆ&�+‰+Ð)´3Ð7LÓ3MÕ+MÔ
NÐbd€CØ
ˆQ„wØˆ	Ø”cÐ-Ó.Õ.€IØ�*Ð×(Ñ(Ð)D×EÒEØˆ	Ø˜)Ð$€FØ€HÜ)×2Ñ2°6Ö:ˆÜ˜%Ÿ+™+ gÓ.Ó/ˆØŸ™› u§y¡y£{°[Õ'@ÐAˆØÔ8¼CÀ»LÈKÔ<WÙØ�‰Ñ9¸U¿[¹[ÈÓ=NÐX_ØCQÐZlônö 	oñ ;ñ <¸HÓEÈÔOŒ5�‹?ÐWÐUWÐWr+   c               ó$   € V ^8„  d   QhRRRRRR/# )r!   r@   r   r�   r1   r%   ÚNoner'   )r(   s   "r)   r*   r*   ¥   s&   € ÷ \ñ \¨#ð \°sð \¸tñ \r+   c                ó&   € \        V4      V n        R# )zCSeed a resumed agent's frozen snapshot from persisted prompt bytes.N)r„   r   )r@   r�   s   &&r)   Úrestore_plugin_prompt_sectionsr­   ¥   s   € ä4SÐTZÓ4[€EÖ1r+   c               ó$   € V ^8„  d   QhRRRRRR/# )r!   Úsectionsr}   r˜   r1   r%   ú	list[str]r'   )r(   s   "r)   r*   r*   ª   s!   € ÷ $ñ $ Uð $°cð $¸iñ $r+   c                ó†   € ^ RI Hp T! V  Uu. uF  q3P                  V8X  g   K  VNK  	  up4      pV'       d   V.# . # u upi )rp   )r“   )r…   r“   r˜   )r¯   r˜   r“   ÚsÚblocks   &&   r)   Ú_plugin_section_blocksr´   ª   s?   € Ý@Ù)±hÓ*Y±h°Ç*Á*ÐPXÑBX¯1¨1±hÑ*YÓZ€EßˆEˆ7Ð# Ð#ùò +Zs   �>¤>c               ó$   € V ^8„  d   QhRRRRRR/# )r!   r@   r   Únowr%   r'   )r(   s   "r)   r*   r*   °   s&   € ÷ .Zñ .Z˜sð .Z¨ð .Z°ñ .Zr+   c           
     ó\  a€ ^ RI H p R V3R llp\        V RR4      p\        V RR4      p Ve0   \        V\        4      '       d   V'       d   VP	                  V4      MRpWd3 Fx  p\        V\        4      '       d   \        P                  ! RV4      MRpV'       g   K<   V! VP                  VP                  ^4       RVP                  ^4       2R	4      4      u # 	  \        V R
R4      p	\        V	R4      '       d	   V! V	4      # S#   \
         d    Rp L·i ; i  \         d     KÆ  i ; i)uÐ  Best-known conversation start time, or ``now`` as a fallback.
``Conversation started:`` must be byte-stable across rebuilds (compression,
resume, fresh gateway turns), so prefer immutable sources in order: the
lineage-root session id's embedded stamp (compaction rotates ids, each with
its own mint time), the current session id's stamp, ``agent.session_start``,
then ``now``.  Stamps are box-local wall-clock: attach that zone first, then
convert to ``now``'s zone so the date matches the per-turn clock.

0. the LINEAGE-ROOT session id's embedded timestamp â€” compaction can rotate the session id, and each
rotated id embeds its OWN mint time, so after months of compactions rung 1 alone would quietly re-birth
the conversation at its latest rotation. Walking to the lineage root (same walk as
``_conversation_root_id``) recovers the ORIGINAL birth stamp â€” a Bot Mode forever-chat keeps knowing
when it was first born, across every compaction (maintainer-directed, #98426); 1. the timestamp embedded
in ``session_id`` (``YYYYMMDD_HHMMSS_...``) â€” immutable for the life of the session, so the line is
byte-stable across every rebuild boundary (preserving prefix-cache KV); 2. 3. ``now`` (initial/legacy
build without either).
)Údatetimec               ó    € V ^8„  d   QhRRRR/# )r!   Údtr   r%   r'   )r(   s   "r)   r*   Ú)_session_start_like.<locals>.__annotate__Ã   s   € ÷ ñ ˜3ð  3ñ r+   c                ó  <€ V P                   f    V P                  4       p \	        SRR 4      e-   V P                   e    V P                  SP                   4      p V # V #   \        \        3 d     LPi ; i  \        \        3 d     T # i ; i)NÚtzinfo)r½   Ú
astimezoneÚ
ValueErrorÚOSErrorrM   )rº   r¶   s   &€r)   Ú_to_display_tzÚ+_session_start_like.<locals>._to_display_tzÃ   s�   ø€ Ø�9‰9Òðà—]‘]“_�ô �3˜ $Ó'Ò3¸¿	¹	Ò8MðØ—]‘] 3§:¡:Ó.�ð ˆ	ˆrˆ	øô ¤Ð(ô Ùðûô
 ¤Ð(ô ØØˆ	ðús"   ‘A ¿A5 ÁA2Á1A2Á5B
Â	B
rc   NÚ_session_dbz^(\d{8})_(\d{6})Ú_z%Y%m%d_%H%M%SÚsession_startr¾   )r¸   rM   r0   r1   Úget_conversation_rootrf   Úrer¨   Ústrptimer¢   r¿   rƒ   )
r@   r¶   r¸   rÁ   rc   ÚdbÚroot_idÚ	candidateÚmrÅ   s
   &f        r)   Ú_session_start_likerÍ   °   s%  ø€ õ$ "÷ð ô ˜ ¨dÓ3€JÜ	�˜ tÓ	,€BðØ:<º.ÌZÐXbÔdg×MhÒMh×mw�"×*Ñ*¨:Ô6ð  ~Bˆð Ó*ˆ	Ü8BÀ9Ìc×8RÒ8RŒB�HŠHÐ(¨)Ô4ÐX\ˆß‰1ðÙ% h×&7Ñ&7¸1¿7¹7À1»:¸,ÀaÈÏÉÐPQË
À|Ð8TÐVeÓ&fÓgÒgñ	 +ô ˜E ?°DÓ9€MÜ,3°MÀ<×,PÒ,P‰>˜-Ó(ÐYÐVYÐYøô ô ØŠðûô ô Úðús)   ¬!D	 ÁD	 Â!:DÄ	DÄDÄD+Ä*D+c               ó    € V ^8„  d   QhRRRR/# ©r!   r@   r   r%   zOptional[Path]r'   )r(   s   "r)   r*   r*   á   s   € ÷ ñ �sð ˜~ñ r+   c                óü   €  ^ RI Hp V! 4       pV'       d   \        V4      #   \	        \	        V RR4      RR4      pV'       d   \        V4      P
                  # R#   \         d     LEi ; i  \         d     R# i ; i)uc  The agent's OWN profile home, or None to use ambient resolution.
A bound HERMES_HOME ContextVar override wins (the gateway multiplexes
profiles over one shared session DB and binds the home per turn); else the
parent of ``_session_db.db_path`` â€” ground truth on threads that lost the
ContextVar, where ambient resolution would leak the launch profile.

1. Surfaces that multiplex several profiles over ONE shared session DB (the messaging gateway:
``gateway/run.py`` hands every agent the launch-home ``state.db`` and binds the profile home per turn
via ``_profile_runtime_scope`` + ``copy_context``) would otherwise have the db-derived launch home STOMP
the correctly-bound profile â€” inverting the leak this helper exists to fix (found by @kshitijk4poor's
post-merge probe on #86313). 2. Fallback: the home containing the agent's ``_session_db.db_path``
(``<home>/state.db``) â€” ground truth on threads that lost the ContextVar (ContextVars don't propagate
into ``threading.Thread``), where the unbound build previously fell back to the launch home and leaked
the default profile's skills/identity into a bot prompt.
)Úget_hermes_home_overriderÃ   NÚdb_path)Úhermes_constantsrÑ   r   rf   rM   Úparent)r@   rÑ   ÚoverriderÒ   s   &   r)   rx   rx   á   s~   € ð Ý=Ù+Ó-ˆßÜ˜“>Ð!ð ðÜœ' %¨¸Ó=¸yÈ$ÓOˆß'.Œt�G‹}×#Ñ#Ð8°DÐ8øô	 ô Ùðûô
 ô Úðús-   ‚A —
A ¤4A, ÁA, ÁA)Á(A)Á,A;Á:A;c               ó    € V ^8„  d   QhRRRR/# rÏ   r'   )r(   s   "r)   r*   r*   ÿ   s   € ÷ 9ñ 9˜Sð 9 ^ñ 9r+   c                ó6   € \        V 4      pVe
   VR,          # R# )zCThe agent's own ``<home>/skills`` dir, or None to use ambient home.NÚskills)rx   )r@   r{   s   & r)   Ú_agent_skills_dirrÙ   ÿ   s    € ä�uÓ€DØ"Ò.ˆ4�(�?Ð8°DÐ8r+   c               ó    € V ^8„  d   QhRRRR/# )r!   r{   r   r%   r1   r'   )r(   s   "r)   r*   r*     s   € ÷ 
ñ 
 ð 
¨#ñ 
r+   c                ó   €  ^ RI Hp V P                  4       P                  V! 4       R,          P                  4       4      pVP                  '       d   VP                  ^ ,          # R#   \
        \        3 d     R# i ; i)zð``<root>/profiles/X`` -> ``"X"``; anything else -> ``"default"``.
Uses ``get_default_hermes_root()`` (NOT ``get_hermes_home()``): on a bound
profile session the ambient home IS the profile dir, so every profile
would misreport as "default".)r   Úprofilesrs   )rÓ   r   ÚresolveÚrelative_toÚpartsr¿   rÀ   )r{   r   Úrels   &  r)   ry   ry     sd   € ð
Ý<Ø�l‰l‹n×(Ñ(Ñ*AÓ*CÀjÕ*P×)YÑ)YÓ)[Ó\ˆØ"ŸyŸy˜yˆs�y‰y˜�|Ð7¨iÐ7øÜœÐ ô Úðús   ‚AA( ÁA( Á&A( Á(A=Á<A=c               ó    € V ^8„  d   QhRRRR/# ©r!   r@   r   r%   r$   r'   )r(   s   "r)   r*   r*     s   € ÷ ;ñ ; ð ;¨ñ ;r+   c                óp  € V P                   pRpRV9   d3   \        P                  ! \        V RR4      \        V RR4      RV9   R7      p\        V RR4      pVf   R	V9   d   \	        4       '       d   \
        pTR
V9   d   \        MRRV9   d   \        MRV.pRP                  R V 4       4      ;'       g    R# )zHTool-aware behavioral guidance, injected only when the tools are loaded.NÚmemoryÚ_memory_enabledTÚ_user_profile_enabledÚskill_manage)Úskill_manage_availableÚ_kanban_worker_guidanceÚkanban_showÚsession_searchÚ c              3  ó8   "  € T F  q'       g   K  Vx € K  	  R # 5ir/   r'   )r4   Úgs   & r)   r7   Ú'_tool_guidance_block.<locals>.<genexpr>*  s   é € Ð2™}˜!³—A’A›}ùó   ‚	�
)	Úvalid_tool_namesÚ_pbÚbuild_memory_guidancerM   r	   r   r   r   Újoin)r@   ÚnamesÚmemory_guidanceÚ_kanban_guidanceÚtool_guidances   &    r)   Ú_tool_guidance_blockrù     sÁ   € à×"Ñ"€Eð €OØ�5ÔÜ×3Ò3Ü�EÐ,¨dÓ3Ü�EÐ2°DÓ9Ø#1°UÑ#:ô
ˆô ˜uÐ&?ÀÓFÐØÒ M°UÔ$:Ô?P×?RÒ?RÜ*ÐàØ#3°uÔ#<ÕÀ$Ø)¨UÔ2�¸Øð	€Mð �8‰8Ñ2™}Ó2Ó2×:Ð:°dÐ:r+   c               ó    € V ^8„  d   QhRRRR/# rv   r'   )r(   s   "r)   r*   r*   -  s   € ÷ Añ A˜#ð A #ñ Ar+   c                óê  a € \         ;QJ d    V 3R lR	 4       F  '       g   K   RM	  RM! V 3R lR	 4       4      '       g   R# ^ RIpS P                   Uu0 uF  q!P                  V4      kK  	  upRR0,
          p ^ RIHp V! S P                  \        4       R7      p\        P                  ! S P                  TT;'       g    R\        S 4      R7      # u upi   \         d    \        4       p LSi ; i)
uŽ   Skills index (empty without skills tools).  Focus mode demotes non-coding
categories to names-only â€” never hidden, every name stays visible.c              3  ó@   <"  € T F  qSP                   9   x € K  	  R # 5ir/   ©rñ   ©r4   Únamer@   s   & €r)   r7   Ú!_skills_prompt.<locals>.<genexpr>0  s   øé € ÐhÑ:g°$�u×-Ñ-Ö-Ó:gùó   ƒTFr-   N)Úcoding_compact_skill_categories)re   rb   )Úavailable_toolsÚavailable_toolsetsÚcompact_categoriesÚskills_dir_override©Úskills_listÚ
skill_viewrç   )r<   Úmodel_toolsrñ   Úget_toolset_for_toolÚagent.coding_contextr  re   r   rf   Ú	frozensetrò   Úbuild_skills_system_promptrÙ   )r@   r
  Ú	tool_nameÚavail_toolsetsr  Ú_compact_catss   f     r)   Ú_skills_promptr  -  sÏ   ø€ ÷ ‹3ÔhÑ:gÓh�3�3Š3ÔhÑ:gÓh×hÒhÙÛØSX×SiÒSiÓjÑSiÀi×6Ñ6°yÖAÑSiÑjÐnrÐtvÐmwÕw€Nð$ÝHÙ7ÀÇÁÔUhÓUjÔkˆô ×)Ò)¸%×:PÑ:PÐesØ<I×<QÐ<QÈTÔgxÐy~ÓgôAð Aùò køô ô $Ü!›Šð$ús   ÁCÁ<"C ÃC2Ã1C2c               ó    € V ^8„  d   QhRRRR/# ©r!   r@   r   r%   r°   r'   )r(   s   "r)   r*   r*   =  s   € ÷ &ñ &˜Cð & Iñ &r+   c                ó¦  a € \        S RR4      '       gA   \        ;QJ d    V 3R lR 4       F  '       g   K   RM	  RM! V 3R lR 4       4      '       g   . # \        S RR4      '       g¢   R. . 3p \        \        P                  P                  R4      4      '       g%   ^ RIHp V! \        S R	R
4      \        S 4      R7      pV^,          '       d-   \        P                  RRP                  V^,          4      4       TS n        RS n        S P                  ^ ,          pV'       d   V.# . #   \         d    \        P                  RRR7        LRi ; i)u  ``skills.auto_load`` blocks, resolved once per agent lifecycle (config, skill files and
HERMES_IGNORE_RULES are read on the first build only) so the prompt stays byte-stable
across model switches, compression and static-prefix restoration.

Same gate as ``_skills_prompt``: nothing without the skills toolset, and nothing for agents that skip
context files (delegate children, curator/review forks, gateway hygiene agents) â€” pinned skills are
operator guidance for the user's session, not payload for every internal fork.Úskip_context_filesFc              3  ó@   <"  € T F  qSP                   9   x € K  	  R # 5ir/   rý   rþ   s   & €r)   r7   Ú#_auto_load_parts.<locals>.<genexpr>E  s   øé € ð >fÙ7d¨t�E×*Ñ*Ö*Ó7dùr  TÚ_auto_load_skills_resolvedr-   ÚHERMES_IGNORE_RULES)Úbuild_auto_load_promptrc   N)Útask_idÚhome_overridez=skills.auto_load: skill(s) not found or disabled, skipped: %sú, z#skills.auto_load: injection skipped©Úexc_infor  )rM   r<   r   r[   ÚenvironrO   Úagent.skill_commandsr  rx   r†   r‡   rô   rf   ÚdebugÚ_auto_load_skills_resultr  )r@   Úresultr  r�   s   f   r)   Ú_auto_load_partsr&  =  s(  ø€ ô ˆuÐ*¨E×2Ò2¿#»#ô >fÙ7dó>f¿#¿#º#ô >fÙ7dó>f÷ ;fò ;fàˆ	Ü�5Ð6¸×>Ò>Ø46¸¸B°<ˆð	OÜ"¤2§:¡:§>¡>Ð2GÓ#H×IÒIÝGÙ/¼ÀÀ|ÐUYÓ8ZÔjuÐv{Ój|Ô}�Ø�a�yŒyÜ—‘Ð^Ð`d×`iÑ`iÐjpÐqrÕjsÓ`tÔuð *0ˆÔ&Ø+/ˆÔ(Ø×+Ñ+¨AÕ.€FßˆFˆ8Ð% 2Ð%øô ô 	OÜ�L‰LÐ>ÈˆLÖNð	Oús   Á0A D+ Ã,D+ Ä+"EÅEc               ó    € V ^8„  d   QhRRRR/# r  r'   )r(   s   "r)   r*   r*   X  s   € ÷ ñ ˜3ð  9ñ r+   c                ó  € . p ^ RI HpHpHp \	        \        V RR4      ;'       g    R4      P                  4       pV'       g_   \        V RR4      p\        V RR4      p\	        V'       d   V'       d   VP                  V4      MR;'       g    R4      P                  4       pWR8X  d   V! \        V 4      4      MRpV'       d9   VP                  V4       VP                  V! \        V 4      4      4       RV n
        V#   \         d     T# i ; i)uÐ   Bot Mode teammate protocol â€” only in a bot's canonical "Bot Chat" session.
Marks the prompt timeless (the volatile date line is dropped) since a birth
date pinned in a months-long session is misinformation.)ÚBOT_CHAT_TITLEÚ
epoch_lineÚget_bot_mode_protocol_sectionÚ_session_title_hintr-   rÃ   Nrc   T)Útools.bot_mode_prober)  r*  r+  r1   rM   rH   Úget_session_titlerx   rE   Ú_bot_chat_timeless_promptrf   )	r@   rß   r)  r*  r+  Ú_titleÚ_sdbÚ_sidÚ_bot_sections	   &        r)   Ú_bot_mode_partsr4  X  sì   € ð €EðßbÑbÜ”W˜UÐ$9¸2Ó>×DÐDÀ"ÓE×KÑKÓMˆßÜ˜5 -°Ó6ˆDÜ˜5 ,°Ó5ˆDÜ¿4ÇD˜$×0Ñ0°Ô6Èt×ZÐZÐXZÓ[×aÑaÓcˆFØLRÔLdÑ4´[ÀÓ5GÔHÐjnˆßØ�L‰L˜Ô&ð �L‰L™¤K°Ó$6Ó7Ô8Ø.2ˆEÔ+ð €Løô ô ØØ€Lðús.   „"C= §C= Á.C= Á3C= Â5C= Ã8C= Ã=DÄDc               ó   € V ^8„  d   QhRR/# rn   r'   )r(   s   "r)   r*   r*   p  s   € ÷ *ñ *¨3ñ *r+   c                 ó   € ^ RI Hp  V ! 4       # )rp   ©Ú_resolve_active_profile_name)Úagent.file_safetyr8  r7  s    r)   Ú!_ambient_file_safety_profile_namer:  p  s   € Ý>Ù'Ó)Ð)r+   c               ó    € V ^8„  d   QhRRRR/# rv   r'   )r(   s   "r)   r*   r*   u  s   € ÷ %ñ % ð %¨ñ %r+   c                ó*  € \        V 4      p\        V \        4      pVR8X  d2   \        Ve   \	        4       M	\        4       4      pRV,           R,           # Ve   \        V4      M\        \        4       4      p\	        4       pRV RV RV RV RV R	V R
2# )a	  Name the running profile so the agent doesn't conflate ``~/.hermes/skills``
(default) with ``~/.hermes/profiles/<active>/skills``.  Resolved from the
agent's OWN home first (a build thread that lost the ContextVar would
otherwise print "default" for a bot profile).rs   zCActive Hermes profile: default. Other profiles (if any) live under zê/profiles/<name>/. Each profile has its own skills/, plugins/, cron/, and memories/ that affect a different session than this one. Do not modify another profile's skills/plugins/cron/memories unless the user explicitly directs you to.zActive Hermes profile: z . This session reads and writes z'/. The default profile's data lives at z
/skills/, z/plugins/, z/cron/, u¶   /memories/ â€” those belong to a different session run from a different shell. Do NOT modify another profile's skills/plugins/cron/memories unless the user explicitly directs you to.)rx   rh   r:  r1   r   r   )r@   Ú_agent_home_pathÚactive_profileÚ	_root_strÚprofile_homeÚdefault_roots   &     r)   Ú_active_profile_linerB  u  sÁ   € ô
 # 5Ó)ÐÜ)¨%Ô1RÓS€NØ˜Ô"ô Ð5EÒ5QÔ/Ô1ÔWfÓWhÓiˆ	ðØ õ!ð$õð	
ð -=Ò,H”3Ð'Ô(ÌcÔRaÓRcÓNd€Lô +Ó,€Là
! .Ð!1ð 2Ø"�^ð $#Ø#/ .°
¸<¸.ÈØˆ.˜  ð /%ð	&ðr+   c               ó    € V ^8„  d   QhRRRR/# )r!   rA   r1   r%   r'   )r(   s   "r)   r*   r*   �  s   € ÷ ñ ¨ð °ñ r+   c                ó¬  € \         P                  ! V R4      pV'       gc   V '       d[    ^ RIHp VP                  V 4      pVf   ^ RIHp V! 4        VP                  V 4      pT;'       d    VP                  ;'       g    RpV R8X  d;   V'       d3   \        4       '       d#   VP                  4       R,           \        ,           pV#   \         d     LPi ; i)zHBuilt-in hint, else the plugin adapter's ``platform_hint``, else ``""``.r-   )Úplatform_registry)Údiscover_pluginsÚtelegramrì   )r   rO   Úgateway.platform_registryrE  r…   rF  Úplatform_hintrf   Ú_telegram_rich_messages_enabledÚrstripr   )rA   rW   rE  Ú_entryrF  s   &    r)   Ú_default_platform_hintrM  �  s±   € ä×Ò˜l¨BÓ/€Dß—Lð	ÝCØ&×*Ñ*¨<Ó8ˆFØŠ~õ @Ù Ô"Ø*×.Ñ.¨|Ó<�Ø×3Ð3˜v×3Ñ3×:Ð:¸ˆDð �zÔ!§dÔ/N×/PÒ/PØ�{‰{‹}˜sÕ"Ô%@Õ@ˆØ€Køô	 ô 	Ùð	ús   ©AC Á+C Á?C ÃCÃCc               ó    € V ^8„  d   QhRRRR/# rv   r'   )r(   s   "r)   r*   r*   ²  s   € ÷ Kñ K˜sð K sñ Kr+   c                óÈ   € ^ RI Hp V! RR4      P                  4       P                  4       pV'       d   VR8X  d   R# \	        W\        V4      4      pV'       d	   RV RV 2# R# )u)  The destination channel's hint (default + its ``platform_hints`` override) for a cron agent.

A cron agent runs as platform ``cron`` but its final response lands on the job's ``deliver``
channel, so without this the model never learns that MEDIA: tags become Slack/Telegram
attachments or that tables do not render there â€” and a user's ``platform_hints.slack.append``
never reached scheduled jobs at all. The scheduler publishes the primary auto-deliver target
into the session ContextVar before the agent runs (same seam ``send_message`` routes by).
)Úget_session_envÚ!HERMES_CRON_AUTO_DELIVER_PLATFORMr-   ÚcronzDelivery destination (z): )Úgateway.session_contextrP  r2   rH   rU   rM  )r@   rP  Údeliver_keyrW   s   &   r)   Ú_cron_delivery_hintrU  ²  s`   € õ 8Ù!Ð"EÀrÓJ×PÑPÓR×XÑXÓZ€Kß˜+¨Ô/ÙÜ! %Ô6LÈ[Ó6YÓZ€Dß>BÐ# K =°°D°6Ð:ÐJÈÐJr+   c               ó    € V ^8„  d   QhRRRR/# rv   r'   )r(   s   "r)   r*   r*   Ã  s   € ÷ ñ ˜ð  ñ r+   c                ó&  € V P                   ;'       g    RP                  4       P                  4       p\        W\	        V4      4      pVR8X  d   V'       d   \        V4      pVR8X  d)   \        V 4      pV'       d   V RV 2P                  4       pV# )zžBuilt-in/plugin platform hint + Telegram rich-messages opt-in + config
override + desktop TUI clarifier; cron agents also carry their delivery channel's hint.r-   ÚtuirR  rL   )re   r2   rH   rU   rM  r]   rU  )r@   rA   Ú_effective_hintÚ	_deliverys   &   r)   rI  rI  Ã  sƒ   € ð —N‘N×(Ð( b×/Ñ/Ó1×7Ñ7Ó9€LÜ,¨UÔBXÐYeÓBfÓg€OØ�uÔ§Ü6°ÓGˆØ�vÔÜ'¨Ó.ˆ	ßØ!0Ð 1°°i°[ÐA×GÑGÓIˆOØÐr+   c               ó   € V ^8„  d   QhRR/# )r!   r%   r&   r'   )r(   s   "r)   r*   r*   Ñ  s   € ÷ ñ ¨ñ r+   c                 ó   €  ^ RI Hp  V ! 4       pVP                  R4      ;'       g    / P                  R4      ;'       g    / P                  R4      ;'       g    / P                  R4      pVP                  R4      ;'       g    / P                  R4      ;'       g    / P                  R4      p/ \        V\        4      '       d   TM/ C\        V\        4      '       d   TM/ Cp\        VP                  R4      4      #   \         d     R# i ; i)zÖ``rich_messages`` from the Telegram ``extra`` config; same precedence the
adapter uses (top-level ``platforms.telegram.extra`` overrides
``gateway.platforms.telegram.extra`` at the leaf). False on any read failure.)Úload_config_readonlyÚgatewayÚ	platformsrG  ÚextraÚrich_messagesF)Úhermes_cli.configr]  rO   r0   rN   r&   rf   )r]  Ú_cfgÚ_gwÚ_topÚmergeds        r)   rJ  rJ  Ñ  sã   € ðÝ:Ù#Ó%ˆØ—‘˜)Ó$×*Ð*¨×/Ñ/°Ó<×BÐBÀ×GÑGÈ
ÓS×YÐYÐWY×^Ñ^Ð_fÓgˆØ—‘˜+Ó&×,Ð,¨"×1Ñ1°*Ó=×CÐCÀ×HÑHÈÓQˆØgœJ s¬D×1Ò1‘S°rÐgÄzÐRVÔX\×G]ÒG]¹tÐceÐgˆÜ�F—J‘J˜Ó/Ó0Ð0øÜô Úðús/   ‚$C> §C> Á C> Á)C> ÂC> ÂA!C> Ã>DÄDc               ó$   € V ^8„  d   QhRRRRRR/# )r!   r¶   r   Útzr%   r°   r'   )r(   s   "r)   r*   r*   à  s!   € ÷ ñ �Cð ˜Sð  Yñ r+   c                ó  € \        VRR4      p^ RIHp V! V R4      pV! V R4      pV'       d   V.M. pV'       d   WB8w  d   VP                  V4       V'       d&   VP                  RVR,           RVR	,           24       V# )
u€   IANA key, abbreviation (if different) and UTC offset â€” all constant for
the day, so the byte-stable date line stays cacheable.ÚkeyN)Úsafe_strftimez%Zz%zÚUTC:Né   NÚ::rm  NN)rM   Úhermes_timerk  rE   )r¶   rh  Ú_ianark  Ú_abbrevÚ_offsetÚbitss   &&     r)   Ú
_zone_bitsrt  à  su   € ô �B˜˜tÓ$€EÝ)Ù˜C Ó&€GÙ˜C Ó&€GßˆE‰7 €Dß�7Ô#Ø�‰�GÔßØ�‰�c˜' "�+˜ a¨°­ }Ð5Ô6Ø€Kr+   c               ó    € V ^8„  d   QhRRRR/# rv   r'   )r(   s   "r)   r*   r*   ï  s   € ÷ `ñ `˜3ð ` 3ñ `r+   c                óZ  € ^ RI HpHpHp V! 4       p\	        WA! 4       4      pV'       d   RRP                  V4       R2MRp\        W4      pRV! VR4       V 2pVP                  R4      VP                  R4      8w  d   VR	V! VR4       R
2,          p\        V RR4      '       d   V'       d   RRP                  V4       2MRpRV P                  '       d   V P                  MR3RV P                  3RV P                  3RV P                  33p	VRP                  R V	 4       4      ,           # )zØDate-only so the prompt is byte-stable for the day; zone + offset so
tools needn't guess EST vs EDT. Long-lived sessions get an "as of" line on
rebuild days (the cache prefix is already invalidated at that boundary).)Úget_timezoner¶   rk  z (r  Ú)r-   zConversation started: z%A, %B %d, %Yz%Y%m%dz0
Today's date (as of the last context rebuild): uW    â€” trust this over the start date for what day it is now; query tools for exact time.r/  Fz
Timezone: z
Session IDNÚModelÚProviderÚPlatformc              3  óJ   "  € T F  w  rV'       g   K  R V RV 2x € K  	  R# 5i)Ú
z: Nr'   )r4   ÚlabelÚvalues   &  r)   r7   Ú"_timestamp_line.<locals>.<genexpr>  s%   é € Ð#_Ég¹l¸eÔY^Ô$9 b¨¨¨r°%°Õ$9Ëgùs   ‚#“#)ro  rw  r¶   rk  rt  rô   rÍ   ÚstrftimerM   Úpass_session_idrc   r#   rd   re   )
r@   Ú
_hermes_tzÚ_hermes_nowrk  r¶   Ú_bitsÚ_zone_suffixÚ_startÚtimestamp_lineÚtrailers
   &         r)   Ú_timestamp_linerŠ  ï  s2  € ÷ ZÑYÙ
‹-€CÜ�s˜J›LÓ)€Eß/4�R˜Ÿ	™	 %Ó(Ð)¨Ñ+¸"€LÜ  Ó,€FØ-©m¸FÀOÓ.TÐ-UÐVbÐUcÐd€Nð ‡|�|�HÓ §¡°Ó!:Ô:ØÐNÉ}Ð]`ÐbqÓOrÐNsð ttð tõ 	uˆäˆuÐ1°5×9Ò9ß<A˜: d§i¡i°Ó&6Ð%7Ñ8ÀrˆØ°%×2G×2GÐ2G˜e×.Ò.ÈTÐRÐU\Ð^c×^iÑ^iÐTjØ˜EŸN™NÐ+¨j¸%¿.¹.Ð-IðK€Gà˜BŸG™GÑ#_ÉgÓ#_Ó_Õ_Ð_r+   c               ó    € V ^8„  d   QhRRRR/# r  r'   )r(   s   "r)   r*   r*   
  s   € ÷ ñ ˜ð  ñ r+   c                ó  € . pV P                   '       df   V P                  R3V P                  R33 FE  w  r#V'       d   V P                   P                  V4      MRpV'       g   K4  VP	                  V4       KG  	  V P
                  '       dN    ^ RIHp Ve   V! V 4      '       d5    V P
                  P                  4       pV'       d   VP	                  V4       V#   \         d    Rp LWi ; i  \         d    Rp L=i ; i)zºBuilt-in memory/USER.md blocks plus the external provider block (gated on
the same check ``inject_memory_provider_tools`` uses, so we never advertise
tools the toolset config gated off).rä   ÚuserN)Úmemory_provider_tools_exposed)
Ú_memory_storerå   ræ   Úformat_for_system_promptrE   Ú_memory_managerÚagent.memory_manager_toolsrŽ  rf   Úbuild_system_prompt)r@   rß   ÚenabledÚkindr³   Ú_mem_exposedÚ_ext_mem_blocks   &      r)   Ú_memory_partsr˜  
  sì   € ð €EØ××ÐØ$×4Ñ4°hÐ?À%×B]ÑB]Ð_eÐAfÓg‰MˆGßJQ�E×'Ñ'×@Ñ@ÀÔFÐW[ˆEß‰uØ—‘˜UÖ#ñ hð ××Ðð	 Ý`ð Ò¡<°×#6Ò#6ð&Ø!&×!6Ñ!6×!JÑ!JÓ!L�÷ Ø—‘˜^Ô,Ø€Løô ô 	 ØŠLð	 ûô
 ô &Ø!%’ð&ús$   ÂC Â&C. ÃC+Ã*C+Ã.C>Ã=C>c               ó$   € V ^8„  d   QhRRRRRR/# )r!   r@   r   Úctx_lenúOptional[int]r%   ztuple[list[str], bool]r'   )r(   s   "r)   r*   r*   &  s'   € ÷ [ñ [˜3ð [¨ð [Ð;Qñ [r+   c                óÎ   € V P                   ;'       g    V P                  '       * pV'       d"   \        P                  ! V\	        V 4      R7      MRpV'       d   V.R3# \
        .R3# )z­SOUL.md (primary identity; cron keeps the persona while skipping cwd
instructions, scoped to the agent's OWN home) or the default identity.
Returns ``(parts, soul_loaded)``.)r  NTF)Úload_soul_identityr  rò   Úload_soul_mdrx   r
   )r@   rš  Ú
wants_soulÚ_soul_contents   &&  r)   Ú_identity_partsr¡  &  sZ   € ð ×)Ñ)×IÐI°×1IÑ1IÔ-I€JßS]”C×$Ò$ W¼KÈÓ<NÕOÐcg€Mß&3ˆ]ˆO˜TÐ"ÐZÔ;QÐ:RÐTYÐ9ZÐZr+   c               ó    € V ^8„  d   QhRRRR/# r  r'   )r(   s   "r)   r*   r*   /  s   € ÷ ñ ˜3ð  9ñ r+   c           
     ó  a € . pS P                   '       dA   TR\        3R\        33 UUu. uF  w  r#\        S VR4      '       g   K  VNK  	  upp,          pVP	                  \        S 4      4       S P                   '       g   V# VP	                  \        4       \        S P                  S P                  \        4      '       dk   VP	                  \        4       \        ;QJ d    V 3R lR	 4       F  '       g   K   RM	  RM! V 3R lR	 4       4      '       d   VP	                  \        4       \        \        S RR4      S P                  \        4      '       d(   ^ RIHp VP	                  V! S P                   4      4       V# u uppi )
zXUniversal + tool-aware + model-gated guidance blocks, each gated by its config.yaml key.Ú_task_completion_guidanceÚ_parallel_tool_call_guidanceTc              3  óp   <"  € T F+  qSP                   ;'       g    R P                  4       9   x € K-  	  R# 5irG   )r#   r2   )r4   rî   r@   s   & €r)   r7   Ú"_guidance_parts.<locals>.<genexpr>D  s+   øé € ÐMÑ9L°A�U—[‘[×&Ð& B×-Ñ-Ó/Ö/Ó9Lùs   ƒ6›6FÚ_execution_guidanceÚauto)Úexecution_guidance_text)ÚgeminiÚgemma)rñ   r   r   rM   rE   rù   r   r>   Ú_tool_use_enforcementr#   r   r   r<   r   r   Úagent.prompt_builderrª  )r@   rß   ÚflagÚtextrª  s   f    r)   Ú_guidance_partsr±  /  s1  ø€ à€EØ××ÐØà,Ô.FÐGØ/Ô1LÐMñ$ô
ñ$‘Z�Tô ˜  d×+÷ ˆDñ $ò
õ 	
ˆð 
‡L�LÔ% eÓ,Ô-Ø×!×!Ð!Øˆà	‡L�LÔ#Ô$ô
 �5×.Ñ.°·±Ô=X×YÒYØ�‰Ô2Ô3ß‹3ÔMÑ9LÓM�3�3Š3ÔMÑ9LÓM×MÒMØ�L‰LÔ:Ô;Ü”7˜5Ð"7¸Ó@À%Ç+Á+ÔOh×iÒiÝ@Ø�‰Ñ,¨U×-CÑ-CÓDÔEØ€Lùó-
s   ªFÁFc               ó    € V ^8„  d   QhRRRR/# r  r'   )r(   s   "r)   r*   r*   L  s   € ÷ ñ  #ð ¨)ñ r+   c                ó–   € V P                   R8w  d   . # V P                  P                  R^4      R,          pRV RV P                   R2.# )z{Alibaba Coding Plan always reports "glm-4.7" as the model name; inject
the real identity so the agent can answer correctly.ÚalibabaÚ/z#You are powered by the model named z. The exact model ID is zt. When asked what model you are, always answer based on this information, not on any model name returned by the API.rš   )rd   r#   Úrsplit)r@   Ú_model_shorts   & r)   Ú_alibaba_identity_partr¸  L  sY   € ð ‡~�~˜Ô"Øˆ	Ø—;‘;×%Ñ% c¨1Ó-¨bÕ1€Là
-¨l¨^ð <!Ø!&§¡ ð .5ð	6ðð r+   c               ó   € V ^8„  d   QhRR/# rn   r'   )r(   s   "r)   r*   r*   Z  s   € ÷ ñ ˜Cñ r+   c                 ór   €  \        \        4       ;'       g    \        4       4      #   \         d     R# i ; i)zâThe directory the workspace probe inspects, which is also the prompt's ``Current working
directory``: a build with no cwd bound (launch dir) and a later one binding that same dir
(TUI ``/compress``) are one workspace, not two.r-   )r1   r   r   rÀ   r'   r+   r)   Ú_workspace_pin_keyr»  Z  s4   € ðÜÔ&Ó(×?Ð?Ô,=Ó,?Ó@Ð@øÜô Úðús   ‚' ˜' §6µ6c               ó$   € V ^8„  d   QhRRRRRR/# )r!   r�   r1   rj  r%   r$   r'   )r(   s   "r)   r*   r*   d  s!   € ÷ ñ  sð °ð ¸ñ r+   c                ó²  € ^ RI Hp RV R2pV P                  V4      pV^ 8  d   R# \        V4      P	                  4       pV^ 8¼  d‘   W^,           R P                  R^4      ^ ,          p\        VP                  R^4      ^,          \        R4      R 4      P	                  4       pWu8X  g   WuP                  9   d   V# V P                  W4^,           4      pK—  R# )z«The workspace snapshot inside ``prompt`` taken for ``key`` (its ``- Root:`` is ``key`` or an
ancestor); "" when the prompt has none; None when it has one for another root.)ÚWORKSPACE_BLOCK_HEADERrL   z	
- Root: r-   Nr}  z- Root: )r  r¾  rœ   r   rÝ   Úsplitr�   Úparents)r�   rj  r¾  Úheadr¤   rb   r³   Úroots   &&      r)   Ú_persisted_workspace_blockrÃ  d  s¿   € õ <ØÐ(Ð)¨Ð4€DØ�K‰K˜Ó€EØˆq„yÙÜ
ˆs‹)×
Ñ
Ó
€CØ
�1Œ*Ø˜q•y�zÐ"×(Ñ(¨°Ó3°AÕ6ˆÜ�E—K‘K  aÓ(¨Õ+¬C°
«OÐ,<Ð=Ó>×FÑFÓHˆØŒ;˜$§+¡+Ô-ØˆLØ—‘˜D¨!¥)Ó,ŠÙr+   c               ó    € V ^8„  d   QhRRRR/# râ   r'   )r(   s   "r)   r*   r*   v  s   € ÷ Bñ B˜3ð B =ñ Br+   c                óä  € \        V RR4      p\        V\        4      '       d   V'       d   V# \        V RR4      \        V RR4      r2Ve   \        V\        4      '       d	   V'       g   R#  VP                  V4      p\        T\        4      '       d   TP                  R4      MRp\        T\        4      '       d   T'       d   T# R#   \         d    \
        P                  RTRR7        R# i ; i)	zQPrompt bytes this session already sends: the cached copy, else its persisted row.r€   NrÃ   rc   z8workspace snapshot: session row read failed (session=%s)Tr  Úsystem_prompt)	rM   r0   r1   Úget_sessionrf   r†   r#  rN   rO   )r@   ÚcachedrÉ   rc   Úrowr�   s   &     r)   Ú_session_promptrÊ  v  sÈ   € ä�UÐ3°TÓ:€FÜ�&œ#×Ò§6ØˆÜ˜U M°4Ó8¼'À%ÈÐW[Ó:\ˆ
Ø	‚zœ J´×4Ò4¿JÙðØ�n‰n˜ZÓ(ˆô *4°C¼×)>Ò)>ˆS�W‰W�_Ô%ÀD€FÜ ¬×,Ò,·ˆ6ÐA¸TÐAøô	 ô Ü�‰ÐOÐQ[ÐfjˆÔkÚðús   Á,C Ã#C/Ã.C/c               ó$   € V ^8„  d   QhRRRRRR/# )r!   r@   r   rj  r1   r%   r«   r'   )r(   s   "r)   r*   r*   ‡  s!   € ÷ 8ñ 8˜sð 8¨ð 8°ñ 8r+   c                ó¨   € ^ RI Hp \        V 4      pV'       g   R# V! VR4      pV'       d	   WA8w  d   R# \        W14      pV'       d   W3V n        R# R# )a_  Pin the snapshot the session's existing prompt already carries.  An agent that did not
build those bytes (resumed, or a fresh gateway/TUI agent whose first act is ``/compress``)
would otherwise re-probe git at its first rebuild and rewrite the prompt for any repo that
moved since session start.  Only a snapshot provably taken in this cwd is adopted.)Úruntime_host_valueNzCurrent working directory)Úagent.surface_switchrÍ  rÊ  rÃ  Ú_frozen_workspace_snapshot)r@   rj  rÍ  r�   Ú
stored_cwdr³   s   &&    r)   Ú_seed_workspace_pinrÑ  ‡  sM   € õ
 8Ü˜UÓ#€FßÙÙ# FÐ,GÓH€Jß�jÔ'ÙÜ& vÓ3€E÷ Ø,/¨<ˆÖ(ñ r+   c               ó    € V ^8„  d   QhRRRR/# )r!   r@   r   r%   z&tuple[list[str], list[str], list[str]]r'   )r(   s   "r)   r*   r*   š  s   € ÷ ñ ˜ð Ð!Gñ r+   c                óÈ  €  ^ RI Hp V P                  '       g   . . . 3# \        4       p\	        4       p\        V RR4      f   \        W4       \        V RR4      pVe   V^ ,          V8X  d
   V^,          MRpV! V P                  W P                  V P                  VR7      pVf(   Y6^,          '       d   V^,          ^ ,          MR3V n	        V#   \         d     Mi ; i. . . 3# )av  ``(prefix, workspace, trailing)`` coding-posture blocks; all empty
without tools or when probing fails (it must never block prompt build).

The workspace block is a live git probe after project context, ahead of the whole
volatile band; re-probing at the compaction rebuild re-emits different bytes for any
repo that moved and defeats the keep-prompt fast path.  So the bytes are pinned per
session on the agent, keyed by the probed cwd (a gateway serves many cwds), seeded from
the session's existing prompt when this agent did not build it, and replayed on
rebuilds; ``reset_session_state`` drops the pin at a session boundary.
)Úcoding_system_prompt_partsrÏ  N)re   rb   r#   rñ   Úworkspace_blockr-   )r  rÔ  rñ   r   r»  rM   rÑ  re   r#   rÏ  rf   )r@   rÔ  rb   Úcwd_keyÚpinnedÚreplayrß   s   &      r)   Ú_coding_partsrÙ  š  sß   € ðÝCØ×%×%Ð%Ø�r˜2�:ÐÜ!Ó#ˆÜ$Ó&ˆÜ�5Ð6¸Ó=ÒEÜ Ô/Ü˜Ð <¸dÓCˆà$Ò0°V¸AµYÀ'Ô5I�˜–ÈtˆÙ*°E·N±NÈ×S^ÑS^Ø<A×<RÑ<RÐdjôlˆàŠ>Ø07ÈaÏÌ¸¸q½À!¾ÐVXÐ/YˆEÔ,ØˆøÜô Ùðúàˆr�2ˆ:Ðs   ‚C šC ŸB.C ÃCÃCc               ó    € V ^8„  d   QhRRRR/# r  r'   )r(   s   "r)   r*   r*   º  s   € ÷ ñ  ð ¨ñ r+   c                ó  € . p\        V RR4      '       d    ^ RIHp VP                  V! 4       4       \        V RR4      '       d   VP                  \        V 4      4       VP                  \        V 4      4       V#   \         d     LVi ; i)zÇBlocks that follow the worktree-specific context: environment probe
(config.yaml agent.environment_probe; one line, nothing when clean, skipped
for remote backends), bot-mode protocol, platform hint.Ú_environment_probeT)Úget_environment_probe_lineÚ_bot_mode_protocol)rM   Útools.env_proberÝ  rE   rf   Úextendr4  rI  )r@   rß   rÝ  s   &  r)   Ú_post_workspace_partsrá  º  s~   € ð €EÜˆuÐ*¨D×1Ò1ð	ÝBØ�L‰LÑ3Ó5Ô6ô ˆuÐ*¨D×1Ò1Ø�‰”_ UÓ+Ô,Ø	‡L�L”˜uÓ%Ô&Ø€Løô ô 	Ùð	ús   —A< Á<B
Â	B
c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r!   r@   r   rš  r›  Úsoul_loadedr&   r%   r°   r'   )r(   s   "r)   r*   r*   Ë  s/   € ÷ iñ i˜sð i¨]ð iÈð iÐR[ñ ir+   c           	     óÈ   € V P                   '       d   . # \        V RR4      p\        V'       * R7      p\        P                  ! WBVV P
                  R9   \        V 4      R7      .# )aœ  Project context files (AGENTS.md etc.) for the context tier. TERMINAL_CWD
when set (gateway); None lets discovery fall back to the launch dir.  The
install-tree fallback is only legitimate for cli/tui where the launch dir
IS the user's shell cwd. Desktop launch artifacts skip the session cwd but
still honor the profile-scoped TERMINAL_CWD; without one, the fallback guard
can reject Hermes's bundled AGENTS.md.Ú_context_cwd_is_launch_artifactF)Úinclude_session_override)rb   Ú	skip_soulÚcontext_lengthÚallow_install_tree_fallbackr  )ÚclirX  )r  rM   r   rò   Úbuild_context_files_promptre   rx   )r@   rš  rã  Úlaunch_artifactrb   s   &&&  r)   Ú_context_files_partrí  Ë  sf   € ð ××ÐØˆ	Ü˜eÐ%FÈÓN€OÜ
¸?Ô7JÔ
K€CÜ×*Ò*Ø°wØ$)§N¡N°nÑ$DÔT_Ð`eÓTfôhð ið ir+   c               ó    € V ^8„  d   QhRRRR/# )r!   rß   zlist[Optional[str]]r%   r1   r'   )r(   s   "r)   r*   r*   Û  s   € ÷ Dñ DÐ)ð D¨cñ Dr+   c                ó2   € RP                  R V  4       4      # )z5Join non-empty parts; None/blank entries are dropped.rL   c              3  ó„   "  € T F6  q'       g   K  VP                  4       '       g   K$  VP                  4       x € K8  	  R # 5ir/   )rH   ©r4   r5   s   & r)   r7   Ú_join_tier.<locals>.<genexpr>Ý  s&   é € ÐC©% Q³1”y¸¿¹¿”y�q—w‘w—y�y«%ùs   ‚	A �A ¨A )rô   )rß   s   &r)   Ú
_join_tierró  Û  s   € à�;‰;ÑC©%ÓCÓCÐCr+   c               ó$   € V ^8„  d   QhRRRRRR/# )r!   r@   r   Úsystem_messager$   r%   r_   r'   )r(   s   "r)   r*   r*   à  s'   € ÷ ?~ñ ?~ Sð ?~¸-ð ?~ÐSañ ?~r+   c                ó&  € \        \        V RR4      RR4      p\        V\        4      '       d
   V^ 8”  d   TMRp\        W4      w  rE\	        V4      pVP                  \        4       VP                  \        V 4      4       \        V 4      pRV P                  ;'       g    \        4       9   d   RV9   d	   \        WF&   VP                  \        V 4      4       VP                  \        V 4      4       \        P                   ! 4       p\#        V 4      w  ršpVP                  V	4       \%        V 4      p. pVe   VP                  V4       VP                  \'        WV4      4       V
'       d   VP                  . V
OVOVO4       MVP                  . VOVO4       V.\)        V 4      OpVP                  \+        \-        V 4      R4      4       VP                  \/        V 4      4       VP                  \1        V 4      4       V'       dk   VP3                  \        P4                  R\        P4                  ,           4      pVP                  \        P4                   RV R\        P6                   24       R	\9        V4      R
\9        V4      R\9        V4      /# )aÿ  Assemble the system prompt as three ordered cache tiers: ``stable`` (identity,
guidance and the coding brief), ``context`` (caller ``system_message``, project
context files, workspace snapshot and remaining workspace guidance) and
``volatile`` (skills index, memory, user profile, external memory block,
timestamp line, runtime environment hints).  Worktree-dependent blocks follow project context so a
shared context file can remain in the longest common prefix across worktrees.
Never re-rendered mid-session.Úcontext_compressorNrè  r	  z- hermes-agent:r–   z> rL   ÚstableÚcontextÚvolatile)rM   r0   r¡   r¡  r�   rE   r   rà  r±  r  rñ   Úsetr   r¸  r&  rò   Úbuild_environment_hintsrÙ  rá  rí  r˜  r´   r‹   rB  rŠ  rK   ÚRUNTIME_ENVIRONMENT_HEADINGÚRUNTIME_ENVIRONMENT_ENDró  )r@   rõ  Ú_cc_lenÚ_ctx_lenÚstable_partsÚ_soul_loadedÚ_help_guidance_slotÚskills_promptÚenvironment_hintsÚcoding_prefix_partsÚcoding_workspace_partsÚcoding_trailing_partsÚpost_workspace_partsÚcontext_partsÚvolatile_partss   &&             r)   Úbuild_system_prompt_partsr  à  s[  € ô ”g˜eÐ%9¸4Ó@ÐBRÐTXÓY€GÜ$ W¬c×2Ò2°wÀ´{‰wÈ€Hä!0°Ó!AÑ€Lô ˜lÓ+ÐØ×ÑÔ<Ô=Ø×Ñœ¨Ó.Ô/Ü" 5Ó)€Mð ˜×.Ñ.×7Ð7´#³%Ô8Ð=NÐR_Ô=_Ü,FˆÑ)Ø×ÑÔ.¨uÓ5Ô6à×ÑÔ(¨Ó/Ô0ô ×3Ò3Ó5ÐÜIVÐW\ÓI]ÑFÐÐ1FØ×ÑÐ+Ô,Ü0°Ó7Ðà!€MàÒ!Ø×Ñ˜^Ô,Ø×ÑÔ,¨U¸lÓKÔLßØ×ÑÐeÐ5ÐeÐ8MÐeÐPdÐeÕfð 	×ÑÐKÐ3ÐKÐ6JÐKÔLð "/Ð F´¸uÓ1EÐ F€Nð ×ÑÔ0Ô1OÐPUÓ1VÐXfÓgÔhð ×ÑÔ.¨uÓ5Ô6Ø×Ñœ/¨%Ó0Ô1÷ à-×5Ñ5´c×6UÑ6UÐW[Ô^a×^}Ñ^}ÕW}Ó~ÐØ×Ñ¤×!@Ñ!@Ð AÀÐFWÐEXÐX\Ô]`×]xÑ]xÐ\yÐzÔ{Ø”j Ó.°	¼:ÀmÓ;TÐV`ÔblÐm{Ób|Ð}Ð}r+   c               ó$   € V ^8„  d   QhRRRRRR/# )r!   r@   r   rõ  r$   r%   r1   r'   )r(   s   "r)   r*   r*   "  s&   € ÷ 	_ñ 	_˜sð 	_°Mð 	_ÈSñ 	_r+   c                óÚ   € \        WR7      pVR,          V n        \        4        F  pV P                  V4       K  	  RP	                  R VR,          VR,          VR,          3 4       4      # )z×Assemble the full prompt; cached on ``agent._cached_system_prompt`` and
only rebuilt after compression.  Tiers are ordered stable -> context ->
volatile so implicit longest-prefix caches keep the unchanged scaffold.©rõ  rø  rL   c              3  ó8   "  € T F  q'       g   K  Vx € K  	  R # 5ir/   r'   rñ  s   & r)   r7   Ú&build_system_prompt.<locals>.<genexpr>+  s   é € Ð^Ñ"X˜QÓ\]—q’qÓ"Xùrð   rù  rú  )r  Ú_cached_system_prompt_staticr   Ú_emit_diagnostic_statusrô   )r@   rõ  rß   r‡   s   &&  r)   r“  r“  "  s_   € ô & eÔK€EØ).¨x­€EÔ&ä,Ö.ˆØ×%Ñ% gÖ.ñ /à�;‰;Ñ^ 5¨¥?°E¸)Õ4DÀeÈJÕFWÑ"XÓ^Ó^Ð^r+   c               ó    € V ^8„  d   QhRRRR/# )r!   r@   r   r%   r«   r'   )r(   s   "r)   r*   r*   .  s   € ÷ -ñ - Cð -¨Dñ -r+   c                óÈ   € RV n         RV n        \        V R4      '       d   V P                  V n        V =V P
                  '       d   V P
                  P                  4        R# R# )u  Force a rebuild on the next turn (after compression): reload memory from
disk and clear the frozen plugin snapshot (previous bytes stashed as the
fail-open fallback) so plugins re-render at the same boundary.

Called after context compression events. Also reloads memory from disk so the rebuilt prompt captures
any writes from this session, and clears the frozen plugin-section snapshot so plugins re-render at the
same boundary (maintainer-directed, #95681 arc): a plugin section is just another prompt block carrying
state â€” freezing it while memory, skills, and guidance refresh would recreate the stale-block disease
inside plugin-land. The previous bytes are stashed so a plugin whose render RAISES falls back to its
last good section instead of vanishing (fail-open guard, not a freeze).
Nr   )r€   r  rƒ   r   r‚   r�  Úload_from_disk)r@   s   &r)   Úinvalidate_system_promptr  .  sY   € ð #'€EÔØ)-€EÔ&ÜˆuÐ?×@Ò@Ø8=×8eÑ8eˆÔ5ØÐ9Ø××ÐØ×Ñ×*Ñ*Ö,ñ r+   Ú	log_labelÚrestorec               ó(   € V ^8„  d   QhRRRRRRRR/# )	r!   r@   r   rõ  r$   r  r1   r%   r«   r'   )r(   s   "r)   r*   r*   C  s*   € ÷ .ñ . Sð .¸-ð .Ð^að .Ðrvñ .r+   c               ó  € \        V RR4      p\        V RR4      p\        V RR4      '       df   \        V\        4      '       dP   V'       dH   \        V\        4      '       d    V'       d   VP                  V4      '       g   \        V RR4      V8X  d   R#  \	        WR7      R,          pV'       d'   VP                  V4      '       d   WPn        RV n        R# RT n        Y0n        R#   \         d    \        P                  R	TR
R7        L4i ; i)aù  Reconstruct ``_cached_system_prompt_static`` for a stored prompt.
Only the full prompt is persisted, so restore / keep-prompt compression /
mid-turn failover to a cache-on provider must rebuild the stable tier to
regain the ``[static, volatile]`` layout.  The rebuilt tier is used ONLY
when the stored prompt literally starts with it; otherwise static stays
None and the stored bytes are sent untouched.  A failed rebuild is memoized
per stored prompt so the retry-loop hot path doesn't redo the file I/O.r€   Nr  Ú_use_prompt_cachingFÚ_static_rebuild_failed_forr  rø  z0static system-prefix reconstruction failed on %sTr  )
rM   r0   r1   rž   r  r  r  rf   r†   r#  )r@   rõ  r  ÚstoredÚexistingÚstatics   &&$   r)   Úreconstruct_static_prefixr!  C  sæ   € ô �UÐ3°TÓ:€FÜ�uÐ<¸dÓC€Hä�EÐ0°%×8Ò8Ü˜&¤#×&Ò&¯fÜ�x¤×%Ò%¯(°v×7HÑ7HÈ×7RÒ7RÜ�5Ð6¸Ó=ÀÔGáðcÜ*¨5ÔPÐQYÕZˆß�f×'Ñ'¨×/Ò/Ø17Ô.Ø/3ˆEÔ,Ùð *.€EÔ&Ø'-Ö$øô ô cÜ�‰ÐGÈÐ]aˆÖbðcús   Â1C& ÃC& Ã&#DÄDc               ó    € V ^8„  d   QhRRRR/# rv   r'   )r(   s   "r)   r*   r*   `  s   € ÷ Bñ B¨3ð B°3ñ Br+   c                ó   € V P                   '       g   R# \        P                  ! V P                    Uu. uFI  pRVR,          R,          RVR,          P                  RR4      RVR,          P                  R/ 4      RR/NKK  	  upR	R
7      # u upi )z/JSON tool definitions in the trajectory format.z[]rÿ   ÚfunctionÚdescriptionr-   Ú
parametersÚrequiredNF)Úensure_ascii)ÚtoolsÚjsonÚdumpsrO   )r@   Úts   & r)   Úformat_tools_for_system_messager-  `  s“   € à�;�;ˆ;ÙÜ�:Š:ð !&§¢ó-ñ !,˜1ð   *¥¨fÕ 5°}ÀaÈ
Åm×FWÑFWÐXeÐgiÓFjØ$ a¨
¥m×&7Ñ&7¸ÀbÓ&IØ" Dó*ñ !,ñ-ð <AôBð Bùò -s   ³AB)ÚtrueÚalwaysÚyesÚon)ÚfalseÚneverÚnoÚoffr/   )r“  r  r-  r  rI  r­   )cÚ__doc__Ú
__future__r   r*  Úloggingr[   rÇ   Úpathlibr   Útypingr   r   r   r   r   Úagent.delegation_contextr	   r®  r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r@   r   rò   Úagent.runtime_cwdr   r   rÓ   r   r   Úutilsr   Ú	getLoggerÚ__name__r†   ÚcompileÚ	MULTILINErŸ   rN   Úfromkeysr:   r>   rU   rZ   r]   rl   ri   rh   r‹   r„   r­   r´   rÍ   rx   rÙ   ry   rù   r  r&  r4  r:  rB  rM  rU  rI  rJ  rt  rŠ  r˜  r¡  r±  r¸  r»  rÃ  rÊ  rÑ  rÙ  rá  rí  ró  r  r“  r  r!  r-  Ú__all__r'   r+   r)   Ú<module>rD     s©  ðñõ #ã Û Û 	Û 	Ý ß 3Õ 3å 6÷÷ ÷ ÷ ó õ (ß Dß EÝ !à	×	Ò	˜8Ó	$€ØŸ:š:Ø}Ø‡L�LóÐ ð @�—‘Ð>ÀÓEÐÈÏÉÐWvÐx}ÓI~Ð€õ9õGð"2ð õ/õõ7õ
õõ2Xõ6\õ
$õ.Zõbõ<9õ
õ;õ6Aõ &õ6õ0*õ
%õPõ*Kõ"õõõ`õ6õ8[õõ:õõõ$Bõ"8õ&õ@õ"iõ D÷
?~÷D	_õ-ñ*.Ðdm÷ .ð .õ:Bò‚r+   