+
    lHàj~K  ã            
       óz  € R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ]P                  ! R4      t	]P                  ! 4       tR R ltR R ltR	 R
 ltR tR R ltR R ltR R ltRRRRRRRRRR/R R lltR R ltR R ltR R  ltR! R" ltR# R$ ltR1R% R& lltR' R( ltR) R* ltR+ R, ltR- R. ltR/ R0 ltR# )2z¼Live-agent tool-list maintenance after MCP (re)discovery: refreshing an
AIAgent's tools/tool names, preserving the cached tools[] prefix across rebuilds,
and re-injecting post-build tools.N)ÚOptional)Ú_coreztools.mcp_toolc                ó0   € V ^8„  d   QhR\         R\        /# )é   Útool_defÚreturn)ÚdictÚstr)Úformats   "Ú9/home/ubuntu/.hermes/hermes-agent/tools/mcp_tool_agent.pyÚ__annotate__r      s   € ÷ <ñ <œð <¤ñ <ó    c                 óX   € V P                  R 4      ;'       g    / P                  RR4      # )ÚfunctionÚnameÚ )Úget)r   s   &r   Ú	_def_namer      s&   € Ø�L‰L˜Ó$×*Ð*¨×/Ñ/°¸Ó;Ð;r   c                ó$   € V ^8„  d   QhR\         /# ©r   r   ©Úlist)r
   s   "r   r   r      s   € ÷ 5ñ 5œtñ 5r   c                 óB   € \        \        V R R4      ;'       g    . 4      # )ÚtoolsN)r   Úgetattr)Úagents   &r   Ú_agent_tool_defsr      s   € Ü”˜˜w¨Ó-×3Ð3°Ó4Ð4r   c                ó$   € V ^8„  d   QhR\         /# r   r   )r
   s   "r   r   r      s   € ÷ Nñ Nœtñ Nr   c                óp   € \        \        \        V 4      4       Uu. uF  q'       g   K  VNK  	  up# u upi )zANames of ``agent.tools`` in wire order (unnamed entries skipped).)Úmapr   r   )r   r   s   & r   Úagent_tool_namesr       s-   € ä ¤Ô,<¸UÓ,CÔDÓMÑD�TË�DˆDÑDÑMÐMùÒMs   œ	3ª3c                ó´   € \        V RR4      p\        V RR4      pVf   Ve5   Ve   TMTpVe   ^ RIHp V! V\        V RR4      4      pW4uV n        V n        W43# )zÑExplicit reloads pass freshly-resolved toolsets (so a server just ENABLED in config is
picked up) and the agent's selection is updated to match; automatic paths pass nothing
and reuse the build-time selection.Úenabled_toolsetsNÚdisabled_toolsets)Úsession_disabled_toolsetsÚplatform)r   Útoolsetsr$   r"   r#   )r   Úenabled_overrideÚdisabled_overrideÚenabledÚdisabledr$   s   &&&   r   Ú_resolve_refresh_toolsetsr+       su   € ô �eÐ/°Ó6€GÜ�uÐ1°4Ó8€HØÒ#Ð'8Ò'DØ&6Ò&BÑ"ÈˆØÒ(Ý:Ù0Ð1BÄGÈEÐS]Ð_cÓDdÓeˆHØ:AÐ7ˆÔ Ô 7ØÐÐr   c                ó0   € V ^8„  d   QhR\         R\        /# )r   Únew_defsr   )r   Úbool)r
   s   "r   r   r   /   s   € ÷ ñ ´ð ¼ñ r   c                ób   €  R pV! \        V 4      4      V! V4      8g  #   \         d     R# i ; i)z‹Byte-level diff of the serialized tool arrays (dynamic schemas change CONTENT under
