+
    Q(iG                    D  a  0 t $ ^ RIHt ^ RIt^ RIHt ^ RIHtHtH	t	H
t
HtHt ^ RIt^ RIt^ RIHt ^ RIHtHtHtHtHtHt ^ RIHt ^ RIHtHtHt ^ R	IHt ^ R
I H!t! ^ RI"H#t#H$t$ ^ RI%H&t& ^ RI'H(t( ^ RI)H*t*H+t+H,t,H-t-H.t.  ^ RI/H0t1 ^ RI2H3t4 Rt5]'       d   ^ RI7H8t8 ^ RI9H:t: ^ RI;H<t< ^ RI=H>t>H?t? ](! ]@4      tA]]	.]B3,          tCR]DR&   R R ltE ! R R]4      tF ! R R]&4      tR*R R  lltGR*R! R" lltHR#tIR$ R% ltJR*R& R' lltKRR.tLR( R) ltMR#   ]6 d    Rt5 Li ; i)+    )annotationsN)Callable)TYPE_CHECKING	AnnotatedAnyClassVar	TypeAliasoverload)validate_and_warn_tool_name)CallToolResultContentBlockIconTextContentToolAnnotationsToolExecution)Tool)	BaseModelFieldmodel_validator)SkipJsonSchema)	AuthCheck)
TaskConfigTaskMeta)FastMCPComponent)
get_logger)AudioFileImageNotSetNotSetT)	PrefabApp)	ComponentTF)Docket)	ExecutionFunctionTool)ArgTransformTransformedToolr	   ToolResultSerializerTypec                    V ^8  d   QhRRRR/# )   datar   returnstr )formats   "X/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fastmcp/tools/tool.py__annotate__r2   @   s     > >S >S >    c                V    \         P                  ! V \        R 7      P                  4       # ))fallback)pydantic_coreto_jsonr.   decode)r,   s   &r1   default_serializerr9   @   s      4;;==r3   c                     a  ] tR t^Dt$ ]! RR7      tR]R&   ]! RRR7      tR]R	&   ]! RR
R7      tR]R&   RR V 3R lllt	R R lt
RtV ;t# )
ToolResultz*List of content blocks for the tool result)descriptionlist[ContentBlock]contentNz4Structured content matching the tool's output schema)defaultr<   dict[str, Any] | Nonestructured_contentz)Runtime metadata about the tool executionmetac               $    V ^8  d   QhRRRRRR/# )r+   r>   zlist[ContentBlock] | Any | NonerA   zdict[str, Any] | Any | NonerB   r@   r/   )r0   s   "r1   r2   ToolResult.__annotate__O   s(     (
 (
0(
 8(
 $	(
r3   c                	V  < Vf   Vf   \        R4      hVf   Tp\        VR7      pVe   \        '       dX   \        V\        4      '       d   VP                  4       pM0\        V\        4      '       d   \	        VR7      P                  4       p \        P                  ! VR7      p\        T\        4      '       g'   \        R\        T4      P                   RT: R24      h\        SV `A  WBVR	7       R #   \        P                   d   p\        P                  RT 24       h R p?ii ; i)
Nz5Either content or structured_content must be provided)resultview)valuezCould not serialize structured content. If this is unexpected, set your tool's output_schema to None to disable automatic serialization: z/structured_content must be a dict or None. Got z: zA. Tools should wrap non-dict values based on their output_schema.)r>   rA   rB   )
ValueError_convert_to_content_HAS_PREFAB
isinstance
_PrefabAppr7   _PrefabComponentr6   to_jsonable_pythonPydanticSerializationErrorloggererrordicttype__name__super__init__)selfr>   rA   rB   converted_contente	__class__s   &&&&  r1   rX   ToolResult.__init__O   s>    ?19TUU_(G0C70S) {0*==);)C)C)E& 24DEE)39K)L)T)T)V&%2%E%E,&" 0$77  23<<=R@R?U VVV  	%SW 	 	
 !;;  `  ab  `c  d 	s   C5 5D(
D##D(c                   V ^8  d   QhRR/# )r+   r-   zOlist[ContentBlock] | tuple[list[ContentBlock], dict[str, Any]] | CallToolResultr/   )r0   s   "r1   r2   rD   y   s     5 5 	X5r3   c                	    V P                   e-   \        V P                  V P                  V P                   R7      # V P                  f   V P                  # V P                  V P                  3# )N)structuredContentr>   _meta)rB   r   rA   r>   rY   s   &r1   to_mcp_resultToolResult.to_mcp_resulty   s_    
 99 !"&"9"9ii 
 ""*<<||T4444r3   r/   )NNN)rV   
