+
    lHàjäE  ã                  ó*  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 ^ RIHt ]P                  ! ]4      t ! R R4      t]P$                  ! 4       t/ tR]R&   R	 sR
]R&   R sR]R&   R sR]R&   R sR]R&   RtRt]! 4       tR]R&   RAR R lltR R ltR R lt R R  lt!R! R" lt"R# R$ lt#R% R& lt$R'R/R( R) llt%R* R+ lt&R, R- lt'R. R/ lt(RAR0 R1 llt)R2 R3 lt*RBR4R/R5 R6 lllt+R7 R8 lt,R9 R: lt-R; R< lt.R= R> lt/R? R@ lt0R# )Cuç	  Serverâ†’client JSON-RPC requests: the backend asks the renderer a question and waits for the
response frame carrying the same ``id``.

JSON-RPC is peer-to-peer; this is the backend's half. Every "ask the renderer" bridge (clarify,
approval, sudo, secret, vault prompts, desktop GUI reads, MCP setup consent, the tour) is one
:func:`send` (blocking) or :func:`send_async` (queue-backed approvals) and one response frame from
the client â€” no paired ``*.request`` notification / ``*.respond`` method, no per-kind ``*.expire``.

Ids are ``srq-<12 hex>``: strings never collide with client-minted integer ids, and the random
part keeps a compute-host child's requests distinct from the parent's when both reach one socket.
A request that times out or is cancelled (interrupt, session close, shutdown) emits ONE
``request.cancel {id, method, reason}`` notification so every renderer tears the card down the
same way. A response for an id that is no longer open is dropped â€” the wait already returned.

Reconnect: unanswered requests are returned as ``open_requests`` by ``session.resume`` /
``session.activate`` / ``session.events.since`` (:func:`open_requests`); the shared TypeScript
channel re-delivers them as if they had just arrived, so the notification replay ring never
has to carry "a question still waiting for an answer".

Batch clarify keeps per-question locks (``clarify.lock`` â†’ :func:`lock_answer`): answers stay
editable until every question is locked, locked answers survive a timeout, and the last lock
resolves the request with the full answer set.

Window-owned bridges (``preview.read`` / ``preview.act`` / ``terminal.read`` / ``window.read`` /
``tour``) are answered only by the window showing the session; every other attached window declines
with :data:`NOT_SHOWN_CODE`. A decline does not settle the request â€” the owner may still answer â€” until
every answering client attached to the session has declined; then the request resolves with
:data:`NOT_SHOWN_MESSAGE` at once instead of the agent waiting out the deadline (#119333).

Capability: a client says once per connection that it answers serverâ†’client requests
(``client.capabilities {server_requests: true}`` â†’ :func:`advertise`). A WebSocket client that never
did is a build older than this half of the protocol â€” it drops the frame silently and the agent
would wait the full deadline (clarify's 300s) for nothing â€” so :func:`send` / :func:`send_async`
return the same ``None`` an error response produces without writing the frame (#112548).
)ÚannotationsN)ÚAnyÚCallable)Úsettle_batchc                  óJ   € ] tR t^3tR
tRRRR/R R lltR R ltR R	 ltR
tR# )ÚServerRequestÚ	on_resultÚqidsNc               ó0   € V ^8„  d   QhRRRRRRRRRR	R
R/# )é   ÚsidÚstrÚmethodÚparamsÚdictr	   úlist[str] | Noner   z$Callable[[dict | None], None] | NoneÚreturnÚNone© )Úformats   "Ú@/home/ubuntu/.hermes/hermes-agent/tui_gateway/server_requests.pyÚ__annotate__ÚServerRequest.__annotate__E   s9   € ÷ *ñ *˜Cð *¨ð *°dð *ÐEUð *Ø@ð*ØLPñ*ó    c               	ó¦  € R \         P                  ! 4       P                  R,           2V n        Wn        W n        \        V4      V n        \        P                  ! 4       V n
        RV n        RV n        \        P                  ! 4       V n        V'       d   \        V4      MRV n        / V n        WPn        \'        4       V n        RV n        RV n        R# )zsrq-:Né   NNF)ÚuuidÚuuid4ÚhexÚidr   r   r   r   Ú	threadingÚEventÚeventÚresultÚansweredÚtimeÚ
