+
    lHàjÜE  ã                   óÊ  € R t ^ RIt^ RIt^ RIt^ RIt^ RIHtHtHtH	t	H
t
 ^ RIHt ^ RIHt ^ RIHt ^ RIHt ]P&                  ! R4      tRtR1t]^,          ^,          ^,           t]3R	 R
 lltR R ltR R ltR R ltR R ltRRRRRR/R R lltRRRR/R R lltRRRRR R/tRR/R! R" llt R# R$ lt!^t"^t#R% R& lt$R' R( lt%R) R* lt&R+ R, lt'R- R. lt(R2R/ R0 llt)R# )3z¬Rendering of MCP tool-result content blocks into model-facing text: size
capping, _meta filtering, image/audio caching to MEDIA tags, resource links and
embedded resources.N)ÚAnyÚDictÚListÚOptionalÚTuple)Ústrip_unicode_tags)Ú	mcp_field)Úmcp_prefixed_tool_name©Útruncate_head_tailztools.mcp_tooli€„ c                ó<   € V ^8„  d   QhR\         R\        R\         /# )é   ÚtextÚ	max_charsÚreturn)ÚstrÚint)Úformats   "Ú;/home/ubuntu/.hermes/hermes-agent/tools/mcp_tool_content.pyÚ__annotate__r       s'   € ÷ Cñ C¤Cð C´Cð CÔY\ñ Có    c                ó   € \        WRR7      # )z:Bound pathological MCP text before it propagates (#56059).z
MCP RESULT)Úlabelr
   )r   r   s   &&r   Ú_truncate_mcp_text_resultr       s   € ä˜d°\ÔBÐBr   c                ó0   € V ^8„  d   QhR\         R\        /# )r   Úkeyr   )r   Úbool)r   s   "r   r   r   %   s   € ÷ sñ s¤3ð s¬4ñ sr   c                óø   a€ V P                  R4      pV^ 8:  d   R# V RV P                  R4      o\        ;QJ d(    V3R l\        S4       4       F  '       g   K   R# 	  R# ! V3R l\        S4       4       4      # )z÷True if an MCP ``_meta`` key uses a protocol-reserved prefix: a ``modelcontextprotocol``
or ``mcp`` label followed by at least one more label. A trailing one
(``com.example.mcp/...``) is a vendor namespace.

Ported from MoonshotAI/kimi-code#2600.
Ú/FNÚ.c              3   ól   <"  € T F)  w  rVR9   ;'       d    V\        S4      ^,
          8  x € K+  	  R# 5i)ÚmodelcontextprotocolN)r!   Úmcp)Úlen)Ú.0Úir   Úlabelss   &  €r   Ú	<genexpr>Ú,_is_reserved_mcp_meta_key.<locals>.<genexpr>0   s5   øé € ÐrÑ`qÑT\ÐTUˆuÐ7Ñ7×OÐO¸AÄÀFÃÈaÅÑ<OÔOÓ`qùs   ƒ14T)ÚfindÚsplitÚanyÚ	enumerate)r   Úslashr&   s   & @r   Ú_is_reserved_mcp_meta_keyr.   %   si   ø€ ð �H‰H�S‹M€EØ�„zÙØ��%ˆ[×Ñ˜sÓ#€Fß‹3ÔrÔ`iÐjpÔ`qÓr�3Œ3ÐrŠ3Ðrˆ3ÔrÔ`iÐjpÔ`qÓrÓrÐrr   c                ó\   € V ^8„  d   QhR\         \        \        \        3,          ,          /# ©r   r   )r   Údictr   r   )r   s   "r   r   r   3   s    € ÷ ñ ¤x´´S¼#°XµÕ'?ñ r   c                óò   € \        V \        4      '       g   R# V P                  4        UUu/ uF2  w  r\        V\        4      '       g   K  \	        V4      '       d   K0  WbK4  	  pppT;'       g    R# u uppi )zoDrop protocol-reserved keys from ``_meta``; None if nothing model-facing remains or the