__module____qualname____firstlineno__r   r>   __annotations__rA   rB   rX   rc   __static_attributes____classcell__r\   s   @r1   r;   r;   D   sb    "'@#G  16"X1-  #("M#D
 (
 (
T5 5r3   r;   c                    a  ] tR t^t$ RtRtR]R&   R]R&   RtR]R	&   RtR
]R&   Rt	R]R&   Rt
R]R&   RtR]R&   RtR]R&   ]! RR7      R R l4       tR R lt]RRRRRRRRRRRRRRR RR	]RRR!RR"RRRRR/R# R$ ll4       tR% R& ltR' R( lt]R>R) R* ll4       t]R+ R, l4       tR>R- R. lltR/ R0 ltR1RR2R/R3 R4 llt]RRR]R]RRR]R	]RRR!]R5RR6R/
R7 R8 ll4       t]R9 R: l4       tR; V 3R< lltR=tV ;t# )?r   z Internal tool registration info.toolzClassVar[str]
KEY_PREFIXzOAnnotated[dict[str, Any], Field(description='JSON schema for tool parameters')]
parametersNzRAnnotated[dict[str, Any] | None, Field(description='JSON schema for tool output')]output_schemaz]Annotated[ToolAnnotations | None, Field(description='Additional annotations about the tool')]r   z]Annotated[ToolExecution | None, Field(description='Task execution configuration (SEP-1686)')]	executionzAnnotated[SkipJsonSchema[ToolResultSerializerType | None], Field(description='Deprecated. Return ToolResult from your tools for full control over serialization.')]
serializerzAnnotated[SkipJsonSchema[AuthCheck | list[AuthCheck] | None], Field(description='Authorization checks for this tool', exclude=True)]authzkAnnotated[float | None, Field(description='Execution timeout in seconds. If None, no timeout is applied.')]timeoutafter)modec                   V ^8  d   QhRR/# )r+   r-   r   r/   )r0   s   "r1   r2   Tool.__annotate__   s      T r3   c                0    \        V P                  4       V # )z<Validate tool name according to MCP specification (SEP-986).)r   namerb   s   &r1   _validate_tool_nameTool._validate_tool_name   s     	$DII.r3   c                    V ^8  d   QhRRRR/# )r+   	overridesr   r-   MCPToolr/   )r0   s   "r1   r2   rx      s     
 

 

r3   c                   RpV P                   '       d   V P                   pMDV P                  '       d3   V P                  P                   '       d   V P                  P                   p\        VP                  RV P                  4      VP                  RV4      VP                  RV P
                  4      VP                  RV P                  4      VP                  RV P                  4      VP                  RV P                  4      VP                  RV P                  4      VP                  R	V P                  4      VP                  R
V P                  4       4      R7	      # )z(Convert the FastMCP tool to an MCP tool.Nrz   titler<   inputSchemaoutputSchemaiconsr   rq   ra   )	rz   r   r<   r   r   r   r   rq   ra   )r   r   r   getrz   r<   ro   rp   r   rq   get_meta)rY   r~   r   s   &, r1   to_mcp_toolTool.to_mcp_tool   s    
 :::JJE$"2"2"8"8"8$$**Evtyy1--/!mT5E5EF!mT__E"~t7I7IJ--4!mT5E5EFmmK@--
 	
r3   rz   versionr   r<   r   tagsexclude_argsrB   taskc                X    V ^8  d   QhRRRRRRRRRRR	R
RRRRRRRRRRRRRRRRRRRR/# )r+   fnzCallable[..., Any]rz   
str | Noner   zstr | int | Noner   r<   r   zlist[Icon] | Noner   set[str] | Noner   zToolAnnotations | Noner   zlist[str] | Nonerp   dict[str, Any] | NotSetT | Nonerr   ToolResultSerializerType | NonerB   r@   r   zbool | TaskConfig | Nonert   zfloat | Noners   z"AuthCheck | list[AuthCheck] | Noner-   r&   r/   )r0   s   "r1   r2   rx      s     &
 &
&
 	&

 "&
 &
  &
 !&
 &
 ,&
 '&
 7&
 4&
 $&
 '&
  !&
" 1#&
$ 
%&
r3   c               P    ^ RI Hp VP                  ! VVVVVVVVV	V
VVVVVR7      # )zCreate a Tool from a function.r%   )r   rz   r   r   r<   r   r   r   r   rp   rr   rB   r   rt   rs   )fastmcp.tools.function_toolr&   from_function)clsr   rz   r   r   r<   r   r   r   r   rp   rr   rB   r   rt   rs   r&   s   &&$$$$$$$$$$$$$$ r1   r   Tool.from_function   sG    * 	=))##%'!
 	
