+
    lHàj°  ã                   ót   € R t ^ RIt^ RIt]P                  ! 4       tR tR tR tR
R ltR
R lt	R t
R R	 ltR# )aE  Shared lark_oapi plumbing for the feishu_doc / feishu_drive tool modules.

Holds the per-thread client handle, the cheap availability probe, and the generic
``BaseRequest`` builder + response unpacking (same pattern as feishu_comment.py).
No ``registry.register`` here on purpose: tool discovery must not import this module.
Nc                ó   € V \         n        R# )zFStore a lark client for the current thread (called by feishu_comment).N)Ú_localÚclient)r   s   &Ú6/home/ubuntu/.hermes/hermes-agent/tools/feishu_lark.pyÚ
set_clientr      s	   € à„F†Mó    c                 ó$   € \        \        RR4      # )z7Return the lark client for the current thread, or None.r   N)Úgetattrr   © r   r   Ú
get_clientr      s   € ä”6˜8 TÓ*Ð*r   c                  óv   € ^ RI p  V P                  P                  R4      RJ#   \        \        3 d     R# i ; i)é    NÚ	lark_oapiF)Úimportlib.utilÚutilÚ	find_specÚImportErrorÚ
ValueError)Ú	importlibs    r   Ú_check_feishur      s=   € ó ðØ�~‰~×'Ñ'¨Ó4¸DÐ@Ð@øÜœÐ$ô Úðús   †# £8·8c                óž  € ^ RI Hp ^ RIHp ^ RIHp VP                  4       P                  V R8X  d   VP                  MVP                  4      P                  V4      P                  VP                  04      pV'       d   VP                  V4      pV'       d   VP                  V4      pVe   VP                  V4      pVP!                  4       # )zMBuild a tenant-token BaseRequest. Raises ImportError if lark_oapi is missing.)ÚAccessTokenType)Ú
HttpMethod)ÚBaseRequestÚGET)r   r   Úlark_oapi.core.enumr   Ú!lark_oapi.core.model.base_requestr   ÚbuilderÚhttp_methodr   ÚPOSTÚuriÚtoken_typesÚTENANTÚpathsÚqueriesÚbodyÚbuild)	Úmethodr    r#   r$   r%   r   r   r   r   s	   &&&&&    r   Úbuild_requestr(   %   s˜   € å)Ý.Ý=ð 	×ÑÓß	‰ v°¤�Z—^’^¸J¿O¹OÓ	Lß	‰ˆS‹ß	‰�o×,Ñ,Ð-Ó	.ð	 ÷
 Ø—-‘- Ó&ˆßØ—/‘/ 'Ó*ˆØÒØ—,‘,˜tÓ$ˆØ�=‰=‹?Ðr   c           	     ó‚   € V P                  \        WW4V4      4      p\        VRR4      \        VRR4      \        V4      3# )z¼Build + execute a BaseRequest; returns (code, msg, data_dict).

Tool handlers run synchronously in a worker thread (no running event loop), so the
blocking lark client is called directly.
ÚcodeNÚmsgÚ )Úrequestr(   r	   Úresponse_data)r   r'   r    r#   r$   r%   Úresponses   &&&&&& r   Ú	lark_callr0   9   s@   € ð �~‰~œm¨F¸ÈÓNÓO€HÜ�8˜V TÓ*¬G°H¸eÀRÓ,HÌ-ÐX`ÓJaÐaÐar   c                ó  € \        V RR4      p V'       d3   \        VR4      '       d!   \        P                  ! VP                  4      MRp\        T\        4      '       d   T# R#   \        P
                  \        3 d     R# i ; i)zTParsed JSON object of the raw HTTP body, or None when absent/unparseable/not a dict.ÚrawNÚcontent)	r	   ÚhasattrÚjsonÚloadsr3   ÚJSONDecodeErrorÚAttributeErrorÚ
isinstanceÚdict)r/   r2   r%   s   &  r   Úraw_bodyr;   C   so   € ä
�(˜E 4Ó
(€Cðß*-´'¸#¸y×2IÒ2IŒt�zŠz˜#Ÿ+™+Ô&Ètˆô ˜d¤D×)Ò)ˆ4Ð3¨tÐ3øô × Ñ ¤.Ð1ô Úðús   �<A% Á%BÂBc                ó$   € V ^8„  d   QhR\         /# )é   Úreturn)r:   )Úformats   "r   Ú__annotate__r@   M   s   € ÷ 	Uñ 	Uœtñ 	Ur   c                óô   € \        V 4      pVe   VP                  R/ 4      M/ pV'       d   V# \        V RR4      p\        V\        4      '       d   V# V'       d   \        VR4      '       d   \        V4      # T# )zP``data`` of a lark response: prefer the raw JSON body, fall back to typed .data.NÚdataÚ__dict__)r;   Úgetr	   r9   r:   r4   Úvars)r/   r%   rB   Ú	resp_datas   &   r   r.   r.   M   sj   € ä�HÓ€DØ#'Ò#3ˆ4�8‰8�F˜BÔ¸€DßØˆÜ˜ &¨$Ó/€IÜ�)œT×"Ò"ØÐß'¬G°I¸z×,JÒ,JŒ4�	‹?ÐTÐPTÐTr   )NNN)Ú__doc__r5   Ú	threadingÚlocalr   r   r   r   r(   r0   r;   r.   r
   r   r   Ú<module>rJ      sE   ðñó Û ð 
�ŠÓ	€òò
+ò
ôô(bò4÷	Ur   