created_atÚlistr	   Úlockedr   ÚsetÚdeclinedÚwritingÚ	withdrawn)Úselfr   r   r   r	   r   s   &&&&$$r   Ú__init__ÚServerRequest.__init__E   s’   € àœŸš›×)Ñ)¨#Õ.Ð/Ð0ˆŒØŒØŒÜ˜6“lˆŒÜ—_’_Ó&ˆŒ
Ø#'ˆŒØˆŒÜŸ)š)›+ˆŒç"&”D˜”J¨DˆŒ	Ø-/ˆŒØ"Œä ›UˆŒàˆŒØ%)ˆŽr   c               ó   € V ^8„  d   QhRR/# ©r   r   r   r   )r   s   "r   r   r   Y   s   € ÷ Cñ C�tñ Cr   c           	     	ón   € R RRV P                   RV P                  RRV P                  /V P                  C/# )Újsonrpcz2.0r   r   r   Ú
session_id)r   r   r   r   )r-   s   &r   ÚframeÚServerRequest.frameY   s:   € Ø˜5 $¨¯©°¸4¿;¹;Ø˜<¨¯©ÐA°T·[±[ÐAðCð 	Cr   c               ó   € V ^8„  d   QhRR/# r1   r   )r   s   "r   r   r   ]   s   € ÷ Hñ H˜$ñ Hr   c                óÂ   € RV P                   /V P                  CpV P                  '       d   \        V P                  4      VR&   RV P                  RV P
                  RV/# )uƒ   ``open_requests`` entry: the request as sent, plus the batch answers locked so far so a
reconnecting client restores its âœ“ state.r4   Úanswersr   r   r   )r   r   r(   r   r   r   )r-   r   s   & r   ÚsnapshotÚServerRequest.snapshot]   sR   € ð  §¡Ð8¨D¯K©KÐ8ˆØ�;�;ˆ;Ü $ T§[¡[Ó 1ˆF�9ÑØ�d—g‘g˜x¨¯©°hÀÐGÐGr   )r$   r&   r*   r"   r   r(   r   r   r   r	   r#   r   r,   r+   )	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú	__slots__r.   r5   r:   Ú__static_attributes__r   r   r   r   r   3   s0   † ð€Ið"*ÐX\ð *ØCG÷*õ(C÷Hñ Hr   r   zdict[str, ServerRequest]Ú_openc                ó   € R # ©Nr   )r5   s   &r   Ú<lambda>rE   l   s   € ©dr   úCallable[[dict], Any]Ú_writec                ó   € R # rD   r   )r"   r   Úpayloads   &&&r   rE   rE   m   s   € ÁTr   úCallable[[str, str, dict], Any]Ú_emitc                ó   € R # )Tr   ©r   s   &r   rE   rE   p   s   € ±r   úCallable[[str], bool]Ú_answerablec                ó   € . # rD   r   rM   s   &r   rE   rE   s   s   € ©br   zCallable[[str], list]Ú_clientsi4  z¡No Hermes Desktop window is showing this chat, so its preview, terminal and tour are out of reach. Ask the user to open this chat in the Desktop app, then retry.r)   Ú_answering_clientsc          
     ó,   € V ^8„  d   QhRRRRRRRRR	R
/# )r   Ú
write_jsonrF   ÚemitrJ   Ú
answerablerN   ÚclientszCallable[[str], list] | Noner   r   r   )r   s   "r   r   r   €   s4   € ÷ ñ Ð0ð Ð8Wð Ø0ðØ;WðØcgñr   c                ó"   € WVus ssVe   VsR # R # rD   )rG   rK   rO   rQ   )rT   rU   rV   rW   s   &&&&r   Ú
bind_sinksrY   €   s"   € ð ",°:Ð€FˆE�;ØÒØŠñ r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Ú	transportr   Úserver_requestsÚboolr   r   r   )r   s   "r   r   r   ˆ   s!   € ÷ 2ñ 2˜ð 2¨tð 2¸ñ 2r   c                óÂ   € \         ;_uu_ 4        V'       d   \        P                  V 4       M\        P                  V 4       RRR4       R#   + '       g   i     R# ; i)u_   Record whether *transport*'s client answers serverâ†’client requests (``client.capabilities``).N)Ú_lockrR   ÚaddÚdiscard)r[   r\   s   &&r   Ú	advertiserb   ˆ   s2   € ç	ŽßÜ×"Ñ" 9Õ-ä×&Ñ& yÔ1÷	 
��Šús   �4AÁA	c               ó    € V ^8„  d   QhRRRR/# )r   r[   r   r   r   r   )r   s   "r   r   r   ‘   s   € ÷ .ñ .�cð .˜dñ .r   c                ó†   € \         ;_uu_ 4        \        P                  V 4       RRR4       R#   + '       g   i     R# ; i)z.Drop a disconnected transport's advertisement.N)r_   rR   ra   ©r[   s   &r   Úforgetrf   ‘   s!   € ç	ŽÜ×"Ñ" 9Ô-÷ 
��Šús	   �/¯A 	c               ó    € V ^8„  d   QhRRRR/# )r   r[   r   r   r]   r   )r   s   "r   r   r   —   s   € ÷ /ñ / ð /¨ñ /r   c                ón   € \         ;_uu_ 4        V \        9   uuR R R 4       #   + '       g   i     R # ; irD   )r_   rR   re   s   &r   Úanswers_requestsri   —   s   € ß	ŽØÔ.Ñ.÷ 
��‹ús   �	#£4	c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   r   r   r]   r   )r   s   "r   r   r   œ   s!   € ÷ ñ ˜#ð  Cð ¨Dñ r   c                óX   € \        V4      '       d   R # \        P                  RW4       R# )Fup   server request %s for %s not sent: the attached client predates serverâ†’client requests (update the Hermes app)T)rO   ÚloggerÚinfo)r   r   s   &&r   Ú_unanswerablern   œ   s'   € Ü�3×ÒÙÜ
‡K�Kð *Ø+1ô8ár   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úreqr   Úreasonr   r   r   r   )r   s   "r   r   r   ¤   s&   € ÷ ]ñ ]�mð ]¨Sð ]°Tñ ]r   c           
     óh   € \        R V P                  RV P                  RV P                  RV/4       R# )zrequest.cancelr   r   rq   N)rK   r   r   r   )rp   rq   s   &&r   Ú_emit_cancelrs   ¤   s)   € Ü	Ð