stable names); False if either side fails to serialize.c                 ó>   € \         P                  ! V R R\        R7      # )T)Ú	sort_keysÚ
separatorsÚdefault)Ú,Ú:)ÚjsonÚdumpsr	   )Údefss   &r   Ú<lambda>Ú,_tool_defs_content_changed.<locals>.<lambda>3   s   € œDŸJšJ t°tÈ
Ô\_Õ`r   F)r   Ú	Exception)r   r-   Údumps   && r   Ú_tool_defs_content_changedr=   /   s8   € ðÙ`ˆÙÔ$ UÓ+Ó,±°X³Ñ>Ð>øÜô Úðús   ‚ Ÿ.­.c                ó<   € V ^8„  d   QhR\         R\        R\        /# )r   r-   Ú	new_namesr   ©r   ÚsetÚtuple)r
   s   "r   r   r   9   s&   € ÷ ]ñ ]¬ð ]¼#ð ]Ä%ñ ]r   c                 ó–   € ^ RI Hp V! V 4      pV'       g   W3# V Uu. uF  p\        V4      V9  g   K  VNK  	  upW$,
          3# u upi )é    )Úagent_tool_drops)r&   rE   r   )r   r-   r?   rE   ÚdropsÚentrys   &&&   r   Ú_drop_session_toolsrH   9   sI   € Ý)Ù˜UÓ#€EßØÐ"Ð"Ù'ÓI™x�e¬9°UÓ+;À5Ñ+H�EˆE™xÑIÈ9ÕK\Ð\Ð\ùÒIs
   žAµAc                ó˜   € V ^8„  d   QhR\         R\        R\        R\        R\        R\        \        ,          R\        \        ,          /# )r   r-   r?   Úsnapshot_generationÚstaged_engine_namesÚcontent_awareÚprefix_registeredr   )r   rA   Úintr.   r   )r
   s   "r   r   r   A   sN   € ÷ #ñ #Üð#Ü&)ð#ÜCFð#äð#ä-1ð#äFNÌsÅmð#äX`ÔadÕXeñ#r   c               ó„  € \         ;_uu_ 4        \        V RR4      p\        V\        4      '       d   TMRpW78  d    RRR4       R# \	        V 4      pV U	u0 uF  p	\        V	4      kK  	  p
p	Ve   \        W�V4      w  r\        WV4      w  r\        Ws4      V n	        W*8X  d%   V'       d   \        W4      '       g    RRR4       R# Wn        W n        \        V RR4      p\        V\        4      '       d"   VP                  4        VP                  V4       W*,
          uuRRR4       # u up	i   + '       g   i     R# ; i)a	  Single atomic read-diff-publish under ``_agent_tools_lock`` so ``added`` matches what
was published and a stale (older-generation) rebuild can't overwrite a newer one. Returns
the added names, or None when nothing was published (unchanged, or a newer snapshot won).Ú_tool_snapshot_generationNÚ_context_engine_tool_nameséÿÿÿÿ)Ú_agent_tools_lockr   Ú
isinstancerN   r   r   Ú_merge_preserving_prefixrH   ÚmaxrP   r=   r   Úvalid_tool_namesrA   ÚclearÚupdate)r   r-   r?   rJ   rK   rL   rM   Úpublished_genÚcurrent_defsÚtÚcurrentÚengine_namess   &&&$$$$     r   Ú_publish_tool_snapshotr_   A   s  € ÷ 
Ö	ä Ð'BÀBÓGˆÜ)3°MÄ3×)GÒ)G™ÈRˆØÔ.Ø÷ 
Ñ	ô (¨Ó.ˆÙ)5Ó6© A”9˜Q–<©ˆÐ6ØÒ(Ü":¸<ÐSdÓ"eÑˆHÜ1°%À9ÓMÑˆä*-¨mÓ*QˆÔ'ð Ô¯Ô;UÐV[×;fÒ;fØ÷! 
Ñ	ð" ŒØ!*Ôä˜uÐ&BÀDÓIˆÜ�l¤C×(Ò(Ø×ÑÔ Ø×ÑÐ 3Ô4ØÕ"÷1 
Ò	ùò 7÷ 
×	Ð	ús0   �/D.ÁD.ÁD)Á+?D.Â+D.ÃAD.Ä)D.Ä.D?	r'   r(   Ú
quiet_modeTrL   FÚpreserve_prefixc                óH   € V ^8„  d   QhR\         R\         R\         R\        /# )r   r`   rL   ra   r   )r.   rA   )r
   s   "r   r   r   b   s,   € ÷ 3ñ 3ÜIMð3äð3ä26ð3äCFñ3r   c          
     óä  € ^ RI Hp ^ RIHp \	        WV4      w  r‰VP
                  p