input wasn't a mapping.N)Ú
isinstancer1   Úitemsr   r.   )ÚmetaÚkÚvÚouts   &   r   Ú_strip_reserved_meta_keysr9   3   sZ   € ô �dœD×!Ò!ÙØ ŸJ™JœLÔ
f™L‘D�A¬J°q¼#×,>Œ4ÔHaÐbc×HdŒ4ˆ1Š4™L€CÑ
fØ�;ˆ;�$Ðùó gs   ¬A3ÁA3ÁA3c                ó$   € V ^8„  d   QhR\         /# r0   ©r   )r   s   "r   r   r   <   s   € ÷ Añ AœSñ Ar   c                ó’   € \        T ;'       g    R4      P                  R^4      ^ ,          P                  4       P                  4       # )zC``type/subtype`` of a MIME string, lower-cased, parameters dropped.Ú Ú;)r   r*   ÚstripÚlower)Ú	mime_types   &r   Ú
_base_mimerB   <   s7   € äˆy�ˆ˜BÓ×%Ñ% c¨1Ó-¨aÕ0×6Ñ6Ó8×>Ñ>Ó@Ð@r   c                ó0   € V ^8„  d   QhR\         R\         /# )r   rA   r   r;   )r   s   "r   r   r   A   s   € ÷ ;ñ ;´#ð ;¼#ñ ;r   c                ój   € \        V 4      pVR9   d   R# \        P                  ! V4      ;'       g    R# )z>File extension for an MCP image MIME type (``.png`` fallback).z.jpgz.png>   ú	image/jpgú
image/jpeg)rB   Ú	mimetypesÚguess_extension)rA   Ú
normalizeds   & r   Ú"_mcp_image_extension_for_mime_typerJ   A   s1   € ä˜IÓ&€JØÐ0Ô0ÙÜ×$Ò$ ZÓ0×:Ð:°FÐ:r   Úcap_whatÚ
cap_suffixr=   Údecode_failc                ó®   € V ^8„  d   QhR\         R\         R\        \         ,          R\         R\         R\        \        \        ,          \         3,          /# )r   Úwhatr   rK   rL   rM   r   )r   r   ÚtupleÚbytes)r   s   "r   r   r   I   sM   € ÷ ñ ¤#ð ¬cð ÄÌÅð Ü"%ðÜ9<ðÜFKÌHÔUZÍOÔ]`ÐL`ÕFañr   c               ó’  € V'       d:   \        V 4      \        8”  d&   RRV R\        V 4      ^,          ^,           RV R23#  \        P                  ! V 4      pT'       d,   \        T4      \        8”  d   RRT R\        T4       RT R23# TR3#   \        \
        3 d&   p\        P                  RYT4       RT3u Rp?# Rp?ii ; i)	zøBase64-decode one block payload: ``(bytes, "")`` or ``(None, inline_marker)``. With
``cap_what`` the payload is rejected on b64 length BEFORE decoding and on decoded size
after. Decode failures warn and return ``decode_fail`` ("" = drop the block).Nz[MCP z too large to cache: ~z bytesÚ]zMCP %s decode failed (%s): %sz too large to cache: r=   )	r#   Ú_MCP_RESOURCE_MAX_B64_CHARSÚbase64Ú	b64decodeÚ	TypeErrorÚ
ValueErrorÚloggerÚwarningÚ_MCP_RESOURCE_MAX_BYTES)ÚdatarO   r   rK   rL   rM   Ú	raw_bytesÚexcs   &&&$$$  r   Ú_decode_block_b64r_   I   sÒ   € ÷
 ”C˜“IÔ ;Ô;Ø�u˜X˜JÐ&<¼SÀ»YÈ½]ÈaÕ=OÐ<PÐPVÐWaÐVbÐbcÐdÐdÐdð!Ü×$Ò$ TÓ*ˆ	÷ ”C˜	“NÔ%<Ô<Ø�u˜X˜JÐ&;¼CÀ	»NÐ;KÈ6ÐR\ÐQ]Ð]^Ð_Ð_Ð_Ø�bˆ=Ðøô ”zÐ"ô !Ü�‰Ð6¸ÀSÔIØ�[Ð Õ ûð!ús   ÁB ÂCÂ!CÂ;CÃCÚunavailableÚfailedc                ó˜   € V ^8„  d   QhR\         R\         R\         R\         R\         R\        \        \         ,          \         3,          /# )r   ÚwriterrO   Ú