˜CŸG™G d¨C¯F©F°H¸c¿j¹jÈ(ÐTZÐ%[Ö\r   c               ó    € V ^8„  d   QhRRRR/# )r   rp   r   r   r   r   )r   s   "r   r   r   ¨   s   € ÷ %ñ %�=ð % Tñ %r   c           	     óê  € ^ RI Hp VP                  P                  V P                  4      pVf   \        RV P                  : R24      hVP                  VRV P                  /V P                  C4      w  r4Ve   \        V4      h\        ;_uu_ 4        RV n        V \        V P                  &   RRR4        \        V P                  4       4       \        ;_uu_ 4        RV n        V P                   pRRR4       Xe   \#        Y4       R# R#   + '       g   i     Lg; i  + '       g   i     L6; i  \        ;_uu_ 4        RT n        T P                   pRRR4       i   + '       g   i     i ; i; i)é    )ÚregistryNzserver request z) has no contract in tui_gateway/contractsr4   TF)Útui_gateway.contractsrw   ÚSERVER_REQUESTSÚgetr   ÚRuntimeErrorÚvalidate_paramsr   r   Ú
ValueErrorr_   r+   rB   r   rG   r5   r,   rs   )rp   Ú	contractsÚcontractÚ_Úproblemr,   s   &     r   Ú	_registerr‚   ¨   s  € Ý;à×(Ñ(×,Ñ,¨S¯Z©ZÓ8€HØÒÜ˜_¨S¯Z©Z©NÐ:cÐdÓeÐeØ×*Ñ*¨8°lÀCÇGÁGÐ5ZÈsÏzÉzÐ5ZÓ[�J€AØÒÜ˜Ó!Ð!ß	ŽØˆŒØŒˆc�f‰f‰÷ 
ð&Üˆs�y‰y‹{ÔçŽUØˆCŒKØŸ™ˆI÷ ð Òä�SÖ$ñ ÷ 
�ú÷ �Uû�UŽUØˆCŒKØŸ™ˆI÷ �U�UˆUýs<   ÂDÂ7D3 ÃD ÄD	Ä D0	Ä3E2ÅE	Å	E2ÅE/Å*E2r	   c               ó0   € V ^8„  d   QhRRRRRRRRRR	R
R/# )r   r   r   r   r   r   Útimeoutzfloat | Noner	   r   r   zdict | Noner   )r   s   "r   r   r   ¿   s8   € ÷ $ñ $�ð $˜3ð $¨ð $¸,ð $Øð$Ø+6ñ$r   c               óØ  € \        W4      '       d   R# \        WW$R7      p\        V4        VP                  P	                  V4       \        ;_uu_ 4        \        P                  TP                  R4      TJ pTP                  TP                  \        TP                  4      r©pRRR4       X'       d   X	# X'       d(   \        TR4       TP                  e   \!        X
RR7      # R#   \
         dd    \        ;_uu_ 4        \        P                  TP                  R4      TJ pRRR4       M  + '       g   i     M; iX'       d   \        TR4       h i ; i  + '       g   i     L¼; i)uÇ  Send one request and block for the response ``result`` (a dict).

Returns ``None`` when the renderer never answered (timeout, cancel, or an error response â€” e.g.
a client without a handler for ``method``). ``timeout`` semantics: None â†’ wait until answered or
cancelled, 0 â†’ return immediately, > 0 â†’ bounded wait. A batch (``qids``) that settled returns
``{"answers": <locked so far>, "outcome"}`` (``submitted`` / ``cancelled`` / ``timed_out``).
N)r	   Úinterruptedr„   Ú	timed_out©Úended)rn   r   r‚   r"   ÚwaitÚBaseExceptionr_   rB   Úpopr   rs   r$   r#   r   r(   r	   r   )r   r   r   r„   r	   rp   Ú
still_openr‡   r$   r#   r(   s   &&&$$      r   ÚsendrŽ   ¿   s  € ô �V×!Ò!ÙÜ
˜ VÔ
7€CÜˆc„Nð
Ø�	‰	�‰�wÔ÷ 
Žô —I‘I˜cŸf™f dÓ+¨sÐ2ˆ	Ø#&§<¡<°·±¼TÀ#Ç*Á*Ó=M˜&ˆ÷ 
÷ ØˆßÜ�S˜)Ô$Ø�8‰8ÒÜ ¨kÔ:Ð:Ùøô+ ô ÷ ŽUÜŸ™ 3§6¡6¨4Ó0°CÐ7ˆJ÷ �U�UˆUúçÜ˜˜mÔ,Øðú÷ 
�ús6   ­C( ÁAEÃ(EÄ#D-Ä$	EÄ-D=Ä8EÅEÅE)	c          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
r   r   r   r   r   r   r   zCallable[[dict | None], None]r   zCallable[[str], None]r   )r   s   "r   r   r   æ   s1   € ÷ ñ �sð  ð ¨dð Ð?\ð Ðavñ r   c                ó‚   a€ \        W4      '       d   V! R4       R # \        WW#R7      o\        S4       R V3R llpV# )a!  Send one request whose wait is owned elsewhere (the approval queue's own timeout). ``on_result``
runs on the dispatching thread when the response lands. Returns ``settle(reason)``: call it when
the underlying wait ends; if the request is still open it is withdrawn with ``request.cancel``.Nc                ó   € R # rD   r   )rq   s   &r   rE   Úsend_async.<locals>.<lambda>ì   s   € ™dr   )r   c               ó    € V ^8„  d   QhRRRR/# )r   rq   r   r   r   r   )r   s   "r   r   Ú send_async.<locals>.__annotate__ð   s   € ÷ &ñ &�sð &˜tñ &r   c                óÌ   <€ \         ;_uu_ 4        \        P                  SP                  R 4      R JpR R R 4       X'       d   \	        SV 4       R # R #   + '       g   i     L(; irD   )r_   rB   rŒ   r   rs   )rq   r�   rp   s   & €r   ÚsettleÚsend_async.<locals>.settleð   s@   ø€ ßŽUÜŸ™ 3§6¡6¨4Ó0¸Ð<ˆJ÷ çÜ˜˜fÖ%ñ ÷ �Uús   �#AÁA#	)rn   r   r‚   )r   r   r   r   r–   rp   s   &&&& @r   Ú
send_asyncr˜   æ   sA   ø€ ô �V×!Ò!Ù�$ŒÙ"Ð"Ü
˜ VÔ
A€CÜˆc„N÷&ð &ð €Mr   c               ó    € V ^8„  d   QhRRRR/# )r   r5   r   r   r]   r   )r   s   "r   r   r   ù   s   € ÷ Kñ K˜ð K $ñ Kr   c                ó„   € V P                  R 4      p\        V\        4      ;'       d    VP                  R4      \        8H  # )ÚerrorÚcode)rz   Ú
isinstancer   ÚNOT_SHOWN_CODE)r5   r›   s   & r   Ú_is_not_shownrŸ   ù   s3   € Ø�I‰I�gÓ€EÜ�eœTÓ"×JÐJ u§y¡y°Ó'8¼NÑ'JÐJr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úridr   r[   r   r   r]   r   )r   s   "r   r   r   þ   s!   € ÷ ñ �#ð  #ð ¨$ñ r   c           	     ó@  € \         ;_uu_ 4        \        P                  V 4      pRRR4       Xf   \        P	                  RV 4       R# Ve   \        \        VP                  4      4      M	\        4       p\         ;_uu_ 4        \        P                  V 4      VJd    RRR4       R# Ve   VP                  P                  V4       V'       d   W2P                  8:  g    RRR4       R# \        P                  V R4       R\        P                  ! RRR\        /4      /Vn        RVn        RRR4       VP                   e   VP!                  VP                  4       VP"                  P                  4        R#   + '       g   i     EL]; i  + '       g   i     Li; i)ar  One client's "no window here shows this session". Settles only once every answering client
attached to the session declined: a bystander window must not beat the owner (#113348), and with
no owner at all the agent gets the refusal now rather than at the deadline (#119333). A decline
from an unknown transport (relayed, proxied) is recorded nowhere and the wait goes on.Nz:server request %s: decline dropped, request no longer openFTÚvalueÚsuccessr›   )r_   rB   rz   rl   Údebugr)   rQ   r   r*   r`   rŒ   ÚjsonÚdumpsÚNOT_SHOWN_MESSAGEr#   r$   r   r"   )r¡   r[   rp   rW   s   &&  r   Ú_decliner©   þ   s  € ÷
 
ŽÜ�i‰i˜‹nˆ÷ 
à
‚{Ü�‰ÐQÐSVÔWÙØ(1Ò(=Œc”(˜3Ÿ7™7Ó#Ô$Ä3Ã5€Gß	ŽÜ�9‰9�S‹> Ó$Ø÷ 
‰ð Ò Ø�L‰L×Ñ˜YÔ'ß˜g¯©Ô5Ø÷ 
‰ô 	�	‰	�#�tÔØœtŸzšz¨9°e¸WÔFWÐ*XÓYÐZˆŒ
ØˆŒ÷ 
ð ‡}�}Ò Ø�‰�c—j‘jÔ!Ø‡I�I‡M�M„OÙ÷' 
�ˆú÷ 
�ús*   �E9ÂFÂ(&FÃFÃ*AFÅ9F
	ÆF	c               ó$   € V ^8„  d   QhRRRRRR/# )r   r5   r   r[   r   r   r]   r   )r   s   "r   r   r     s!   € ÷ #ñ #˜Dð #¨Sð #¸Dñ #r   c           
     ót  € V P                  R4      p\        V\        4      '       g   R# \        V 4      '       d   \	        W!4      # \
        ;_uu_ 4        \        P                  V4      pVf"   \        P                  RV4        RRR4       R# \        P                  VR4       RV 9   dA   \        P                  RW#P                  V P                  R4      4       RRuVn        Vn        MnV P                  R4      p\        V\        4      '       d   TM/ Vn        VP                  '       d&   \        VP                   VP                  4      Vn        RVn        RRR4       XP"                  e   VP#                  VP                  4       VP$                  P'                  4        R#   + '       g   i     LU; i)	u  Route one client response frame to its open request. False when nothing is waiting for that id
(already timed out / cancelled, or owned by another process â€” see the compute-host bridge).
*transport* is the client connection the frame arrived on (counts a NOT_SHOWN_CODE decline).r   FNz;server request %s: response dropped, request no longer openr›   z.server request %s (%s) answered with error: %sr#   T)rz   r�   r   rŸ   r©   r_   rB   rl   r¥   rŒ   r   r#   r$   r   r	   r   r(   r   r"   r)   )r5   r[   r¡   rp   r#   s   &&   r   Úresolve_responser¬     s:  € ð �)‰)�D‹/€CÜ�cœ3×ÒÙÜ�U×ÒÜ˜Ó'Ð'ß	ŽÜ�i‰i˜‹nˆØŠ;ô �L‰LÐVÐX[Ô\Ø÷ 
‰ô 	�	‰	�#�tÔØ�eÔÜ�L‰LÐIÈ3×PZÑPZÐ\a×\eÑ\eÐfmÓ\nÔoØ'+¨UÐ$ˆCŒJ˜�à—Y‘Y˜xÓ(ˆFÜ#-¨f´d×#;Ò#;™ÀˆCŒJØ�x�xˆxô *¨#¯*©*°c·j±jÓA�”
ØˆCŒL÷- 
ð. ‡}�}Ò Ø�‰�c—j‘jÔ!Ø‡I�I‡M�M„OÙ÷5 
�ús   Á1F'ÂBF'Ä.,F'Æ'F7	c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Ú
request_idr   Úquestion_idÚanswerú
str | Noner   r   r   )r   s   "r   r   r   ?  s)   € ÷ ñ ˜Cð ¨cð ¸:ð ÐJZñ r   c                óD  € \         ;_uu_ 4        \        P                  V 4      pVe   VP                  f    RRR4       R# WP                  9  d   \	        RV: 24      hW#P
                  V&   VP                   Uu. uF  qDVP
                  9  g   K  VNK  	  ppV'       g;   \        VP
                  RR7      RuVn        Vn        \        P                  V R4       RRR4       X'       g   XP                  P                  4        V# u upi   + '       g   i     L9; i)a  Lock one batch-clarify answer (update-in-place; ``None`` = skipped). Returns the question ids
still unanswered; the last lock resolves the request with the full ``{"answers"}`` set. ``None``
when no open batch has that id (expired or foreign); ``ValueError`` for an unknown question id.Nzunknown question_id Ú	submittedrˆ   T)r_   rB   rz   r	   r}   r(   r   r#   r$   rŒ   r"   r)   )r®   r¯   r°   rp   ÚqidÚ	remainings   &&&   r   Úlock_answerr¶   ?  sÕ   € ÷ 
ŽÜ�i‰i˜
Ó#ˆØŠ;˜#Ÿ(™(Ò*Ø÷ 
‰ð Ÿh™hÔ&ÜÐ3°K±?ÐCÓDÐDØ"(�
‰
�;ÑØ$'§H¢HÓF¡H˜S¸3¿:¹:Ñ0E—S�S¡Hˆ	ÐFßÜ'3°C·J±JÀkÔ'RÐTXÐ$ˆCŒJ˜œÜ�I‰I�j $Ô'÷ 
÷ Ø�	‰	�‰ŒØÐùò G÷ 
�ús*   �)DÁ;DÁ=D
ÂD
ÂADÄ
DÄD	r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r   r±   rq   r   r   r   Úintr   )r   s   "r   r   r   S  s)   € ÷ ñ �
ð ¨3ð È:ð Ðadñ r   c               óH  € \         ;_uu_ 4        \        P                  4        Uu. uF3  pV e   VP                  V 8X  g   K  Ve   VP                  V8X  g   K1  VNK5  	  ppV F  p\        P                  VP                  R4       VP                  e&   \        VP                  RR7      RuVn
        Vn        MRRuVn
        Vn        VP                  '       g   Ky  Wn        K�  	  V Uu0 uF"  q3P                  '       d   K  VP                  kK$  	  ppRRR4       X FZ  pVP                  e   VP                  R4       VP                  P!                  4        VP                  X9   g   KO  \#        W14       K\  	  \%        V4      # u upi u upi   + '       g   i     L…; i)us  Withdraw open requests â€” only *sid*'s (session.interrupt must not touch other sessions'), or
every one when *sid* is None (shutdown); *method* narrows it to one request kind. Blocked waits
return None (a batch returns its locked answers with ``outcome: cancelled``); queue-backed requests
run ``on_result(None)`` so their owner can settle. Returns the number withdrawn.NÚ	cancelledrˆ   TF)r_   rB   Úvaluesr   r   rŒ   r   r	   r   r(   r#   r$   r+   r,   r   r"   r)   rs   Úlen)r   rq   r   rp   ÚtargetsÚ	announceds   &&$   r   Úcancelr¿   S  s;  € ÷
 
ŽÜ"'§,¡,¤.ó d¡.˜3Ø’{ c§g¡g°¡nô Ø;Aº>ÈSÏZÉZÐ[aÑMa÷ �3¡.ˆð dãˆCÜ�I‰I�c—f‘f˜dÔ#Ø�x‰xÒ#Ü+7¸¿
¹
È+Ô+VÐX\Ð(�”
˜C�Là+/°Ð(�”
˜CœLØ�{�{Š{Ø &–ñ ñ (/ÓB¡w ·kµk”V�S—V”V¡wˆ	ÐB÷ 
ó ˆØ�=‰=Ò$Ø�M‰M˜$ÔØ�	‰	�‰ŒØ�6‰6�YÖÜ˜Ö%ñ ô ˆw‹<Ðùò#dùò C÷ 
�úsA   �F¦FÁFÁFÁA8FÃFÃ*FÄFÄFÆ
FÆF!	c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r   z
list[dict]r   )r   s   "r   r   r   m  s   € ÷ ,ñ ,�sð ,˜zñ ,r   c                óô   a € \         ;_uu_ 4        \        V 3R l\        P                  4        4       R R7      pRRR4       X Uu. uF  q"P	                  4       NK  	  up#   + '       g   i     L/; iu upi )z,Unanswered requests for *sid*, oldest first.c              3  óL   <"  € T F  qP                   S8X  g   K  Vx € K  	  R # 5irD   rM   )Ú.0rp   r   s   & €r   Ú	<genexpr>Ú open_requests.<locals>.<genexpr>p  s   øé € ÐG¡n˜s¿¹À3¹—s’s£nùs   ƒ$š
$c                ó   € V P                   # rD   ©r&   ©Úrs   &r   rE   Úopen_requests.<locals>.<lambda>p  s   € ÐWX×WcÒWcr   ©ÚkeyN)r_   ÚsortedrB   r»   r:   )r   Úreqsrp   s   f  r   Úopen_requestsrÏ   m  sI   ø€ ç	ŽÜÔG¤e§l¡l¤nÓGÑMcÔdˆ÷ 
á&*Ó+¡d˜s�L‰LŽN¡dÑ+Ð+÷ 
�üâ+s   �+A"ÁA5Á"A2	c               ó   € V ^8„  d   QhRR/# )r   r   r¸   r   )r   s   "r   r   r   t  s   € ÷ ñ ˜Cñ r   c                 óz   € \         ;_uu_ 4        \        \        4      uuRRR4       #   + '       g   i     R# ; i)u£   Unanswered serverâ†’client requests across every session: the process is waiting on a
human (clarify, approval, sudo, secret, ...) and must not be treated as idle.N)r_   r¼   rB   r   r   r   Úopen_request_countrÒ   t  s   € ÷ 
ŽÜ”5‹z÷ 
��‹ús   �)©:	c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r   r   )r   s   "r   r   r   {  s   € ÷ Hñ H�cð H˜cñ Hr   c                ó  € \         ;_uu_ 4        \        P                  4        Uu. uF  qP                  V 8X  g   K  VNK  	  ppRRR4       X'       d   \	        VR R7      P
                  # R# u upi   + '       g   i     L7; i)ua   Method of the oldest open request for *sid* ("" when none) â€” the session is waiting on a human.Nc                ó   € V P                   # rD   rÇ   rÈ   s   &r   rE   Úpending_kind.<locals>.<lambda>  s   €  1§<¢<r   rË   Ú )r_   rB   r»   r   Úminr   )r   rp   rÎ   s   &  r   Úpending_kindrÙ   {  sY   € ç	ŽÜ$Ÿ|™|œ~Ó@™~˜·±¸C±—�™~ˆÐ@÷ 
ç;?Œ3ˆtÑ/Ô0×7Ñ7ÐGÀRÐGùò A÷ 
�ús!   �A4¦A/½A/ÁA4Á/A4Á4B	c               ó    € V ^8„  d   QhRRRR/# )r   Úobjr   r   r]   r   )r   s   "r   r   r   ‚  s   € ÷ qñ q˜3ð q 4ñ qr   c                óŠ   € \        V \        4      ;'       d-    RV 9  ;'       d     RV 9   ;'       d    RV 9   ;'       g    RV 9   # )zUA client response: has an ``id`` and a ``result``/``error`` member but no ``method``.r   r   r#   r›   )r�   r   )rÛ   s   &r   Úis_response_framerÝ   ‚  sD   € ä�cœ4Ó ×pÐp X°SÑ%8×pÐp¸TÀS¹[×pÐpÈhÐZ]Éo×NoÐNoÐahÐloÑaoÐpr   c               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r   s   "r   r   r   ‡  s   € ÷ #ñ #˜ñ #r   c                 ó¬   € \         ;_uu_ 4        \        P                  4        \        P                  4        R R R 4       R #   + '       g   i     R # ; irD   )r_   rB   ÚclearrR   r   r   r   Úreset_for_testsrá   ‡  s(   € ß	ŽÜ�‰ŒÜ× Ñ Ô"÷ 
��Šús   �)AÁA	rD   )Nr†   )1Ú__conditional_annotations__Ú__doc__Ú
__future__r   r¦   Úloggingr    r%   r   Útypingr   r   Útools.clarify_batchr   Ú	getLoggerr<   rl   r   ÚLockr_   rB   Ú__annotations__rG   rK   rO   rQ   rž   r¨   r)   rR   rY   rb   rf   ri   rn   rs   r‚   rŽ   r˜   rŸ   r©   r¬   r¶   r¿   rÏ   rÒ   rÙ   rÝ   rá   )râ   s   @r   Ú<module>rë      s'  øðô"õH #ã Û Û Û Û ß  å ,à	×	Ò	˜8Ó	$€÷0Hñ 0Hðf 	�ŠÓ€Ø"$€ÐÓ $ñ
 !3€ÐÓ 2Ù)I€Ð&Ó Iñ &6€Ð"Ó 5ñ #1€Ð
Ó 0ð €ð`Ð ñ
 ›%Ð �CÓ ÷õ2õ.õ/õ
õ]õ%ð.$Ø"&÷$õNõ&Kõ
÷6#õLñ(ÐX\÷ ð õ4,õõHõq÷
#r   