\        V! W‰VR7      ;'       g    . 4      pV Uu0 uF  p\        V4      kK  	  pp\        WV4      p\        WV4       RpV'       d,    VP                  4        Uu0 uF  pVP                  kK  	  ppMRp\        WWÚWäVR7      pVf   \        4       # \        V 4       V# u upi u upi   \         d     LAi ; i)u£  Re-derive an already-built agent's tool snapshot from the live registry; returns the
newly-added tool names (empty when unchanged). The agent snapshots ``agent.tools`` at build
time, so servers that connect later (slow OAuth, ``/reload-mcp``) are invisible until
rebuilt. Shared by the TUI RPC, gateway reload, late-binding thread and between-turns
refresh: respects the toolset filter, diffs by tool NAME (a count compare misses an
equal-size swap) and, for ``content_aware`` callers, by serialized schema bytes, re-injects the memory-provider / context-engine tools ``agent_init``
appends after ``get_tool_definitions`` plus guarded session capabilities, and publishes
``(tools, valid_tool_names)`` together.

``preserve_prefix``: for rebuilds inside a live conversation the tool array is a cached
request prefix and any moved byte re-prefills the whole history â€” existing tools keep their
slot and the schema bytes already sent (a refreshed description is rendered ahead of the
conversation), a still-registered tool whose ``check_fn`` merely flapped is carried forward
(``check_fn`` gates exposure, never invocation), a deregistered tool is dropped, new tools
append at the tail. The caller owns the prompt-cache contract.

With ``preserve_prefix`` off (explicit ``/reload-mcp``, and a rebuild before the
first turn) a same-name schema change is published. The caller has already
accepted the cache break, or nothing has been cached yet.)Úget_tool_definitions©Úregistry)r"   r#   r`   NT)rJ   rK   rL   rM   )Úmodel_toolsrd   Útools.registryrf   r+   Ú_generationr   r   Ú_reinject_post_build_toolsÚ"_reinject_authorized_dynamic_toolsÚget_all_entriesr   r;   r_   rA   Úpersist_agent_tool_names)r   r'   r(   r`   rL   ra   rd   rf   r)   r*   rJ   r-   r\   r?   rK   rM   rG   Úaddeds   &$$$$$            r   Úrefresh_agent_mcp_toolsro   b   sÿ   € õ, 1Ý'Ü1°%ÐK\Ó]Ñ€Gð #×.Ñ.ÐÜÑ(¸'ÐjtÔu×{Ð{Ðy{Ó|€HÙ'/Ó0¡x !”˜1–¡x€IÐ0ä4°UÀiÓPÐÜ& u¸	ÔBð (,Ðßð	Ø9A×9QÑ9QÔ9SÓ TÑ9S° §¤Ñ9SÐÐ TÐð ˆÜ"Ø˜Ø/Ð`qôs€Eð ‚}Ü‹uˆÜ˜UÔ#Ø€Lùò- 1ùò !UøÜô 	Ùð	ús*   ÁCÂC! ÂCÂ(C! ÃC! Ã!C/Ã.C/c                ó   € V ^8„  d   QhRR/# ©r   r   N© )r
   s   "r   r   r   ˜   s   € ÷ ñ  4ñ r   c                 ó:   € ^ RI Hp  ^ RIHp V! 4        V ! 4        R# )zÔExplicit ``/reload-mcp`` hatch out of the tools[] freeze: drop the ``check_fn`` verdict
cache AND the ``get_tool_definitions`` memo (keyed on registry generation, so it would
otherwise replay the stale verdicts).)Ú_clear_tool_defs_cache)Úinvalidate_check_fn_cacheN)rg   rt   rh   ru   )rt   ru   s     r   Úreprobe_tool_availabilityrv   ˜   s   € õ 3Ý8ÙÔÙÖr   c                ó$   € V ^8„  d   QhR\         /# r   ©r	   )r
   s   "r   r   r   ¢   s   € ÷ Iñ Iœ#ñ Ir   c                 ó�   € ^ RI Hp  ^ RIHp V! 4       pVP	                  R4      ;'       g    VP	                  R4      ;'       g    T # )z®The code identity a tools[] pin was built by (checkout/build sha, else the release version).
