+
    Q(ie7                       R t ^ RIHt ^ RIt^ RIHt ^ RIHtH	t	H
t
HtHt ^ RIt^ RIt]'       d   ^ RIHt ^ RIHt ^ RIHt ^ RIt^ RIHt ^ R	IHtHtHtHt ^ R
IHt ^ RIHt ^ RI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- ]+! ].4      t/ ! R R]P`                  4      t1 ! R R]-4      t ! R R]P`                  4      t2 ! R R])4      t. ROt3R R lt4R# )z!Base classes for FastMCP prompts.)annotationsN)Callable)TYPE_CHECKINGAnyClassVarLiteraloverload)Docket)	ExecutionFunctionPrompt)GetPromptResult)EmbeddedResourceIconPromptMessageTextContent)Prompt)PromptArgument)Field)SkipJsonSchema)	AuthCheck)
TaskConfigTaskMeta)FastMCPComponent)
get_logger)FastMCPBaseModelc                  X   a  ] tR t^)t$ RtR]R&   R]R&   RR V 3R llltR R	 ltR
tV ;t	# )Messagea  Wrapper for prompt message with auto-serialization.

Accepts any content - strings pass through, other types
(dict, list, BaseModel) are JSON-serialized to text.

Example:
    ```python
    from fastmcp.prompts import Message

    # String content (user role by default)
    Message("Hello, world!")

    # Explicit role
    Message("I can help with that.", role="assistant")

    # Auto-serialized to JSON
    Message({"key": "value"})
    Message(["item1", "item2"])
    ```
Literal['user', 'assistant']rolezTextContent | EmbeddedResourcecontentc                    V ^8  d   QhRRRR/# )   r    r   r   r    )formats   "\/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fastmcp/prompts/prompt.py__annotate__Message.__annotate__B   s"     @ @@ +@    c                  < \        V\        \        34      '       d   TpM[\        V\        4      '       d   \        RVR7      pM7\        P
                  ! V\        R7      P                  4       p\        RVR7      p\        SV `!  W#R7       R# )a/  Create Message with automatic serialization.

Args:
    content: The message content. str passes through directly.
             TextContent and EmbeddedResource pass through.
             Other types (dict, list, BaseModel) are JSON-serialized.
    role: The message role, either "user" or "assistant".
text)typer*   )fallbackr   r    N)	
isinstancer   r   strpydantic_coreto_jsondecodesuper__init__)selfr    r   normalized_content
serialized	__class__s   &&&  r%   r4   Message.__init__B   sr     g-=>??AH%%!,&w!G '..wELLNJ!,&z!Jd?r(   c                   V ^8  d   QhRR/# )r"   returnr   r#   )r$   s   "r%   r&   r'   [   s     C C} Cr(   c                D    \        V P                  V P                  R7      # )zConvert to MCP PromptMessage.r-   )r   r   r    )r5   s   &r%   to_mcp_prompt_messageMessage.to_mcp_prompt_message[   s    $))T\\BBr(   r#   )user)
__name__
__module____qualname____firstlineno____doc____annotations__r4   r=   __static_attributes____classcell__r8   s   @r%   r   r   )   s.    * '&++@ @2C Cr(   r   c                  t    ] tR t^`t$ Rt]! RR7      tR]R&   ]! RRR7      tR	]R
&   ]! RRR7      t	R]R&   Rt
R# )r   z+An argument that can be passed to a prompt.zName of the argument)descriptionr/   nameNz%Description of what the argument doesdefaultrJ   
str | NonerJ   Fz Whether the argument is requiredboolrequiredr#   )r@   rA   rB   rC   rD   r   rK   rE   rJ   rP   rF   r#   r(   r%   r   r   `   sE    5"89D#9#"IK  #EHd r(   r   c                     a  ] tR t^lt$ RtR]R&   RtR]R&   RtR]R&   RR	 V 3R
 lllt]	R R l4       t
R R ltRtV ;t# )PromptResulta  Canonical result type for prompt rendering.

Provides explicit control over prompt responses: multiple messages,
roles, and metadata at both the message and result level.