skip_labelr`   ra   r   )r   rP   r   )r   s   "r   r   r   Z   sK   € ÷ ñ œsð ¬#ð ¼3ð Ü$'ðÜ69ðÜMRÔS[Ô\_ÕS`ÔbeÐSeÕMfñr   c               óì   €  ^ RI Hu Hp \        Wp4      ! V/ VB R3#   \         d    \
        P                  RT4       RT3u # \         d%   p\
        P                  RY4       RT3u Rp?# Rp?ii ; i)u	  Call ``gateway.platforms.base.<writer>(*args, **kwargs)``: ``(path, "")`` or ``(None,
marker)``. Fail-open so one bad block never kills the tool result: gateway deps missing
(cron without gateway) â†’ ``unavailable``; any other cache error â†’ warning + ``failed``.Nr=   u=   MCP %s caching skipped â€” gateway.platforms.base unavailablezMCP %s cache failed: %s)	Úgateway.platforms.baseÚ	platformsÚbaseÚgetattrÚImportErrorrY   ÚdebugÚ	ExceptionrZ   )	rc   rO   rd   r`   ra   ÚargsÚkwargsÚ_baser^   s	   &&&$$*,  r   Ú_write_block_cacherp   Z   ss   € ð
ß.Ð.Ü�uÔ% tÐ6¨vÑ6¸Ð:Ð:øÜô !Ü�‰ÐTÐV`ÔaØ�[Ð Ò Üô Ü�‰Ð0°$Ô<Ø�Vˆ|Õûðús'   ‚ ž%A3ÁA3ÁA3ÁA.Á(A3Á.A3z	audio/wavz.wavzaudio/x-wavz
audio/wavec                ó^   € V ^8„  d   QhR\         R\         R\        \         ,          R\         /# )r   Úkindrc   rK   r   )r   r   )r   s   "r   r   r   m   s0   € ÷ 4ñ 4¬ð 4´Sð 4ÔPXÔY\ÕP]ð 4Ôilñ 4r   c          	     ó   € \        V RR4      p\        \        V RR4      4      pVe   VP                  V R24      '       g   R# \	        WQ R2WdR7      w  rxVf   V# \        W! R2WV! V4      R	7      w  r˜V	f   V# R
V	 2# )zâCache an image/audio block and return a ``MEDIA:<path>`` tag. "" (logging, not raising)
when the block isn't ``kind`` media, the base64 is malformed, or the cache rejects the
bytes: the caller falls through to any text blocks.r\   NrA   ÚmimeTyper   r=   z block©rK   )ÚextzMEDIA:)ri   rB   r   Ú
startswithr_   rp   )
Úblockrr   rc   Úext_forrK   r\   Úmimer]   ÚerrÚpaths
   &&&&$     r   Ú_cache_mcp_media_blockr}   m   s’   € ô �5˜& $Ó'€DÜ”i  {°JÓ?Ó@€DØ‚|˜4Ÿ?™?¨d¨V°1¨:×6Ò6ÙÜ& t¨v°V¨_¸dÔV�N€IØÒØˆ
