+
    Q(i#                       R t ^ RIHt ^ RIt^ RIHt ^ RIHtHt ^ RIH	t	H
t
Ht ^ RIt^ RIHt ^ RIHtHt ^ RIHtHtHt ^ R	IHt ^ R
IHt ^ RIHt ]	'       d   ^ RIHt ^ RIHt ^ RI H!t! ^ RI"H#t# ]! ]$4      t%Rt&RR R llt'R# )zrSEP-1686 task execution handlers.

Handles queuing tool/prompt/resource executions to Docket as background tasks.
)annotationsN)suppress)datetimetimezone)TYPE_CHECKINGAnyLiteral)McpError)INTERNAL_ERROR	ErrorData)_current_docketget_access_tokenget_context)TaskMeta)build_task_key)
get_logger)Prompt)Resource)ResourceTemplate)Toolc               0    V ^8  d   QhRRRRRRRRR	R
RR/# )   	task_typez1Literal['tool', 'resource', 'template', 'prompt']keystr	componentz+Tool | Resource | ResourceTemplate | Prompt	argumentszdict[str, Any] | None	task_metazTaskMeta | Nonereturnzmcp.types.CreateTaskResult )formats   "c/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fastmcp/server/tasks/handlers.py__annotate__r"   "   sL      @	 ; %	
       c                  aa"   \        \        P                  ! 4       4      p\        P                  ! \
        P                  4      p\        4       p VP                  o\        P                  ! 4       pVf   \        \        \        RR7      4      h\        SWPV4      p	Ve   VP                   e   VP                   p
M*\#        VP$                  P'                  4       R,          4      p
\#        V
R,          4      \(        ,           pVP+                  RS RV 24      pVP+                  RS RV R24      pVP+                  RS RV R	24      pVP+                  RS RV R
24      p\#        VP,                  P.                  P'                  4       R,          4      pVP0                  e    \        VP0                  P2                  4      MRp\5        4       pVP+                  RS RV R24      pVP7                  4       ;_uu_4       GRj  xL
 pVP9                  WVR7      G Rj  xL
  VP9                  WP;                  4       VR7      G Rj  xL
  VP9                  V\        V4      VR7      G Rj  xL
  Ve   VP9                  VVVR7      G Rj  xL
  Ve+   VP9                  VVP=                  4       VR7      G Rj  xL
  RRR4      GRj  xL
  SR8w  d   ^ RIH p V! SVPB                  4       \D        PF                  PH                  PK                  RRRRVRRRRRVRVRV
RV/RRRV///4      p\D        PF                  PM                  V4      p\O        \P        4      ;_uu_ 4        VPB                  PS                  V4      G Rj  xL
  RRR4       V R8X  d   VPU                  WV	R7      G Rj  xL
  MVPU                  WWR7      G Rj  xL
  ^ RI+H,p \[        VPB                  R4      '       d?   VPB                  P\                  pV'       d!   VP_                  VVV	VPB                  VV4       ^ R I0H1pH2o  V! SVPB                  WPf                  4      G Rj  xL
  \[        VPB                  R!4      '       dv   VPB                  Ph                  e^   \k        VPB                  R"R#4      '       gA   R$ VV3R% llpVPB                  Ph                  Pm                  V4       R&VPB                  n7        \D        PF                  Pu                  \D        PF                  Pw                  TRTTT
TR(7      R)7      #   \         d    Ro ELi ; i ELD EL, EL EL EL EL EL  + GRj  xL 
 '       g   i     EL; i EL  + '       g   i     EL; i EL EL EL<  \P         d!   p\p        Ps                  R'T4        Rp?LRp?ii ; i5i)*a-  Submit any component to Docket for background execution (SEP-1686).

Unified handler for all component types. Called by component's internal
methods (_run, _read, _render) when task metadata is present and mode allows.

Queues the component's method to Docket, stores raw return values,
and converts to MCP types on retrieval.

Args:
    task_type: Component type for task key construction
    key: The component key as seen by MCP layer (with namespace prefix)
    component: The component instance (Tool, Resource, ResourceTemplate, Prompt)
    arguments: Arguments/params (None for Resource which has no args)
    task_meta: Task execution metadata. If task_meta.ttl is provided, it
        overrides the server default (docket.execution_ttl).

Returns:
    CreateTaskResult: Task stub with proper Task object
internalNz9Background tasks require a running FastMCP server context)codemessagei  zfastmcp:task::z:created_atz:poll_intervalz:origin_request_idz:access_token)ex)register_task_sessionmethodznotifications/tasks/statusparamstaskIdstatusworkingstatusMessagezTask submitted	createdAtlastUpdatedAtttlpollInterval_metaz$io.modelcontextprotocol/related-taskresource)fn_keytask_key)subscribe_to_task_updates_subscription_task_group)ensure_subscriber_runningstop_subscriber_exit_stack _notification_cleanup_registeredFc                   V ^8  d   QhRR/# )r   r   Noner   )r    s   "r!   r"   &submit_to_docket.<locals>.__annotate__   s     2 2t 2r#   c                 4   <"   S! S 4      G R j  xL
  R #  L5i)Nr   )