Accepts:
    - str: Wrapped as single Message (user role)
    - list[Message]: Used directly for multiple messages or custom roles

Example:
    ```python
    from fastmcp import FastMCP
    from fastmcp.prompts import PromptResult, Message

    mcp = FastMCP()

    # Simple string content
    @mcp.prompt
    def greet() -> PromptResult:
        return PromptResult("Hello!")

    # Multiple messages with roles
    @mcp.prompt
    def conversation() -> PromptResult:
        return PromptResult([
            Message("What's the weather?"),
            Message("It's sunny today.", role="assistant"),
        ])
    ```
list[Message]messagesNrN   rJ   dict[str, Any] | Nonemetac               $    V ^8  d   QhRRRRRR/# )r"   rT   str | list[Message]rJ   rN   rV   rU   r#   )r$   s   "r%   r&   PromptResult.__annotate__   s-     R R%R  R $	Rr(   c                L   < V P                  V4      p\        SV `	  WBVR7       R# )zCreate PromptResult.

Args:
    messages: String or list of Message objects.
    description: Optional description of the prompt result.
    meta: Optional metadata about the prompt result.
)rT   rJ   rV   N)_normalize_messagesr3   r4   )r5   rT   rJ   rV   
normalizedr8   s   &&&& r%   r4   PromptResult.__init__   s'     --h7
*DQr(   c                    V ^8  d   QhRRRR/# )r"   rT   rX   r;   rS   r#   )r$   s   "r%   r&   rY      s     
 
%
	
r(   c           
     ^   \        V \        4      '       d   \        V 4      .# \        V \        4      '       dV   \	        V 4       FD  w  r\        V\        4      '       d   K  \        RV R\        V4      P                   RV: R24      h	  V # \        R\        V 4      P                   24      h)z!Normalize input to list[Message].	messages[z] must be Message, got . Use Message() to wrap the value.z+messages must be str or list[Message], got )r.   r/   r   list	enumerate	TypeErrorr+   r@   )rT   iitems   &  r%   r[    PromptResult._normalize_messages   s    
 h$$H%&&h%%$X.!$00##A3&=d4j>Q>Q=R S''+h.BD  / O9$x.:Q:Q9RS
 	
r(   c                   V ^8  d   QhRR/# )r"   r;   r   r#   )r$   s   "r%   r&   rY      s     
 
o 
r(   c                    V P                    Uu. uF  qP                  4       NK  	  pp\        V P                  VV P                  R7      # u upi )zConvert to MCP GetPromptResult.)rJ   rT   _meta)rT   r=   r   rJ   rV   )r5   mmcp_messagess   &  r%   to_mcp_prompt_result!PromptResult.to_mcp_prompt_result   sG    ;?==I=a//1=I((!))
 	
 Js   Ar#   NN)r@   rA   rB   rC   rD   rE   rJ   rV   r4   staticmethodr[   rn   rF   rG   rH   s   @r%   rR   rR   l   sO    > "K""&D
&R R  
 
&
 
r(   rR   c                  J  a  ] tR t^t$ RtRtR]R&   ]! RRR7      tR]R	&   ]! RR
RR7      t	R]R&   R R lt
]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 R l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% R& ltR'RR(R/R) R* lltR+ V 3R, lltR-tV ;t# )0r   z7A prompt template that can be rendered with parameters.promptzClassVar[str]
KEY_PREFIXNz*Arguments that can be passed to the promptrL   zlist[PromptArgument] | None	argumentsz$Authorization checks for this promptT)rM   rJ   excludez2SkipJsonSchema[AuthCheck | list[AuthCheck] | None]authc                    V ^8  d   QhRRRR/# )r"   	overridesr   r;   	SDKPromptr#   )r$   s   "r%   r&   Prompt.__annotate__   s     
 

 

