+
    iHàj  ã                  ó>  a € 0 t $ R t^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	H
t
HtHt ]P                  ! ]4      tRtRt]
]]],          ]],          .R3,          t]P*                  ! RRR7      tR]R	&   R
 R lt]P2                  R R l4       tR R ltR R ltR# )a
  Live progress from inside a running tool call (MCP ``notifications/progress``) onto the agent's
``tool_progress_callback`` as ``tool.progress`` events.

The executor binds a relay for each dispatched call (``bound_tool_progress``); a tool reads it on its
own thread with ``current_tool_progress()`` and may invoke the result from any thread (the MCP client
fires it on the MCP event loop). Emission is throttled per call so a chatty server cannot flood the
UI; the first update and the one reaching ``total`` always pass.
)ÚannotationsN)ÚCallableÚIteratorÚOptionalztool.progressg      à?Útool_progress_reporter)Údefaultz2contextvars.ContextVar[Optional[ProgressReporter]]Ú_currentc               ó$   € V ^8„  d   QhRRRRRR/# )é   Ú	tool_nameÚstrÚtool_call_idÚreturnÚProgressReporter© )Úformats   "Ú>/home/ubuntu/.hermes/hermes-agent/agent/tool_progress_relay.pyÚ__annotate__r      s"   € ÷ ñ  3ð °cð Ð>Nñ ó    c                ó^   a aaaa€ \         P                  ! 4       oR .oRR V VVVV3R lllpV# )ç        c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r
   ÚprogressÚfloatÚtotalzOptional[float]ÚmessageúOptional[str]r   ÚNoner   )r   s   "r   r   Ú_reporter.<locals>.__annotate__    s/   € ÷ [ñ [˜ð [ ð [Èð [Ðaeñ [r   c                óf  <€ VR J;'       d    V^ 8„  ;'       d    W8¬  p\         P                  ! 4       pS;_uu_ 4        S^ ,          '       d-   V'       g%   VS^ ,          ,
          \        8  d    R R R 4       R # VS^ &   R R R 4       V'       d-   \        \	        \        W,          R4      R4      ^d,          4      MR p S! \        S
T;'       g    R R S	\        V 4      Vf   R M
\        V4      VR7       R #   + '       g   i     L; i  \         d    \        P                  RS
RR7        R # i ; i)Nr   g      ð?)r   r   r   Úpercentz$tool.progress callback failed for %sT)Úexc_info)ÚtimeÚ	monotonicÚ_MIN_INTERVAL_SÚroundÚminÚmaxÚTOOL_PROGRESS_EVENTr   Ú	ExceptionÚloggerÚdebug)r   r   r   ÚdoneÚnowr    ÚcallbackÚlastÚlockr   r   s   &&&   €€€€€r   ÚreportÚ_reporter.<locals>.report    sú   ø€ Ø˜DÐ ×DÐD U¨Q¡Y×DÐD°8Ñ3DˆÜ�nŠnÓˆßŠTØ�A�wŒwŸt¨¨d°1­g­¼Ô(GØ÷ ‰Tð ˆD�‰G÷ ÷ HM”%œœC Õ 0°#Ó6¸Ó<¸sÕBÔCÐRVˆð	[ÙÔ(¨)°W·_°_ÀÀdÐYeÜ# H›o¸Uº]±TÔPUÐV[ÓP\Ðfm÷o÷ �Tûô ô 	[Ü�L‰LÐ?ÀÐUYˆL×Zð	[ús/   ¾C6ÁC6Á:C6Â>D	 Ã%D	 Ã6D	Ä	#D0Ä/D0)NN)Ú	threadingÚLock)r.   r   r   r1   r/   r0   s   fff @@r   Ú	_reporterr5      s)   ü€ Ü�>Š>Ó€DØˆ5€D÷[ö [ð €Mr   c               ó$   € V ^8„  d   QhRRRRRR/# )r
   r   r   r   r   zIterator[None]r   )r   s   "r   r   r   1   s!   € ÷ ñ ¨Sð Àð Èñ r   c              #  óÜ   "  € \         P                  V '       d   \        YT;'       g    R4      MR4      p Rx € \         P                  V4       R#   \         P                  T4       i ; i5i)zUBind this call's relay for the block (no-op when the agent has no progress callback).Ú N)r   Úsetr5   Úreset)r.   r   r   Útokens   &&& r   Úbound_tool_progressr<   0   sI   é € ô �L‰LÏxœ 8¸×8JÐ8JÈÔKÐ]aÓb€EðÛä�‰�uÖøŒ�‰�uÕüs    ‚&A,©A,·A »A,ÁA)Á)A,c               ó   € V ^8„  d   QhRR/# )r
   r   zOptional[ProgressReporter]r   )r   s   "r   r   r   :   s   € ÷ ñ Ð9ñ r   c                 ó*   € \         P                  4       # )zDThe running call's reporter, or None outside a dispatched tool call.)r   Úgetr   r   r   Úcurrent_tool_progressr@   :   s   € ä�<‰<‹>Ðr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r
   Únamer   r   ÚkwargsÚdictr   r   )r   s   "r   r   r   ?   s/   € ÷ \ñ \ ð \¸ð \Ètð \ÐX\ñ \r   c                ó0  € R\        VP                  R4      ;'       g    R4      R\        T ;'       g    R4      R\        VP                  R4      ;'       g    R4      RVP                  R4      RVP                  R4      R	V'       d   \        V4      /# R
/# )z¶The ``tool.progress`` wire payload every viewer surface publishes (gateway event stream and
the legacy TUI gateway): ``percent`` is 0-100 when the server sent a ``total``, else None.Útool_idr   r8   rB   r   r   r   r    r   N)r   r?   r   )rB   r   rC   s   &&&r   Útool_progress_payloadrG   ?   sŠ   € ð ”s˜6Ÿ:™: nÓ5×;Ð;¸Ó<¸fÄcÈ$Ï*È*ÐRTÃoØœ˜fŸj™j¨Ó4×;Ð;¸Ó<¸gÀvÇzÁzÐRYÓGZØ�v—z‘z )Ó,¨iÏ¼¸W»ð\ð \àVZð\ð \r   )Ú__conditional_annotations__Ú__doc__Ú
__future__r   Ú
contextlibÚcontextvarsÚloggingr3   r"   Útypingr   r   r   Ú	getLoggerÚ__name__r*   r(   r$   r   r   r   Ú
ContextVarr   Ú__annotations__r5   Úcontextmanagerr<   r@   rG   )rH   s   @r   Ú<module>rT      s£   øðôõ #ã Û Û Û Û ß /Ñ /à	×	Ò	˜8Ó	$€à%Ð Ø€à˜U H¨U¥O°X¸cµ]ÐCÀTÐIÕJÐ Ø?J×?UÒ?UÐVnÐx|Ô?}€Ð
<Ó }õð( ×Ñôó ðõ÷
\r   