r3   c                    V ^8  d   QhRRRR/# )r+   	argumentsdict[str, Any]r-   r;   r/   )r0   s   "r1   r2   rx      s     
E 
E> 
Ej 
Er3   c                    "   \        R4      h5i)z
Run the tool with arguments.

This method is not implemented in the base Tool class and must be
implemented by subclasses.

`run()` can EITHER return a list of ContentBlocks, or a tuple of
(list of ContentBlocks, dict of structured output).
zSubclasses must implement run())NotImplementedError)rY   r   s   &&r1   runTool.run   s      ""CDDs   c                    V ^8  d   QhRRRR/# )r+   	raw_valuer   r-   r;   r/   )r0   s   "r1   r2   rx     s     ,
 ,
 ,

 ,
r3   c                   \        V\        4      '       d   V# \        '       dM   \        V\        4      '       d   \	        V4      # \        V\
        4      '       d   \	        \        VR7      4      # \        WP                  R7      pV P                  f   \        V\        \        ,          \        ,          \        ,          4      '       g\   \        V\        \        ,          4      '       dG   \        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   \        VR7      #  \         P"                  ! V4      pT P                  f/   \        T\&        4      '       d   \        Y#R7      # \        TR7      # T P                  P)                  R4      p\        TT'       d
   R	T/R7      # TR7      #   \         P$                   d    \        TR7      u # i ; i)
zConvert a raw result to ToolResult.

Handles ToolResult passthrough and converts raw values using the tool's
attributes (serializer, output_schema) for proper conversion.
rG   )rr   c              3  B   "   T F  p\        V\        4      x  K  	  R # 5iNrM   r   .0items   & r1   	<genexpr>&Tool.convert_result.<locals>.<genexpr>  s     M94
4669   TF)r>   r>   rA   zx-fastmcp-wrap-resultrF   )rM   r;   rL   rN   _prefab_to_tool_resultrO   rK   rr   rp   r   r   r   r   listtupleanyr6   rP   rQ   rT   r   )rY   r   r>   
structuredwrap_results   &&   r1   convert_resultTool.convert_result  sq    i,,;)Z00-i88)%566-ji.HII%iOOL %y,"6">"EFF9dUl33CM9MCCCM9MMM g..	/&99)DJ %*d++!'QQg.. ((,,-DE9D*5
 	
JT
 	
 77 	/g..	/s   4F? ?!G#"G#c               $    V ^8  d   QhRRRRRR/# )r+   r   r   	task_metaNoner-   r;   r/   )r0   s   "r1   r2   rx   1  s(      !  
	r3   c                	   "   R # 5ir   r/   rY   r   r   s   &&&r1   _run	Tool._run0  s
     
    c               $    V ^8  d   QhRRRRRR/# )r+   r   r   r   r   r-   zmcp.types.CreateTaskResultr/   )r0   s   "r1   r2   rx   8  s(     ) )!) ) 
$	)r3   c                	   "   R # 5ir   r/   r   s   &&&r1   r   r   7  s
     
 &)r   c               $    V ^8  d   QhRRRRRR/# )r+   r   r   r   zTaskMeta | Noner-   z'ToolResult | mcp.types.CreateTaskResultr/   )r0   s   "r1   r2   rx   >  s(     $) $)!$) #$) 
1	$)r3   c                   "   ^ RI Hp V! V RVVR7      G Rj  xL
 pV'       d   V# V P                  V4      G Rj  xL
 #  L' L5i)a  Server entry point that handles task routing.

This allows ANY Tool subclass to support background execution by setting
task_config.mode to "supported" or "required". The server calls this
method instead of run() directly.

Args:
    arguments: Tool arguments
    task_meta: If provided, execute as background task and return
        CreateTaskResult. If None (default), execute synchronously and
        return ToolResult.

Returns:
    ToolResult when task_meta is None.
    CreateTaskResult when task_meta is provided.