r(   c                   V P                   ;'       g    .  Uu. uF/  p\        VP                  VP                  VP                  R7      NK1  	  pp\        VP                  RV P                  4      VP                  RV P                  4      VVP                  RV P                  4      VP                  RV P                  4      VP                  RV P                  4       4      R7      # u upi )z$Convert the prompt to an MCP prompt.)rK   rJ   rP   rK   rJ   titleiconsrk   )rK   rJ   ru   r}   r~   rk   )
ru   SDKPromptArgumentrK   rJ   rP   rz   getr}   r~   get_meta)r5   ry   argru   s   &,  r%   to_mcp_promptPrompt.to_mcp_prompt   s     ~~+++
 , XXOO
 , 	 
 vtyy1!mT5E5EF--4--4--	
 		

s   5C'rK   versionr}   rJ   r~   tagsrV   taskc               D    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"   fnzCallable[..., Any]rK   rN   r   zstr | int | Noner}   rJ   r~   zlist[Icon] | Noner   zset[str] | NonerV   rU   r   zbool | TaskConfig | Nonerw   z"AuthCheck | list[AuthCheck] | Noner;   r   r#   )r$   s   "r%   r&   r{      sx     "
 "
"
 	"

 ""
 "
  "
 !"
 "
 $"
 '"
 1"
 
"
r(   c       	        F    ^ RI Hp VP                  ! VVVVVVVVV	V
R7
      # )zCreate a Prompt from a function.

The function can return:
- str: wrapped as single user Message
- list[Message | str]: converted to list[Message]
- PromptResult: used directly
r   )
r   rK   r   r}   rJ   r~   r   rV   r   rw   )fastmcp.prompts.function_promptr   from_function)clsr   rK   r   r}   rJ   r~   r   rV   r   rw   r   s   &&$$$$$$$$$ r%   r   Prompt.from_function   s9    , 	C++#
 	