Ü" 6¨V°6¨?¸DÑQXÐY]ÓQ^Ô_�I€DØ’,ˆ3Ð3 f¨T¨F OÐ3r   c                ó$   € V ^8„  d   QhR\         /# r0   r;   )r   s   "r   r   r   |   s   € ÷ pñ p¤Sñ pr   c                ó&   € \        V RR\        4      # )zVCache an ``ImageContent`` block and return a ``MEDIA:<path>`` tag ("" on any failure).ÚimageÚcache_image_from_bytes)r}   rJ   ©rx   s   &r   Ú_cache_mcp_image_blockrƒ   |   s   € ä! %¨Ð2JÔLnÓoÐor   c                ó    € V ^8„  d   QhR\         R\        \        \        \         \        3,          \        \         ,          3,          ,          /# )r   r|   r   )r   r   rP   r1   r   )r   s   "r   r   r   …   s:   € ÷ (dñ (d¤ð (d¬´%¼¼SÄ#¸X½ÌÔQTÍÐ8UÕ2VÕ)Wñ (dr   c           	     ó6  € ^ RI Hp ^ RIHp ^ RIHpHpHpHp ^ RI	H
p ^ RIHpHp	Hp
 V! V 4      pV! VP                  4       4      pV'       g   R# V	! W¼4      w  rÜpV'       g   Vf   R# / p\!        V! 4       V4      p V
! V4      '       d    WÛ8w  d   VP#                  RR7       R# R# VP%                  V4      ;_uu_ 4       pVP&                  pRRR4       V! WÜVVRVR	7      pWÛ8w  d   VP#                  RR7       \)        TP+                  R
X^ ,          4      TP+                  RT^,          4      4      T8”  d   R# \-        T4      T8”  d   R# RRRRT//T! T;'       g    RR4      3#   + '       g   i     L£; i  YÛ8w  d   TP#                  RR7       i i ; i)uœ  ``(image_url part, scale note)`` for one cached MCP image, sized like every other native embed (the
result is re-sent each later turn: ``vision.embed_target_bytes``, 1568 px long edge, JPEG) and normalized
to a provider-accepted format (BMP and friends â†’ PNG). None when the file cannot be embedded safely. The
note maps embedded coordinates back to the original image (a screenshot's pixels are the screen's).©ÚPath)ÚImage)Ú_EMBED_MAX_DIMENSIONÚ_MAX_BASE64_BYTESÚ_build_scale_noteÚ_resize_image_for_vision)Úresolve_embed_target_bytes)Ú"_detect_image_mime_type_from_bytesÚ_normalize_to_supported_imageÚ _validate_raster_image_decodableNT)Ú
missing_ok)rA   Úmax_base64_bytesÚmax_dimensionÚ
force_jpegÚ	scale_outÚ	new_widthÚ
new_heightÚtypeÚ	image_urlÚurl)Úpathlibr‡   ÚPILrˆ   Útools.vision_toolsr‰   rŠ   r‹   rŒ   Ú!tools.vision_tools_history_budgetr�   Útools.vision_tools_image_preprŽ   r�   r�   Ú
read_bytesÚminÚunlinkÚopenÚsizeÚmaxÚgetr#   )r|   r‡   rˆ   r‰   rŠ   r‹   rŒ   r�   rŽ   r�   r�   Úsrcrz   rI   r{   ÚscaleÚtargetr€   Údimsrš   s   &                   r   Ú_mcp_native_image_partr«   …   s‹  € õ
 Ý÷>ó >åL÷Qñ Qá
