+
    lHàjZ  ã                   óŽ  € R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHtHt ]P                  ! R4      t
 ! R R4      t]! 4       t]! 4       tRR R lltRtR	 R
 ltRtR R lt]P(                  ! R]P*                  4      tR R ltR R ltR R ltR R lt]^3R lt]! 0 Rm4      t]! 0 R m4      tR!R R llt R R lt!R R lt"R# )"z¨Small pure helpers shared by the tools.mcp_tool_* modules: SDK 1.x/2.x field access,
error-text sanitising, numeric/bool coercion, timeouts and jitter. No origin state.N)ÚAnyÚOptionalztools.mcp_toolc                   ó:   a € ] tR t^t o RtRtV 3R lR ltRtV tR# )Ú_OriginProxya]  Attribute proxy for ``tools.mcp_tool`` resolved at access time. The split modules read
origin state (``_servers``, ``_lock``, SDK symbols, patchable helpers) through this so
``mock.patch("tools.mcp_tool.X")`` and origin-side rebinds stay effective, and so no split
module needs the origin imported first (the origin imports them while initialising).c                ó    <€ V ^8„  d   QhRS[ /# )é   Úname©Ústr)ÚformatÚ__classdict__s   "€Ú:/home/ubuntu/.hermes/hermes-agent/tools/mcp_tool_common.pyÚ__annotate__Ú_OriginProxy.__annotate__   s   ø€ ÷ 'ñ '¡ñ 'ó    c                ó$   € ^ RI Hp \        W!4      # )é    )Úmcp_tool)Útoolsr   Úgetattr)Úselfr   r   s   && r   Ú__getattr__Ú_OriginProxy.__getattr__   s   € Ý"Ü�xÓ&Ð&r   © N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú	__slots__r   Ú__static_attributes__Ú__classdictcell__)r   s   @r   r   r      s   ø‡ € ñ\ð
 €I÷'ö 'r   r   c                ó0   € V ^8„  d   QhR\         R\         /# )r   ÚsnakeÚcamelr	   )r   s   "r   r   r      s   € ÷ 3ñ 3œ#ð 3¤cñ 3r   c                ór   € \        W\        4      pV\        J d   \        W\        4      pV\        J d   V# T# )uù   Read an MCP model field across the 1.x -> 2.x rename to snake_case. Pydantic aliases
don't apply to attribute access, so ``getattr(result, "isError", False)`` silently returns
the default on 2.x â€” failed calls read as successful, schemas as empty.)r   Ú_MISSING)Úobjr#   r$   ÚdefaultÚvalues   &&&& r   Ú	mcp_fieldr*      s6   € ô �C¤Ó)€EØ”ÓÜ˜¤HÓ-ˆØœxÓ'ˆ7Ð2¨UÐ2r   i,  c                ó0   € V ^8„  d   QhR\         R\        /# )r   ÚconfigÚreturn)ÚdictÚfloat)r   s   "r   r   r   ,   s   € ÷ !ñ !¤$ð !¬5ñ !r   c                óÎ   € V P                  R4      pVe   V#  ^ RIHp V! R\        R7      pVe   V#  \        #   \         d     \
        P                  RRR7        \        # i ; i)z­Per-server tool-call timeout. Precedence: ``mcp_servers.<name>.timeout`` >
