Ë
    ãß²j  ã                   óÈ   — d Z ddlmZmZmZmZmZ ddlmZm	Z	m
Z
 dZddddd	d
dœidgdœdœZdedefd„Z ej                   ddeeeg ddd¬«	       ddlZddlZddlZddiZd„ Zy)zÓFeishu Document Tool -- read document content via Feishu/Lark API.

Provides ``feishu_doc_read`` for reading document content as plain text.
Uses the same lazy-import + BaseRequest pattern as feishu_comment.py.
é    )Ú_check_feishuÚbuild_requestÚ
get_clientÚraw_bodyÚ
set_client)ÚregistryÚ
tool_errorÚtool_resultz5/open-apis/docx/v1/documents/:document_id/raw_contentÚfeishu_doc_readz…Read the full content of a Feishu/Lark document as plain text. Useful when you need more context beyond the quoted text in a comment.ÚobjectÚ	doc_tokenÚstringz>The document token (from the document URL or comment context).)ÚtypeÚdescription)r   Ú
propertiesÚrequired)Únamer   Ú
parametersÚargsÚreturnc           
      ó¸  — | j                  dd«      j                  «       }|st        d«      S t        «       }|€t        d«      S 	 t	        dt
        d|i¬«      }|j                  |«      }t        |d	d «      }|d
k7  rt        d|› dt        |dd«      › �«      S t        |«      }|�.	 t        d|j                  di «      j                  dd«      ¬«      S t        |dd «      }|rEt        |t        «      r|j                  dd«      nt        |dt        |«      «      }	t        d|	¬«      S t        d«      S # t        $ r t        d«      cY S w xY w# t        $ r Y Œ„w xY w)Nr   Ú zdoc_token is requiredz=Feishu client not available (not in a Feishu comment context)ÚGETÚdocument_id)Úpathszlark_oapi not installedÚcoder   zFailed to read document: code=z msg=Úmsgzunknown errorTÚdataÚcontent)Úsuccessr   z%No content returned from document API)ÚgetÚstripr	   r   r   Ú_RAW_CONTENT_URIÚImportErrorÚrequestÚgetattrr   r
   ÚAttributeErrorÚ
isinstanceÚdictÚstr)
r   Úkwargsr   Úclientr%   Úresponser   Úbodyr   r   s
             ú:/home/ubuntu/.hermes/hermes-agent/tools/feishu_doc_tool.pyÚ_handle_feishu_doc_readr0   $   si  € Ø—‘˜ bÓ)×/Ñ/Ó1€IÙÜÐ1Ó2Ð2Ü‹\€FØ€~ÜÐYÓZÐZð5Ü Ô'7ÀÈyÐ?YÔZˆð
 �~‰~˜gÓ&€HÜ�8˜V TÓ*€DØˆq‚yÜÐ:¸4¸&ÀÄgÈhÐX]Ð_nÓFoÐEpÐqÓrÐrä�HÓ€DØÐð	Ü t°T·X±X¸fÀbÓ5I×5MÑ5MÈiÐY[Ó5\Ô]Ð]ô �8˜V TÓ*€DÙÜ-7¸¼dÔ-C�$—(‘(˜9 bÔ)ÌÐQUÐW`ÔbeÐfjÓbkÓIlˆÜ 4°Ô9Ð9ÜÐ=Ó>Ð>øô' ò 5ÜÐ3Ó4Ò4ð5ûô ò 	Ùð	ús$   ÁD3 Â',E Ä3E
Å	E
Å	EÅEÚ
feishu_docFzRead Feishu document contentu   ðŸ“„)	r   ÚtoolsetÚschemaÚhandlerÚcheck_fnÚrequires_envÚis_asyncr   ÚemojiNÚlogger)ztools.approvalr9   c                 óÌ   — t         j                  | «      }|€t        dt        ›d| ›�«      ‚dd l}ddlm}  |t        | g|¢­Ž  t        |j                  |d   «      |d   «      S )Nzmodule z has no attribute r   )Ú	warn_onceé   )	Ú_PLUGIN_COMPAT_LAZYr!   r'   Ú__name__Ú	importlibÚhermes_cli.plugin_compatr;   r&   Úimport_module)r   Útargetr?   r;   s       r/   Ú__getattr__rC   W   se   € Ü ×$Ñ$ TÓ*€FØ€~Ü˜w¤x lÐ2DÀTÀHÐMÓNÐNÛÝ2ÙŒh˜Ð&˜vÓ&Ü�9×*Ñ*¨6°!©9Ó5°v¸a±yÓAÐAó    )Ú__doc__Útools.feishu_larkr   r   r   r   r   Útools.registryr   r	   r
   r#   ÚFEISHU_DOC_READ_SCHEMAr)   r*   r0   ÚregisterÚjsonÚloggingÚ	threadingr=   rC   © rD   r/   ú<module>rN      s·   ðñ÷õ ÷ =Ñ <àJÐ ð ð	Qð àØ Ø_ñð
ð !�Mñ	ñÐ ð&? $ð ?°Só ?ð> €× Ñ Ø	 LÐ9OÐYpØ¨°eÐIgØ
õó Û Û ð Ð*ðÐ ó
BrD   