ˆt‹*€CÙ-¨c¯n©nÓ.>Ó?€DßÙÙ9¸#ÓDÑ€J�cß
ˆjÒ ÙØ€EÜÑ+Ó-Ð/@ÓA€Fð/ñ ,¨J×7Ò7Øð ÔØ×Ñ¨ÐÖ.ñ ð �Z‰Z˜
×#Ô# uØ—:‘:ˆD÷ $á& zÐTZØ5IÐVZÐfkômˆð ÔØ×Ñ¨ÐÔ.ô ˆ5�9‰9�[ $ q¥'Ó*¨E¯I©I°lÀDÈÅGÓ,LÓMÐPdÔdÙÜ
ˆ3ƒx�&ÔÙØ�K ¨u°c¨lÐ;Ñ=NÈuÏ}È}ÐX\Ð^bÓ=cÐcÐc÷ $×#ûð
 ÔØ×Ñ¨ÐÕ.ð ús*   Á>E= Â)E= ÃE*ÃE= Å*E:	Å5E= Å=Fc                óR   € V ^8„  d   QhR\         R\        \         ,          R\        /# )r   r   Úimage_pathsr   )r   Úlistr   )r   s   "r   r   r   °   s%   € ÷ ;"ñ ;"¬ð ;"¼4Ä½9ð ;"Ìñ ;"r   c           	     ó�  € V'       g   V #  ^ RI p^ RIHpHp ^ RIHp V! 4       '       g   V #  . RrvTR\         pT'       Ed   \        T4      \        8  dô   TR\        \        T4      ,
           T\        \        T4      ,
          R r‰T	 U