Cached per process: an updated checkout only reaches a process through a restart.)Ú__version__)Úget_code_identityÚshaÚversion)Ú
hermes_clirz   Úhermes_cli.build_infor{   r   )rz   r{   Úidentitys      r   Útool_pin_versionr�   ¢   s:   € õ 'Ý7Ù Ó"€HØ�<‰<˜Ó×HÐH (§,¡,¨yÓ"9×HÐH¸[ÐHr   c                ó   € V ^8„  d   QhRR/# rq   rr   )r
   s   "r   r   r   «   s   € ÷ 
Bñ 
B tñ 
Br   c           	     ó   € \        V RR4      p\        V RR4      pV'       d	   V'       g   R#  VP                  VR\        4       R\        V 4      /4       R#   \         d    \
        P                  RRR7        R# i ; i)	z°Best-effort: write ``agent.tools`` to the session row (freeze pin). The full definitions,
keyed by the code that built them: another process or surface derives different bytes.Ú_session_dbNÚ
session_idr}   r   ztool_names persist skippedT©Úexc_info)r   Úupdate_session_tool_namesr�   r   r;   ÚloggerÚdebug)r   Údbr…   s   &  r   rm   rm   «   su   € ô 
�˜ tÓ	,€BÜ˜ ¨dÓ3€Jß—ZÙðBØ
×$Ñ$ Z°)Ô=MÓ=OÐQXÔZjÐkpÓZqÐ1rÖsøÜô BÜ�‰Ð1¸Dˆ×AðBús   ®'A Á"A=Á<A=c                ó$   € V ^8„  d   QhR\         /# r   )rA   )r
   s   "r   r   r   ¸   s   € ÷ 	Xñ 	X¤cñ 	Xr   c                ór   € ^ RI Hp ^ RIHp \	        V RR4      pVe   . VOVOpV! V\	        V RR4      R4      # )zûTool names this agent's toolset selection allows before ``check_fn``: all a pin may carry
forward. A client-surface toolset counts as allowed (only its client can add it, so its absence
here is no config choice); ``disabled_toolsets`` still strips it.)Ú_select_tool_names)ÚCLIENT_SURFACE_TOOLSETSr"   Nr#   T)rg   rŽ   r&   r�   r   )r   rŽ   r�   r)   s   &   r   Ú_config_permitted_namesr�   ¸   sI   € õ /Ý0Ü�eÐ/°Ó6€GØÒØ6�GÐ6Ð5Ð6ˆÙ˜g¤w¨uÐ6IÈ4Ó'PÐRVÓWÐWr   c                ó<   € V ^8„  d   QhR\         R\        R\         /# )r   ÚmergedÚcarriedr   ©r   rA   )r
   s   "r   r   r   Ä   s&   € ÷ Rñ R¤dð R´Sð R¼Tñ Rr   c                óò   € ^ RI Hp V  Uu0 uF  p\        V4      kK  	  ppV  Uu. uFA  p\        V4      V9  g-   \        V4      V9  g   V\        V4      ,          ! W44      f   K?  VNKC  	  up# u upi u upi )z¦A carried tool also passes the session-level schema gates the fresh build applied