``timeouts.mcp.tool_call`` > the 300s default; values are platform-clamped by
``resolve_timeout``.Útimeout)Úresolve_timeoutzmcp.tool_call©r(   z'mcp.tool_call timeout resolution failedT)Úexc_info)ÚgetÚagent.deadliner2   Ú_DEFAULT_TOOL_TIMEOUTÚ	ExceptionÚloggerÚdebug)r,   Ú
per_serverr2   Úresolveds   &   r   Ú_resolve_tool_timeoutr=   ,   sv   € ð —‘˜IÓ&€JØÒØÐðOÝ2Ù" ?Ô<QÔRˆØÒØˆOð  ô !Ð øô ô OÜ�‰Ð>ÈˆÕNÜ Ð ðOús   ™: º"A$Á#A$gš™™™™™É?c                ó0   € V ^8„  d   QhR\         R\         /# )r   Úsecondsr-   )r/   )r   s   "r   r   r   A   s   € ÷ \ñ \”uð \¤ñ \r   c           	     ó~   € \        RV \        P                  ! R\        ,
          R\        ,           4      ,          4      # )z5``seconds`` with +/-20% uniform jitter, floored at 0.g        g      ð?)ÚmaxÚrandomÚuniformÚ_BACKOFF_JITTER)r?   s   &r   Ú	_jitteredrE   A   s)   € äˆs�GœfŸnšn¨S´?Õ-BÀCÌ/ÕDYÓZÕZÓ[Ð[r   z�(?:ghp_[A-Za-z0-9_]{1,255}|sk-[A-Za-z0-9_-](?:\.?[A-Za-z0-9_-]){0,254}|Bearer\s+\S+|(?:token|key|API_KEY|password|secret)=[^\s&,;\"']{1,255})c                ó0   € V ^8„  d   QhR\         R\         /# )r   Úrefr-   r	   )r   s   "r   r   r   M   s   € ÷ ñ ”sð œsñ r   c                óŒ   € V P                  4       p V P                  R4      '       d   V \        R4      R P                  4       p V # )zPBare env-var name from a ``${...}`` body; strips a Cursor-style ``env:`` prefix.zenv:N)ÚstripÚ
startswithÚlen)rG   s   &r   Ú_env_ref_namerL   M   s:   € à
�)‰)‹+€CØ
‡~�~�f×ÒØ”#�f“+�,Ð×%Ñ%Ó'ˆØ€Jr   c                ó0   € V ^8„  d   QhR\         R\         /# )r   Útextr-   r	   )r   s   "r   r   r   U   s   € ÷ 7ñ 7œ#ð 7¤#ñ 7r   c                ó.   € \         P                  RV 4      # )zMReplace credential-like patterns with [REDACTED] before text reaches the LLM.z
[REDACTED])Ú_CREDENTIAL_PATTERNÚsub)rN   s   &r   Ú_sanitize_errorrR   U   s   € ä×"Ñ" <°Ó6Ð6r   c                ó0   € V ^8„  d   QhR\         R\        /# )r   Úexcr-   )ÚBaseExceptionr
   )r   s   "r   r   r   Z   s   € ÷ ñ ”-ð ¤Cñ r   c                ó^   € \        V 4      P                  4       pT;'       g    \        V 4      # )z‹Non-empty string for *exc*: some exceptions (``anyio.ClosedResourceError``) carry no
message, so fall back to ``repr`` to keep diagnostics.)r
   rI   Úrepr)rT   rN   s   & r   Ú_exc_strrX   Z   s&   € ô ˆs‹8�>‰>Ó€DØ×Ð”4˜“9Ðr   c                ó<   € V ^8„  d   QhR\         R\        R\         /# )r   ÚenvÚ	directoryr-   )r.   r
   )r   s   "r   r   r   a   s!   € ÷ ñ ”tð ¬ð ´ñ r   c                óF  € \        T ;'       g    / 4      pV'       d   VP                  RR4      P                  \        P                  4       Uu. uF  q3'       g   K  VNK  	  ppW9  d   V.VOpV'       d    \        P                  P                  V4      MTVR&   V# u upi )z=Prepend *directory* to env PATH if it is not already present.ÚPATHÚ )r.   r5   ÚsplitÚosÚpathsepÚjoin)rZ   r[   ÚupdatedÚpartÚpartss   &&   r   Ú_prepend_pathrf   a   s€   € ä�3—9�9˜"‹o€GßØ")§+¡+¨f°bÓ"9×"?Ñ"?ÄÇ
Á
Ô"KÓTÑ"K˜$Ët—�Ñ"KˆÐTØÔ!ØÐ' Ð'ˆEß49œ"Ÿ*™*Ÿ/™/¨%Ô0¸yˆ�‰Ø€Nùò	 Us   Á	BÁBc                óÎ   €  V! V 4      p\        V\        4      '       d   \        P                  ! V4      '       g   V# \	        WC4      #   \
        \        \        3 d    Tu # i ; i)z{Coerce a config value (YAML strings included) to a number, clamped to *minimum*;