u. uF3  qªTP                  TP                  4       P                  \        T
4      3NK5  	  pp
T Fz  w  rÍ TP!                  4       pT'       g   K   Tw  ppT! TR	,          R
,          4      '       d   TRT R2,          pKP  TP#                  T4       T'       g   Kk  TRT RT 2,          pK|  	  EK  T'       g\   T'       g   T #  \$        P&                  ! T 4      pTP)                  R4      ;'       g    R T 2TR&   \$        P*                  ! TRR7      # RpRRRRRRT /RRRTT,           /.TORT /#   \         d    \        P                  RRR7       T u # i ; iu up
i   \         d    \        P                  RTRR7        EKW  i ; i  \,        \.        \0        3 d    Y,           u # i ; i)uÐ  *text* as-is, or the ``_multimodal`` envelope carrying the call's cached images when the active route
takes images inside tool results â€” the same gate as ``vision_analyze`` and ``computer_use`` captures
(``agent.image_input_mode``, an explicit ``auxiliary.vision`` backend, catalog vision, provider support).
The text half keeps the ``MEDIA:`` paths so sharing and full-resolution reads still work. Any failure
keeps the text: the paths already carry the images.N)Ú#_should_use_native_vision_fast_pathÚ_vision_cpu_executor)Úrepeat_refusalz2MCP native image gate failed, keeping MEDIA: pathsT)Úexc_infor=   z#MCP native image prep failed for %sr™   rš   z	
- MEDIA:zN: not attached; this image is already in context (vision.max_calls_per_image).z: ÚresultF)Úensure_asciiuR   The image(s) from this call are attached â€” inspect them with your native vision.Ú_multimodalÚcontentr˜   r   Útext_summary)Úcontextvarsr�   r°   r±   rž   r²   rl   rY   rk   Ú_MCP_NATIVE_IMAGE_CANDIDATESr#   Ú_MCP_NATIVE_IMAGE_MAXÚsubmitÚcopy_contextÚrunr«   r´   ÚappendÚjsonÚloadsr¦   ÚdumpsrW   rX   ÚAttributeError)r   r­   r¹   r°   r±   r²   ÚattachedÚnotesÚ
candidatesÚwaveÚpÚjobsr|   ÚjobÚreadyÚpartÚnoteÚpayloadÚheaders   &&                 r   Ú_mcp_result_with_native_imagesrÐ   °   s[  € ÷ ØˆðÛß`ÝDÙ2×4Ò4ØˆKð 5ð
 ˜"ˆeØÐ:Ô:Ð;€J÷ ˆ*œ˜X›Ô)>Ô>Ø%Ð&LÔ'<¼sÀ8»}Õ'LÐMÈzÔZoÔruÐv~ÓrÕZð  [Að  PBˆjÙuyÓzÑuyÐpqÐ(×/Ñ/°×0HÑ0HÓ0J×0NÑ0NÔPfÐhiÓjÓkÑuyˆÐzÛ‰IˆDðØŸ
™
›�÷ ÙØ‰JˆD�$ñ ˜d ;Õ/°Õ6×7Ò7Ø˜: d VÐ+yÐzÕz�ÙØ�O‰O˜DÔ!ß‰tØ˜: d V¨2¨d¨VÐ4Õ4’ô! ÷" ßØˆKð	 Ü—j’j Ó&ˆGØ#*§;¡;¨xÓ#8×#>Ð#>¸BÐ"?À¸wÐ GˆG�HÑÜ—:’:˜g°EÔ:Ð:ð
 b€FØ˜4Ø˜ ¨°Ð6¸ÀÈÐQWÐZ_ÕQ_Ð8`ÐlÐckÐlØ˜Dð"ð "øôW ô Ü�‰ÐIÐTXˆÔYØŠðüò {øô ô Ü—‘ÐBÀDÐSW�ÔXÛðûô, œ:¤~Ð6ô 	 Ø•<Òð	 úsF   ŒG
 «G
 Â9G4ÃG9Å-H$ Æ!H$ Ç
$G1Ç0G1Ç9#H!È H!È$IÉIc                ó$   € V ^8„  d   QhR\         /# r0   r;   )r   s   "r   r   r   î   s   € ÷ #ñ #¤Sñ #r   c                ó$   € \        V RRR RR7      # )zVCache an ``AudioContent`` block and return a ``MEDIA:<path>`` tag ("" on any failure).ÚaudioÚcache_audio_from_bytesc                 ó|   € \         P                  V 4      ;'       g!    \        P                  ! V 4      ;'       g    R # )z.ogg)Ú_WAV_MIME_EXTr¦   rG   rH   )rz   s   &r   Ú<lambda>Ú(_cache_mcp_audio_block.<locals>.<lambda>ò   s.   € ”]×&Ñ& tÓ,×YÐY´	×0IÒ0IÈ$Ó0O×YÐYÐSYÐYr   zaudio resourceru   )r}   r‚   s   &r   Ú_cache_mcp_audio_blockrÙ   î   s   € ä!ØˆwÐ0ÙYØ!ô#ð #r   c                ó<   € V ^8„  d   QhR\         R\         R\         /# )r   ÚurirA   r   r;   )r   s   "r   r   r   ö   s!   € ÷ ñ ¤ð ´ð ¼ñ r   c           	     ó”  € ^ RI p^ RIHp ^ RIHpHp RpV '       d=    T! T! V! \        V 4      4      P                  ;'       g    R4      4      P                  pVP                  RRV4      P                  4       p\        V4      ^–8”  dk   VP                  R4      w  rxp	V'       dF   ^ \        V	4      u;8  d   ^8:  d.   M M*VR^–\        V	4      ,
          ^,
           R,           V	,           MVR,          pV'       d   VR
9   d/   \        P                   ! \#        V4      4      ;'       g    Rp	R	V	 2pV#   \        \        3 d     Líi ; i)zÇSafe display filename from the URI's last path segment, used only as a name hint:
``cache_document_from_bytes`` re-sanitizes and prefixes it, so remote path components
can't steer the cache location.Nr†   )ÚurlparseÚunquoter=   z[\x00-\x1f\x7f]r   :Né–   Nz.binÚresource>   r   ú..)Úrer›   r‡   Úurllib.parserÝ   rÞ   r   r|   ÚnamerX   rW   Úsubr?   r#   Ú
rpartitionrG   rH   rB   )
rÛ   rA   Ú_rer‡   rÝ   rÞ   rä   ÚstemÚdotrv   s
   &&        r   Ú_mcp_resource_filenamerê   ö   s  € ó Ýß.Ø€Dß
ð	Ù™¡¬¨S«Ó 2× 7Ñ 7× =Ð =¸2Ó>Ó?×DÑDˆDð
 �7‰7Ð% r¨4Ó0×6Ñ6Ó8€DÜ
ˆ4ƒy�3„ØŸ™¨Ó-‰ˆ�3ß9<ÀÄSÈÃXÖASÐQS×ASˆtÐ(�cœC ›H•n qÕ(Ð)¨CÕ/°#Ö5ÐY]Ð^bÕYcˆß�4˜;Ô&Ü×'Ò'¬
°9Ó(=Ó>×HÐHÀ&ˆØ˜#˜ÐˆØ€Køô œIÐ&ô 	Ùð	ús   ž%D3 ÁD3 Ä3EÅEc                ó0   € V ^8„  d   QhR\         R\         /# )r   Ú
block_typer   r;   )r   s   "r   r   r     s   € ÷ Nñ N¼ð NÄñ Nr   c                ó  € RV 2.p\        V RRR4      pV'       d   VP                  RV 24       \        V RR4      ;'       g    \        \        V RR4      RR4      pV'       d   VP                  RV 24       R F;  p\        WR4      p\        V\        4      '       g   K'  VP                  R	V 24        M	  \        V R
R4      pV'       d+   \        V\
        4      '       d   VP                  RV 24       RRP                  V4       R2# )u  Inline notice for an unsupported MCP content block (kimi-code#3227): silently dropping it
leaves the model unaware content went missing. Carries whatever handles the block exposes â€”
mime type, uri, size, name â€” so the agent can fetch or reason about the missing content.ztype=rA   rt   Nz	mimeType=rÛ   rà   úuri=zsize=rä   zname=z)[MCP content dropped: unsupported block (ú, z)])r¤   ÚsizeInBytes)r   r¿   ri   r3   r   r   Újoin)rx   rì   Údetailsrz   rÛ   Ú	size_attrr¤   rä   s   &&      r   Ú _render_mcp_dropped_block_noticerô     sú   € ð �z�lÐ#Ð$€GÜ�U˜K¨°TÓ:€DßØ�‰˜ 4 &Ð)Ô*Ü
�%˜ Ó
%×
_Ð
_¬´¸À
ÈDÓ1QÐSXÐZ^Ó)_€Cß
Ø�‰˜˜c˜U�|Ô$Û,ˆ	Ü�u¨Ó.ˆÜ�dœC× Ô Ø�N‰N˜U 4 &˜>Ô*Ùñ	 -ô
 �5˜& $Ó'€Dß”