r(   c                    V ^8  d   QhRRRR/# )r"   ru   rU   r;   z(str | list[Message | str] | PromptResultr#   )r$   s   "r%   r&   r{     s"     H H(H 
2Hr(   c                    "   \        R4      h5i)zRender the prompt with arguments.

Subclasses must implement this method. Return one of:
- str: Wrapped as single user Message
- list[Message | str]: Converted to list[Message]
- PromptResult: Used directly
z"Subclasses must implement render())NotImplementedError)r5   ru   s   &&r%   renderPrompt.render  s      ""FGGs   c                    V ^8  d   QhRRRR/# )r"   	raw_valuer   r;   rR   r#   )r$   s   "r%   r&   r{     s     "
 "
 "
 "
r(   c           
        \        V\        4      '       d   V# \        V\        4      '       d"   \        WP                  V P                  R7      # \        V\
        \        ,          4      '       d   . p\        V4       F  w  r4\        V\        4      '       d   VP                  V4       K.  \        V\        4      '       d   VP                  \        V4      4       K`  \        RV R\        V4      P                   RV: R24      h	  \        W P                  V P                  R7      # \        R\        V4      P                   24      h)zConvert a raw return value to PromptResult.

Accepts:
    - PromptResult: passed through
    - str: wrapped as single Message
    - list[Message | str]: converted to list[Message]

Raises:
    TypeError: for unsupported types
)rJ   rV   r`   z] must be Message or str, got ra   rb   z<Prompt must return str, list[Message], or PromptResult, got )r.   rR   r/   rJ   rV   rc   tuplerd   r   appendre   r+   r@   )r5   r   rT   rf   rg   s   &&   r%   convert_resultPrompt.convert_result  s    i..i%%	7G7GdiiXXi..&(H$Y/dG,,OOD)c**OOGDM2##A3&DT$ZEXEXDY Z''+h.BD  0  6F6FTYYWW	?++,.
 	
r(   c               $    V ^8  d   QhRRRRRR/# )r"   ru   rU   	task_metaNoner;   rR   r#   )r$   s   "r%   r&   r{   :  s(      (  
	r(   c                	   "   R # 5iNr#   r5   ru   r   s   &&&r%   _renderPrompt._render9  s
     
    c               $    V ^8  d   QhRRRRRR/# )r"   ru   rU   r   r   r;   zmcp.types.CreateTaskResultr#   )r$   s   "r%   r&   r{   A  s(     ) )() ) 
$	)r(   c                	   "   R # 5ir   r#   r   s   &&&r%   r   r   @  s
     
 &)r   c               $    V ^8  d   QhRRRRRR/# )r"   ru   rU   r   zTaskMeta | Noner;   z)PromptResult | mcp.types.CreateTaskResultr#   )r$   s   "r%   r&   r{   G  s(     &+ &+(&+ #&+ 
3	&+r(   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
 pV P                  V4      #  L8 L5i)a  Server entry point that handles task routing.

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

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

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

Subclasses can override this to customize task routing behavior.
For example, FastMCPProviderPrompt overrides to delegate to child
middleware without submitting to Docket.
)check_background_taskrs   )	component	task_typeru   r   N)fastmcp.server.tasks.routingr   r   r   )r5   ru   r   r   task_resultresults   &&&   r%   r   r   G  s_     2 	G1	
 
  {{9--""6**
 .s$   AAAAAAAc                    V ^8  d   QhRRRR/# )r"   docketr	   r;   r   r#   )r$   s   "r%   r&   r{   o  s     7 76 7d 7r(   c                    V P                   P                  4       '       g   R# VP                  V P                  V P                  .R7       R# )z:Register this prompt with docket for background execution.N)names)task_configsupports_tasksregisterr   key)r5   r   s   &&r%   register_with_docketPrompt.register_with_docketo  s4    ..00DHH:6r(   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	   ru   rU   r   rN   r   kwargsr   r;   r
   r#   )r$   s   "r%   r&   r{   u  sN     A AA )A
 A A A 
Ar(   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)a1  Schedule this prompt for background execution via docket.

Args:
    docket: The Docket instance
    arguments: Prompt 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)r5   r   ru   r   r   r   
lookup_keys   &&&$$, r%   add_to_docketPrompt.add_to_docketu  sA     $ ''txx
$5MZZ
5f5i@@@@s   A AAAc                   V ^8  d   QhRR/# )r"   r;   zdict[str, Any]r#   )r$   s   "r%   r&   r{     s     
 
^ 
r(   c                	6   < \         SV `  4       R RRR/,          # )zfastmcp.component.typers   zfastmcp.provider.typeLocalProvider)r3   get_span_attributes)r5   r8   s   &r%   r   Prompt.get_span_attributes  s'    w*,$h#_0
 
 	
r(   r#   r   rp   )r@   rA   rB   rC   rD   rt   rE   r   ru   rw   r   classmethodr   r   r   r   r   r   r   r   rF   rG   rH   s   @r%   r   r      s!   A (J(-2"N.I*  @E"HRV@D
< 
2 "
  	"

 %)"
 !"
 #'"
 $("
 !%"
 '+"
 *."
 48"
 "
HH"
H   ) )&+P7A
 "A  $A.
 
r(   r   c                    V ^8  d   QhRRRR/# )r"   rK   r/   r;   r   r#   )r$   s   "r%   r&   r&     s     K Kc Kc Kr(   c                    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   rs   Nz
Importing z` from fastmcp.prompts.prompt is deprecated. Import from fastmcp.prompts.function_prompt instead.)
stacklevel)function_promptzmodule z has no attribute )fastmcpsettingsdeprecation_warningswarningswarnDeprecationWarningfastmcp.promptsr   getattrAttributeErrorr@   )rK   deprecated_exportsr   r   s   &   r%   __getattr__r     s     	*(
 !000MMTF #G H"	 	4--
78,.@I
JJr(   )r   r   r   rR   )5rD   
__future__r   _annotationsr   collections.abcr   typingr   r   r   r   r   pydanticr0   r   r	   docket.executionr
   r   r   	mcp.typesmcpr   r   r   r   r   r   rz   r   r   r   pydantic.json_schemar   !fastmcp.server.auth.authorizationr   fastmcp.server.tasks.configr   r   fastmcp.utilities.componentsr   fastmcp.utilities.loggingr   fastmcp.utilities.typesr   r@   logger	BaseModelr   rR   __all__r   r#   r(   r%   <module>r      s    ' 2  $ B B  *>    * 9  / 7 < 9 0 
H	4Ch   4Cn	% 	O
8%% O
dR
 R
jKr(   