(``browser_exec`` needs ``terminal`` in the same array), judged on the merged array.)Ú_DYNAMIC_SCHEMA_REWRITERS)rg   r–   r   )r’   r“   r–   r\   Ú	availables   &&   r   Ú_drop_gated_carried_toolsr˜   Ä   su   € õ 6Ù'-Ó.¡v !”˜1–¡v€IÐ.Ùó R‘v�!¤¨1£°WÔ!<Ä	È!ÃÐTmÔ@mØ(¬°1«Ö6°qÓD÷ ˆA‘vñ Rð Rùò /ùòRs   ‹A/¥<A4Á&A4c                ó$   € V ^8„  d   QhR\         /# r   )rB   )r
   s   "r   r   r   Í   s   € ÷ Iñ I¼ñ Ir   c                óx  aaaa€ \        V \        4      '       d-   V P                  R4      ;'       g    . V P                  R4      3MV R3w  r4\        V\        4      '       g   . R. 3# ^ RIHo VRJ;'       d    V\        4       8H  oVVVV3R lpTS\        WS4       Uu. uF  qf'       g   K  VNK  	  up3# u upi )zî(pinned, same_code, definitions) for a tools[] pin, either shape: a pin from the SAME code keeps
its bytes; otherwise (``hermes update``, a legacy name list) each tool takes this process's
definition (``fresh``, else its registry schema).r   r}   NFre   c                 ót  <€ \        V \        4      '       d   T M"\        V \        4      '       d   \        V 4      MR p\        V \        4      '       d   S'       g	   S'       d   V # VS9   d
   SV,          # V'       d   SP	                  V4      MR pV'       d!   RRR/ VP
                  CRVP                  /C/# R # )NÚtyper   r   )rT   r	   r   r   Ú	get_entryÚschemar   )Úitemr   rG   ÚfreshÚ