˜4¤×%Ò%Ø�‰˜˜t˜f�~Ô&Ø6°t·y±yÀÓ7IÐ6JÈ"ÐMÐMr   c                ó0   € V ^8„  d   QhR\         R\         /# )r   Úserver_namer   r;   )r   s   "r   r   r   %  s   € ÷ '{ñ '{´3ð '{Äñ '{r   c                óè  € \        V RR4      pVR8X  g,   \        V R4      '       d¬   \        V R4      '       gš   VR8w  d“   \        V RR4      pV'       g   R# \        V RR4      ;'       g    Rp\        V R	R
R4      ;'       g    RpRV 2V'       d   RV 2MR,           V'       d   RV 2MR,           pV'       d   \        VR4      MRpRV RV R2# \        V RR4      pVf   R# \        VRR4      p	V	e   \	        \        V	4      4      # \        VRR4      p
V
f   R# \        \        VRR4      ;'       g    R4      p\        \        VR	R
R4      ;'       g    R4      p\        T
RT;'       g    TRRV 2RT;'       g    T R2R7      w  r¼Vf   V# T;'       g    Rp\        RRRT\        W54      R\        V4       RV R2RT;'       g    T R2R7      w  rìVf   V# RV R V R!\        V4       R"2# )#u“  Render a ``ResourceLink`` or ``EmbeddedResource`` block as text: embedded text â†’ the
text; embedded blob â†’ decoded (size-capped) into the document cache with a path marker;
link â†’ the URI plus a pointer at the server's read_resource tool (no fetch here â€” links
are only readable via the originating session). "" for non-resource blocks; failures are
reported inline rather than silently dropped.r˜   r=   Úresource_linkrÛ   rà   r   Nrä   rA   rt   rî   z, name=z, mimeType=Úread_resourcez#the MCP server's read_resource toolz[MCP resource link: u    â€” fetch it with rS   Úblobzembedded resourcez, uri=z-[MCP embedded resource could not be decoded: )rK   rL   rM   zunknown typeÚcache_document_from_bytesz![MCP embedded resource received (z bytes, z1) but document cache unavailable in this process]z,[MCP embedded resource could not be cached: )r`   ra   z[MCP resource saved to z (rï   u5    bytes) â€” read it with read_file or terminal tools])
ri   Úhasattrr   r	   r   r   r_   rp   rê   r#   )rx   rö   rì   rÛ   rä   rz   rò   Úreaderrà   r   rú   r]   r{   rr   r|   s   &&             r   Ú_render_mcp_resource_blockrþ   %  s3  € ô ˜ ¨Ó+€JØ�_Ô$¬°¸×)>Ò)>ÄwÈuÐV`×GaÒGaÐfpÐtzÔfzÜ�e˜U DÓ)ˆßÙÜ�u˜f bÓ)×/Ð/¨RˆÜ˜ ¨Z¸Ó<×BÐBÀˆØ˜˜�,·d G¨D¨6Ñ"2ÀÕC×_cÈÐUYÐTZÑG[ÐikÕlˆßITÔ'¨°_ÔEÐZˆØ% g YÐ.AÀ&ÀÈÐKÐKÜ�u˜j¨$Ó/€HØÒÙÜ�8˜V TÓ*€DØÒÜ!¤# d£)Ó,Ð,Ü�8˜V TÓ*€DØ‚|ÙÜ
Œg�h  rÓ*×0Ð0¨bÓ
1€CÜŒy˜ ;°
¸BÓ?×EÐEÀ2ÓF€DÜ&ØÐ! 4§; ;¨3Ð9LÐ[aÐbeÐafÐYgØCÀDÇKÀKÈCÀ=ÐPQÐRôT�N€Ið ÒØˆ
Ø×!Ð!�>€DÜ"Ø#Ð%8¸*ÀiÔQgÐhkÓQrØ7¼¸I»Ð7GÀxÐPTÈvð  VGð  HØ=¸d¿k¸kÀc¸]È!ÐLôN�I€Dð ‚|Øˆ
Ø$ T F¨"¨T¨F°"´S¸³^Ð4DÐDyÐzÐzr   i   )r=   )*Ú__doc__rU   rÀ   ÚloggingrG   Útypingr   r   r   r   r   Útools.ansi_stripr   Útools.mcp_tool_commonr   Útools.mcp_tool_schemar	   Útools.tool_output_truncater   Ú	getLoggerrY   Ú_MCP_HARD_RESULT_CAP_CHARSr[   rT   r   r.   r9   rB   rJ   r_   rp   rÖ   r}   rƒ   r»   rº   r«   rÐ   rÙ   rê   rô   rþ   © r   r   Ú<module>r	     s  ðñó Û Û Û ß 3Õ 3Ý /Ý +Ý 8Ý 9à	×	Ò	Ð+Ó	,€ð 'Ð ð +Ð Ø5¸Õ9¸QÕ>ÀÕBÐ ð ;U÷ Cõ
sõõAõ
;ðÐPTð Ø(*ðØ?A÷ð"Ø*,ðØ<>÷ð  ˜f m°V¸\È6ÐR€ð4Ð`d÷ 4õpð
 Ð Ø!Ð õ(dõV;"õ|#õõ2N÷,'{ñ '{r   