Subclasses can override this to customize task routing behavior.
For example, FastMCPProviderTool overrides to delegate to child
middleware without submitting to Docket.
)check_background_taskrm   )	component	task_typer   r   N)fastmcp.server.tasks.routingr   r   )rY   r   r   r   task_results   &&&  r1   r   r   >  sM     2 	G1	
 
 XXi(((
 )s$   AA AAAAAc                    V ^8  d   QhRRRR/# )r+   docketr#   r-   r   r/   )r0   s   "r1   r2   rx   d  s     4 46 4d 4r3   c                    V P                   P                  4       '       g   R# VP                  V P                  V P                  .R7       R# )z8Register this tool with docket for background execution.N)names)task_configsupports_tasksregisterr   key)rY   r   s   &&r1   register_with_docketTool.register_with_docketd  s4    ..00
3r3   fn_keytask_keyc               0    V ^8  d   QhRRRRRRRRRR	R
R/# )r+   r   r#   r   r   r   r   r   kwargsr   r-   r$   r/   )r0   s   "r1   r2   rx   j  sN     A AA "A
 A A A 
Ar3   c                  "   T;'       g    V P                   pV'       d   WER&   VP                  ! V3/ VB ! V4      G Rj  xL
 #  L5i)a-  Schedule this tool for background execution via docket.

Args:
    docket: The Docket instance
    arguments: Tool arguments
    fn_key: Function lookup key in Docket registry (defaults to self.key)
    task_key: Redis storage key for the result
    **kwargs: Additional kwargs passed to docket.add()
r   N)r   add)rY   r   r   r   r   r   
lookup_keys   &&&$$, r1   add_to_docketTool.add_to_docketj  sA     $ ''txx
$5MZZ
5f5i@@@@s   A AAAtransform_argstransform_fnc               H    V ^8  d   QhRRRRRRRRRR	R
RRRRRRRRRRRRR/# )r+   rm   Tool | Callable[..., Any]rz   r   r   zstr | NotSetT | Noner<   r   r   r   z ToolAnnotations | NotSetT | Nonerp   r   rr   r   rB   r   zdict[str, ArgTransform] | Noner   zCallable[..., Any] | Noner-   r(   r/   )r0   s   "r1   r2   rx     s     
 
'
 	

 $
 *
 
 6
 7
 4
 .
 7
 0
 

r3   c       
        	j    ^ RI Hp V P                  V4      pVP                  ! VVVVV
VVVVVV	R7      # )r   )r(   )rm   r   rz   r   r   r<   r   r   rp   rr   rB   )fastmcp.tools.tool_transformr(   _ensure_tool	from_tool)r   rm   rz   r   r<   r   r   rp   rr   rB   r   r   r(   s   &&$$$$$$$$$$ r1   r   Tool.from_tool  sL      	A%((%)##'!
 	
r3   c                    V ^8  d   QhRRRR/# )r+   rm   r   r-   r   r/   )r0   s   "r1   r2   rx     s     ' ' 9 'd 'r3   c                    \        V\        4      '       d   V# ^ RIHp ^ RIHpHp V! V4      p\        WT4      '       d   VP                  ! WR7      # V P                  V4      # )zCCoerce a callable into a Tool, respecting @tool decorator metadata.)get_fastmcp_meta)r&   ToolMeta)metadata)rM   r   fastmcp.decoratorsr   r   r&   r   r   )r   rm   r   r&   r   fmetas   &&    r1   r   Tool._ensure_tool  sS     dD!!K7F &e&&--dCC  &&r3   c                   V ^8  d   QhRR/# )r+   r-   r   r/   )r0   s   "r1   r2   rx     s     
 