keep_bytesrf   Ú	same_codes   &  €€€€r   Ú_pinned_defÚ&_pinned_tool_defs.<locals>._pinned_def×   s’   ø€ Ü! $¬×,Ò,‰tÄZÐPTÔVZ×E[ÒE[´)¸D´/ÐaeˆÜ�dœD×!Ò!§y·JØˆKØ�5Œ=Ø˜•;Ðß,0�×"Ñ" 4Ô(°dˆßY^�˜
 JÐ0T°5·<±<Ð0TÀÈÏÉÑ0TÐUÐhÐdhÐhr   )rT   r   r   r   rh   rf   r�   r   )	Úsavedr    r¡   Úpinnedr}   r£   Údrf   r¢   s	   &ff    @@r   Ú_pinned_tool_defsr¨   Í   s³   û€ ô KUÐUZÔ\`×JaÒJa�u—y‘y Ó)×/Ð/¨R°·±¸9Ó1EÑFÐhmÐosÐgt�O€FÜ�fœd×#Ò#Ø�5˜"ˆ}ÐÝ'Ø˜tÐ#×EÐE¨Ô3CÓ3EÑ(E€I÷ið ið �9¬#¨kÔ*BÓHÑ*B QÃaŸq˜qÑ*BÑHÐHÐHùÒHs   Â	B7Â-B7c                ó$   € V ^8„  d   QhR\         /# r   r   )r
   s   "r   r   r   ã   s   € ÷ <ñ <œtñ <r   c                ó,   € \        V / RR7      ^,          # )zÄ``saved``'s tool definitions as a fresh agent restores them, for an estimate with no agent built:
pinned definitions keep their bytes, a legacy name list takes each tool's current registry schema.T)r¡   )r¨   )r¥   s   &r   Úpinned_tool_defsr«   ã   s   € ô ˜U B°4Ô8¸Õ;Ð;r   c                ó$   € V ^8„  d   QhR\         /# r   ©r.   )r
   s   "r   r   r   é   s   € ÷  ñ  ¬tñ  r   c           	     óJ  a€ \        T\        V 4       Uu/ uF  p\        V4      VbK  	  up4      w  r4pV'       g   R# ^ RIHp \        V 4      pV Uu/ uF  p\        V4      VbK  	  ppVP                  4        U	u0 uF  q™P                  kK  	  p
p	V Uu0 uF2  p\        V4      V9  g   K  \        V4      V
9   g   K'  \        V4      kK4  	  ppYÌ'       d   \        V 4      M	\        4       ,          pV Uu. uF'  p\        V4      V9   g   \        V4      V9   g   K%  VNK)  	  ppV Uu0 uF  p\        V4      kK  	  upoVP                  V3R lV 4       4       \        WÜ4      pV Uu0 uF  p\        V4      kK  	  pp\        WV4       \        WV4      w  rÞW×8g  pV'       d$   \        ;_uu_ 4        WÐn        Wàn        RRR4       V'       d   V\!        V4      8w  d   \#        V 4       V# u upi u upi u up	i u upi u upi u upi u upi   + '       g   i     LX; i)aØ  Fold a freshly built agent's ``tools`` onto the session's pin; True if changed.
A fresh AIAgent (gateway cache eviction, ``--resume`` in a new process, a surface hop) has no
predecessor to preserve, so the pin stands in. Pinned by the SAME code, a tool still available
here keeps its pinned BYTES, whatever this process derives for it (tool_search's per-surface
catalog, per-surface dynamic parameters, the ``-q`` footprint): tools[] heads every request.
Pinned by other code (``hermes update``, a legacy name list) a tool's contract may have moved,
so each takes its current definition. A pinned tool this process did not build is carried
only while its toolset config allows it here; deregistered tools drop, new tools append.Fre   c              3   óL   <"  € T F  p\        V4      S9  g   K  Vx € K  	  R # 5i©N)r   )Ú.0r\   Úpinned_namess   & €r   Ú	<genexpr>Ú,restore_agent_tool_prefix.<locals>.<genexpr>ý   s   øé € ÐL™Z˜¬9°Q«<¸|Ñ+K—!’!›Zùs   ƒ$š
$N)r¨   r   r   rh   rf   rl   r   r�   rA   Úextendr˜   rk   rH   rS   r   rW   r   rm   )r   r¥   r\   r¦   r¢   Úpinned_defsrf   Ú
fresh_defsr    rG   Úregistered_namesr§   r“   r’   Úmerged_namesÚchangedr²   s   &&              @r   Úrestore_agent_tool_prefixr»   é   sÉ  ø€ ô &7°uÔXhÐinÔXoÓ>pÑXoÐST¼yÈ»|ÈQºÑXoÑ>pÓ%qÑ"€F�{ßÙÝ'Ü! %Ó(€JÙ&0Ó1¡j ŒY�q‹\˜1Š_¡j€EÐ1Ø08×0HÑ0HÔ0JÓKÑ0J uŸ
œ
Ñ0JÐÐKÙ%0Ós¡[ ´I¸a³LÈÑ4MŒ|ÔR[Ð\]ÓR^ÐbrÑRrŒ|Œy˜Ž|¡[€GÐsØ¶Ô& uÔ-¼c»eÕC€GÙ$ÓY™�A¬	°!«¸Ô(=ÄÈ1ÃÐQXÑAX�aˆa™€FÐYÙ*0Ó1©& Q”I˜a–L©&Ñ1€LØ
‡M�MÔL™ZÓLÔLÜ& vÓ7€FÙ*0Ó1©& Q”I˜a–L©&€LÐ1Ü& u°lÔCÜ.¨u¸lÓKÑ€FØÑ"€GßßÖØ ŒKØ%1Ô"÷ ÷ ˜¤$ v£,Ô.Ü  Ô'Ø€Nùò/ ?qùò
 2ùÚKùÚsùâYùÚ1ùò 2÷
 ×úsG   •G/
ÁG4Á<G9ÂG>Â-G>Â?G>Ã7"HÄHÄ*HÅ+HÆ5HÈH"	c          
      ój   € V ^8„  d   QhR\         R\         R\        R\        \         \        3,          /# )r   r[   r-   r¸   r   r@   )r
   s   "r   r   r     s6   € ÷ 2ñ 2¬4ð 2¼4ð 2ÔSVð 2Ô[`ÔaeÔgjÐajÕ[kñ 2r   c                óž  € ^ RI Hp V Uu/ uF"  p\        V4      '       g   K  \        V4      VbK$  	  pp. pV  FM  p\        V4      pVP                  VR4      pVf   Ws9   g   V'       g   K4  Wr9   g   K<  VP	                  V4       KO  	  VP                  VP                  4       4       Yf U	u0 uF  p	\        V	4      kK  	  up	3# u upi u up	i )a¦  Fold a fresh tool snapshot into a live one without moving existing bytes. Ordered by
``current_defs`` (the cached request prefix): a name already sent keeps its slot and the
schema bytes already sent; a name only in the live list is kept if still registered
(``check_fn`` flapped), else dropped; a name only in the fresh list is appended at the tail.

A refreshed schema is not substituted in place. Tool JSON is rendered ahead of the
conversation, so one changed description means the next prompt no longer starts with the
previous one and a local prefix cache reads the whole prompt again. An explicit reload
(``preserve_prefix`` off) still takes the fresh schemas.

The carried entry freezes the whole schema (description and parameters), not just prose: if a
server changes a live tool's input schema under the same name, the model keeps calling with
the old shape and the server rejects those calls until ``/reload-mcp`` or compaction.

The bridge tools are synthesized by ``assemble_tool_defs``, never registered, and a fresh
snapshot omits them when the deferred set shrinks under the activation threshold: they
keep their slot regardless (search reads the live catalog at dispatch).)ÚBRIDGE_TOOL_NAMESN)Útools.tool_search_catalogr¾   r   ÚpopÚappendrµ   Úvalues)
r[   r-   r¸   r¾   rG   r    r’   r   Úreplacementr\   s
   &&&       r   rU   rU     sµ   € õ$ <Ù2:ÓO±(¨¼iÈ×>NÔ$ŒY�uÓ˜uÒ$±(€EÐOØ€FÛˆÜ˜ÓˆØ—i‘i  dÓ+ˆØÒ" dÔ&?ÇDÁDÈTÖMeØ�M‰M˜%Ö ñ	 ð
 ‡M�M�%—,‘,“.Ô!Ø¨&Ó1©& Q”I˜a–L©&Ñ1Ð1Ð1ùò Pùò 2s   ‹C£CÂ-C
c                ó4   € V ^8„  d   QhR\         R\        RR/# )r   Ú
tools_listÚname_setr   Nr”   )r
   s   "r   r   r   *  s"   € ÷ 
.ñ 
.¼$ð 
.Ì#ð 
.ÐRVñ 
.r   c                ó  € ^ RI HpHpHp V Uu. uF  p\	        V4      V8w  g   K  VNK  	  upVR&   VP                  V4       V! V 4      '       d*   VP                  V! 4       4       VP                  V4       R# R# u upi )a
  ``message_agent`` is injected by an auth gate, never registered, so a registry-derived
rebuild drops it. Scrub any stale copy from the STAGED pair and re-add it only when the live
gate re-authorizes, so the publisher exposes a coherent ``(tools, valid_tool_names)``.)ÚMESSAGE_AGENT_TOOL_NAMEÚmessage_agent_authorizedÚmessage_agent_tool_schema:NNNN)Útools.bot_mode_dmrÈ   rÉ   rÊ   r   ÚdiscardrÁ   Úadd)r   rÅ   rÆ   rÈ   rÉ   rÊ   rG   s   &&&    r   rk   rk   *  sv   € ÷ oÑná(2Ób©
˜u´iÀÓ6FÐJaÑ6a—U�U©
Ñb€Jˆq�MØ×ÑÐ,Ô-Ù ×&Ò&Ø×ÑÑ3Ó5Ô6Ø�‰Ð,Ö-ñ 'ùò cs
   �A<¦A<c                ó<   € V ^8„  d   QhR\         R\        R\        /# )r   rÅ   rÆ   r   r”   )r
   s   "r   r   r   7  s!   € ÷ )ñ )´$ð )Ä#ð )Ì#ñ )r   c                ó  a aaa
€ R VV3R llo
R V 3R llp\        S RR4      p V! RR4      pVe<   ^ R	IHp V! V\        S R
R4      RS9   R7      '       d   V! 4        F  pS
! V4       K  	  \        4       p T! RR4      p	Te   RT9   d%   T	e!   TP                  T
3R lT	! 4        4       4       T#   \         d    \        P                  RRR7        Lii ; i  \         d    \        P                  RRR7        T# i ; i)ah  Append memory-provider and context-engine tools onto the caller's staged ``tools_list``
/ ``name_set`` (never the live agent attributes), mirroring ``agent_init``'s post-build
injection. Idempotent and fail-soft. Returns the context-engine routing names THIS rebuild
appended: a name already owned by a registry/plugin tool is not claimed, matching agent_init.c                ó$   € V ^8„  d   QhR\         /# r   r­   )r
   s   "r   r   Ú0_reinject_post_build_tools.<locals>.__annotate__<  s   € ÷ ñ œñ r   c                 óÊ   <€ \        V \        4      '       d   V P                  R R4      MRpV'       d   VS9   d   R# SP                  RRRV /4       SP	                  V4       R# )r   r   Frœ   r   T)rT   r   r   rÁ   rÍ   )rž   r   rÆ   rÅ   s   & €€r   Ú_addÚ(_reinject_post_build_tools.<locals>._add<  sT   ø€ Ü)3°F¼D×)AÒ)Aˆv�z‰z˜& "Ô%Àrˆß�t˜xÔ'ÙØ×Ñ˜6 :¨z¸6ÐBÔCØ�‰�TÔÙr   c                ó0   € V ^8„  d   QhR\         R\         /# )r   ÚattrÚmethodrx   )r
   s   "r   r   rÑ   D  s   € ÷ 4ñ 4œSð 4¬#ñ 4r   c                 ór   <€ \        \        SV R 4      ;'       g    R VR 4      p\        V4      '       d   V# R # r°   )r   Úcallable)rÖ   r×   Úgetterr   s   && €r   Ú_schema_getterÚ2_reinject_post_build_tools.<locals>._schema_getterD  s7   ø€ Üœ ¨¨dÓ3×;Ð;°t¸VÀTÓJˆÜ! &×)Ò)ˆvÐ3¨tÐ3r   r"   NÚ_memory_managerÚget_all_tool_schemas)Úmemory_provider_tools_enabledr#   Úmemory)Úmemory_tool_presentz)Memory-provider tool re-injection skippedTr†   Úcontext_compressorÚget_tool_schemasÚcontext_enginec              3   óV   <"  € T F  pS! V4      '       g   K  VR ,          x € K   	  R# 5i)r   Nrr   )r±   ÚsrÓ   s   & €r   r³   Ú-_reinject_post_build_tools.<locals>.<genexpr>]  s    øé € Ð&S¹-°QÉ4ÐPQÏ7¤y q¨§y¢y»-ùs   ƒ)˜)z(Context-engine tool re-injection skipped)r   Úagent.memory_manager_toolsrß   r;   r‰   rŠ   rA   rY   )r   rÅ   rÆ   rÛ   r)   Úget_mem_schemasrß   rž   rK   Úget_schemasrÓ   s   fff       @r   rj   rj   7  s  û€ ÷