*default* on failure or non-finite floats.)Ú
isinstancer/   ÚmathÚisfiniterA   Ú	TypeErrorÚ
ValueErrorÚOverflowError)r)   r(   ÚcoerceÚminimumÚresults   &&&& r   Ú_safe_numericrq   l   sV   € ðÙ˜“ˆÜ�fœe×$Ò$¬T¯]ª]¸6×-BÒ-BØˆNÜ�6Ó#Ð#øÜ”z¤=Ð1ô ØŠðús   ‚9A	 ¼A	 ¾
A	 Á	A$Á#A$c                ó<   € V ^8„  d   QhR\         R\        R\        /# )r   r)   r(   r-   )r   Úbool)r   s   "r   r   r   |   s!   € ÷ ñ œ#ð ¬ð ¼ñ r   c                ó2  € V f   V# \        V \        \        \        34      '       d   \        V 4      # \        V \        4      '       d9   V P                  4       P                  4       pV\        9   d   R# V\        9   d   R# \        P                  RW4       V# )z\Parse a bool-like config value with safe fallback (YAML ``0``/``1`` are numbers, not words).TFzAMCP config expected a boolean-ish value, got %r; using default=%s)rh   rs   Úintr/   r
   rI   ÚlowerÚ_TRUE_WORDSÚ_FALSE_WORDSr9   Úwarning)r)   r(   Úlowereds   && r   Ú_parse_boolishr{   |   sv   € à‚}ØˆÜ�%œ$¤¤UÐ+×,Ò,Ü�E‹{ÐÜ�%œ×ÒØ—+‘+“-×%Ñ%Ó'ˆØ”kÔ!ÙØ”lÔ"ÙÜ
‡N�NÐVÐX]ÔgØ€Nr   c                ó0   € V ^8„  d   QhR\         R\        /# )r   Úcfgr-   )r.   rs   )r   s   "r   r   r   Œ   s   € ÷ Bñ BœDð B¤Tñ Br   c                ó<   € \        V P                  RR4      RR7      # )a  Whether ``mcp_servers.<name>`` is on. The ONE reader of the ``enabled`` key: the MCP client,
the toolset resolver, the profile editor, and every list/status surface call it, so a value
can never be on for one surface and off for another. Absent, ``null`` or unparseable = on.ÚenabledTr3   )r{   r5   )r}   s   &r   Úmcp_server_enabledr€   Œ   s   € ô ˜#Ÿ'™' )¨TÓ2¸DÔAÐAr   c                óR   € V ^8„  d   QhR\         R\        R\        \        ,          /# )r   r,   Úkeyr-   )r.   r
   r   r/   )r   s   "r   r   r   “   s%   € ÷ ñ ¤4ð ¬cð ´h¼uµoñ r   c                ó|  € V P                  V4      pVf>   \        V P                  R4      \        4      '       d   V R,          P                  V4      pVf   R#  \        V4      pT^ 8  d   \        P                  RY4       R# T;'       g    R#   \        \
        3 d    \        P                  RY4        R# i ; i)z˜Optional positive lifecycle timeout from top-level/nested ``lifecycle`` config (``0``
disables; negatives and non-numbers are warned about and ignored).NÚ	lifecyclez6MCP config %s must be a number of seconds; ignoring %rz+MCP config %s must be positive; ignoring %r)r5   rh   r.   r/   rk   rl   r9   ry   )r,   r‚   Úrawr?   s   &&  r   Ú_get_lifecycle_secondsr†   “   s¦   € ð �*‰*�S‹/€CØ
‚{”z &§*¡*¨[Ó"9¼4×@Ò@Ø�[Õ!×%Ñ% cÓ*ˆØ
‚{ÙðÜ˜“*ˆð �„{Ü�‰ÐDÀcÔOÙØ�?ˆ?�dÐøô ”zÐ"ô Ü�‰ÐOÐQTÔZÚðús   ÁB Â'B;Â:B;)N>   Ú1ÚonÚyesÚtrue>   Ú0ÚnoÚoffÚfalse)T)#r   Úloggingri   r`   rB   ÚreÚtypingr   r   Ú	getLoggerr9   r   Ú_coreÚobjectr&   r*   r7   r=   rD   rE   ÚcompileÚ
IGNORECASErP   rL   rR   rX   rf   ru   rq   Ú	frozensetrw   rx   r{   r€   r†   r   r   r   Ú<module>r˜      sÐ   ðñWó Û Û 	Û Û 	ß  à	×	Ò	Ð+Ó	,€÷
'ñ 
'ñ 	‹€Ù‹8€÷3ð Ð õ!ð$ €õ\ð —j’jðBØCEÇ=Á=óRÐ õ
õ7õ
õð *-°aô 	ñ Ò2Ó3€ÙÒ4Ó5€÷õ B÷r   