^ 
r3   c                	6   < \         SV `  4       R RRR/,          # )zfastmcp.component.typerm   zfastmcp.provider.typeLocalProvider)rW   get_span_attributes)rY   r\   s   &r1   r   Tool.get_span_attributes  s'    w*,$f#_0
 
 	
r3   r/   r   )rV   re   rf   rg   __doc__rn   rh   rp   r   rq   rr   rs   rt   r   r{   r   classmethodr   r   r   r   r
   r   r   r   r   r   r   ri   rj   rk   s   @r1   r   r      sE   * &J& 
 	    	    	    	    	 	   	    '" #

4 &
  	&

 %)&
 !&
 #'&
 $(&
 !%&
 /3&
 *.&
 :@&
 7;&
 '+&
 *.&
  !%!&
" 48#&
 &
P
E,
\   ) )$)L4A
 "A  $A. 
  	

 '-
 -3
 !%
 9?
 :@
 7;
 17
 :>
 37
 
B ' '
 
r3   r   c               $    V ^8  d   QhRRRRRR/# )r+   rF   r   rr   r   r-   r.   r/   )r0   s   "r1   r2   r2     s$     & &&<&&r3   c                    Ve
    V! V 4      # \        V 4      #   \          d#   p\        P                  RTRR7        R p?L3R p?ii ; i)Nz!Error serializing tool result: %sT)exc_info)	ExceptionrR   warningr9   )rF   rr   r[   s   && r1   _serialize_with_fallbackr     sX     	f%% f%%  	NN3   	s    AAAc               $    V ^8  d   QhRRRRRR/# )r+   r   r   rr   r   r-   r   r/   )r0   s   "r1   r2   r2     s+     U U
U/U Ur3   c                   \        V \        4      '       d   V # \        V \        4      '       d   V P                  4       # \        V \        4      '       d   V P                  4       # \        V \        4      '       d   V P                  4       # \        V \        4      '       d   \        R V R7      # \        R \        W4      R7      # )textrU   r   )rM   r   r   to_image_contentr   to_audio_contentr   to_resource_contentr.   r   r   )r   rr   s   &&r1    _convert_to_single_content_blockr     s     $%%$$$&&$$$&&$''))$T22F)A$)STTr3   z[Rendered Prefab UI]c                    V ^8  d   QhRRRR/# )r+   appr   r-   r;   r/   )r0   s   "r1   r2   r2     s       
 r3   c                X    \        \        R\        R7      .V P                  4       R7      # )z,Convert a PrefabApp to a FastMCP ToolResult.r   r   r   )r;   r   _PREFAB_TEXT_FALLBACKr7   )r   s   &r1   r   r     s&    &/DEF;;= r3   c               $    V ^8  d   QhRRRRRR/# )r+   rF   r   rr   r   r-   r=   r/   )r0   s   "r1   r2   r2     s+     Y YY/Y Yr3   c                   V f   . # \        V \        \        ,          4      '       g   \        W4      .# \        ;QJ d    R V  4       F  '       d   K   RM	  RM! R V  4       4      '       d   V # \
        ;QJ d    R V  4       F  '       g   K   RM	  RM! R V  4       4      '       d4   V  Uu. uF&  p\        V\        4      '       g   \        W!4      MTNK(  	  up# \        R\        W4      R7      .# u upi )z2Convert a result to a sequence of content objects.c              3  B   "   T F  p\        V\        4      x  K  	  R # 5ir   r   r   s   & r1   r   &_convert_to_content.<locals>.<genexpr>  s     
=fd:dL))fr   FTc              3     "   T F6  p\        V\        \        ,          \        ,          \        ,          4      x  K8  	  R # 5ir   )rM   r   r   r   r   r   s   & r1   r   r    s)     
TVT:dL50584?@@Vs   >A r   r   )	rM   r   r   r   allr   r   r   r   )rF   rr   r   s   && r1   rK   rK     s     ~	fte|--0DEE s
=f
=sss
=f
=== s
TV
Tsss
TV
TTT
 	
  dL11 -T> 	
 	
 V*B6*VWXX
s   .,C4c                    V ^8  d   QhRRRR/# )r+   rz   r.   r-   r   r/   )r0   s   "r1   r2   r2   
  s     K Kc Kc Kr3   c                    RRRRRR/pW9   dS   ^ RI pVP                  P                  '       d"   \        P                  ! RV  R2\
        ^R7       ^ RIHp \        W04      # \        R	\        : R
V : 24      h)z2Deprecated re-exports for backwards compatibility.r&   ParsedFunctionrm   Nz
Importing zX from fastmcp.tools.tool is deprecated. Import from fastmcp.tools.function_tool instead.)
stacklevel)function_toolzmodule z has no attribute )fastmcpsettingsdeprecation_warningswarningswarnDeprecationWarningfastmcp.toolsr  getattrAttributeErrorrV   )rz   deprecated_exportsr  r  s   &   r1   __getattr__r  
  s     	* !000MMTF #C D"	 	0}++
78,.@I
JJr3   r   )N__conditional_annotations__
__future__r   r  collections.abcr   typingr   r   r   r   r	   r
   	mcp.typesmcpr6   mcp.shared.tool_name_validationr   r   r   r   r   r   r   r   r   pydanticr   r   r   pydantic.json_schemar   !fastmcp.server.auth.authorizationr   fastmcp.server.tasks.configr   r   fastmcp.utilities.componentsr   fastmcp.utilities.loggingr   fastmcp.utilities.typesr   r   r   r   r    prefab_ui.appr!   rN   prefab_ui.components.baser"   rO   rL   ImportErrorr   r#   docket.executionr$   r   r&   r   r'   r(   rV   rR   r.   r)   rh   r9   r;   r   r   r  r   rK   __all__r  )r  s   @r1   <module>r+     s   " "  $    G  & 6 6 / 7 < 9 0 5GK *8J 
H	 '/ucz&: ) :>B5 B5Jm
 m
`	& U, / Y: <
 Ky  Ks   D 	DD