session_idr<   s   r!   _cleanup_subscriber-submit_to_docket.<locals>._cleanup_subscriber   s     %j111s   Tz+Failed to start notification subscriber: %s)r-   r.   r1   r2   r3   r4   )task)<r   uuiduuid4r   nowr   utcr   rC   RuntimeErrorr   getr	   r   r
   r   r3   intexecution_ttltotal_secondsTASK_MAPPING_TTL_BUFFER_SECONDSr   task_configpoll_intervalrequest_context
request_idr   redisset	isoformatmodel_dump_jsonfastmcp.server.dependenciesr*   sessionmcptypesTaskStatusNotificationmodel_validateServerNotificationr   	Exceptionsend_notificationadd_to_docket"fastmcp.server.tasks.subscriptionsr9   hasattrr:   
start_soon"fastmcp.server.tasks.notificationsr;   r<   fastmcpr=   getattrpush_async_callbackr>   loggerdebugCreateTaskResultTask)r   r   r   r   r   server_task_id
created_atctxdocketr8   ttl_msttl_secondstask_meta_keycreated_at_keypoll_interval_keyorigin_request_id_keypoll_interval_msorigin_request_idaccess_tokenaccess_token_keyrU   r*   notificationserver_notificationr9   tgr;   rD   erC   r<   s   &&&&&                        @@r!   submit_to_docketr   "   s2    8 &N hll+J -C ^^
   "F~#S
 	
 j.SIH !:V))779D@Aftm$'FFK JJzl!N;KLMMZZ

|1^$4K@N 



|1^$4NC #JJ

|1^$44FG 900>>LLNQUUV/2/B/B/NC**+TX 
 $%Lzz

|1^$4MB ||~~~iiKi@@@ii(<(<(>;iOOOii)3/?+@[iQQQ())13D)UUU#)) ,">">"@[     ~ ZEj#++6 9933BB2.)!1Zv 0 6n9	
L& ))66|D	)		kk++,?@@@ 
 J%%f8%LLL%%f%WWW M s{{677[[11MM) 
G'
CKKUUU
 CKK//''3CKK)KUSS2 2 KK##778KL;?CKK8 99%%YY^^! $)  
 & 	 	c   
 X @OQU ~~~V 	A 
		 	MW6 	V  GBAFFGs[  AWT4 F&WUWUU (UU	$U-U.UU-U;U<U WUBW'U=U:U=%W0V1WVAW(W:!V VBV 1AW4UWUWUUUUUWU7	#U&$
U7	/U7	1	W:U==V	
WWV W%W ;W WWi  )NN)(__doc__
__future__r   rG   
contextlibr   r   r   typingr   r   r   	mcp.typesr[   mcp.shared.exceptionsr	   r
   r   rY   r   r   r   fastmcp.server.tasks.configr   fastmcp.server.tasks.keysr   fastmcp.utilities.loggingr   fastmcp.prompts.promptr   fastmcp.resources.resourcer   fastmcp.resources.templater   fastmcp.tools.toolr   __name__rj   rP   r   r   r#   r!   <module>r      sc   
 #   ' . .  * / V V 0 4 0-3;'	H	 #*  r#   