ñ ÷4ð 4ô �eÐ/°Ó6€Gð	QÙ(Ð):Ð<RÓSˆØÒ&ÝPÙ,ØœW UÐ,?ÀÓFÐ\dÐhpÑ\p÷ró rá-Ö/�FÙ˜–Lñ 0ô  #›uÐðPÙ$Ð%9Ð;MÓNˆØŠOÐ/°7Ô:ÀÒ@Wà×&Ñ&Ô&S¹+¼-Ó&SÔSð Ðøô ô QÜ�‰Ð@È4ˆÖPðQûô ô PÜ�‰Ð?È$ˆÕOØÐðPús(   ¦B3 ³;B3 Á98C Â3"CÃCÃ"DÄ D)F)Ú__doc__Úloggingr6   Ú	threadingÚtypingr   Útools.mcp_tool_commonr   Ú	getLoggerr‰   ÚLockrS   r   r   r    r+   r=   rH   r_   ro   rv   r�   rm   r�   r˜   r¨   r«   r»   rU   rk   rj   rr   r   r   Ú<module>rò      sÌ   ðñ&ó Û Û Ý Ý 'à	×	Ò	Ð+Ó	,€ð
 —N’NÓ$Ð õ<õ5õNò
õõ]õ#ðB3Ø#ð3Ø7;ð3ØPTð3àð3à9>÷3õlõIõ
Bõ	XõR÷Iõ,<õ õF2õ<
.÷)r   