+
    jHàjù’  ã                   ó˜  € R t ^ RIt^ RIHtHt ^ RIHt ^ RIHtH	t	 ^ RI
Ht ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIt^ RIt^ RIt^ RIHtHtHt ^ R	IHt ^ R
IHt ^<t^t RRRR/t! ! R R]"4      t#R t$R'R lt%R t&R t']R 4       t( ! R R4      t)R t*R t+R t,R t-R'R lt.R t/R t0R'R lt1R t2R  t3R! t4R" t5R# t6R$ t7R% t8R& t9R# )(zIAdmission-owned production exec; observers never own the worker lifetime.N)ÚcontextmanagerÚsuppress)Údeque)ÚasdictÚreplace)Úpartial)ÚSimpleNamespace©ÚPath)Úaccept_resultÚencode_frameÚ
read_frame)Úreserve_admission_worker)ÚRuntimeStoreErrorÚstart_new_sessionTÚ	close_fdsc                   ó   € ] tR t^ tRtRtR# )ÚManagedExecutionUnknownzOThe committed unknown verdict stops the FIFO without forging failed settlement.© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    ÚC/home/ubuntu/.hermes/hermes-agent/gateway/session_managed_worker.pyr   r       s   † ÝYr   r   c                ó  € ^ RI Hp V! V P                  V P                  VP                  ,          P
                  4      pVf   R# VP                  '       g   VP                  e   V# VP                  4       P                  R/ 4      P                  R4      RJd   R# \        P                  ! VP                  4      pVP                  R8w  g.   VP                  R4      R8w  g   VP                  R	4      '       g   \        R
4      hV# )z×Bypass (safe / config-only) sessions always execute out of process; other local
sessions only under the explicit custom-provider opt-in.

The frozen creation snapshot, not current profile config, chooses execution.
)Úpolicy_for_sourceNÚgatewayÚmanaged_workersTÚcliÚproviderÚcustomÚbase_urlÚunsupported_managed_policy)Úgateway.session_policyr   ÚrunnerÚsessionsÚ
session_idÚsourceÚignore_user_configÚkanban_jsonÚconfigÚgetÚjsonÚloadsÚrequest_jsonÚplatformr   )Ú	authorityÚrefr   ÚpolicyÚrequests   &&   r   Úmanaged_policyr7   $   sÌ   € õ 9Ù˜y×/Ñ/°×1CÑ1CÀCÇNÁNÕ1S×1ZÑ1ZÓ[€FØ‚~ÙØ× × Ð  F×$6Ñ$6Ò$BØˆØ‡}�}ƒ×Ñ˜9 bÓ)×-Ñ-Ð.?Ó@ÈÓLÙÜ�jŠj˜×,Ñ,Ó-€GØ‡�˜%Ô 7§;¡;¨zÓ#:¸hÔ#FÈgÏkÉkÐZd×NeÒNeÜÐ <Ó=Ð=Ø€Mr   c                 óN  € ^ RI Hp ^ RIHp ^ RIHp \        P                  ! VP                  4      p	VP                  '       d8   V! W4      P                  4        F  w  r«V
^ ,          e   K  W¹V
^,          &   K  	  V P                  VP                  ,          p\        \        P                  ! VP                  4      RVR,          P                  RR4      RVR,          P                  R4      R	J R
\!        WP"                  V4      /VR,          P                  R4      '       d   RVR,          R,          /M/ CVR,          P                  R4      '       d   RVR,          R,          /M/ CR7      p^ RIHp V! WVP(                  P*                  4      VR&   \-        W4      p\/        V\        P0                  ! V4      \        P0                  ! V4      \        P0                  ! V	4      RRR7      pR^RV P2                  RTR\5        V4      RV! WV4      RVf   VR,          R,          MTRVP"                  /RVR,          9   d   RVR,          R,          /M/ CRVP(                  P6                  RVP(                  P*                  RV! W24      RVP8                  RVP:                  /C# )é    )Úrow_turn_author)Úroute_launch_key)Úrecover_config_secretsNÚfiniteÚpayloadFÚ
unattendedTÚyoloÚ
surface_v1Ú
display_v1)Úturn_v1)Úconstruct_inputsÚconstruct_v1)Úconfig_jsonr1   Úterminal_jsonÚcredential_refÚconfig_secret_refÚversionÚhomeÚscoper5   Úapi_keyÚtextÚrouteÚattachments_v1Úuser_idÚchat_idÚturn_authorÚ	safe_moder+   )Úgateway.session_ingressr:   r&   r;   Ú"gateway.session_policy_credentialsr<   r/   r0   rG   rI   Úitemsr(   r)   Údictr1   r.   Ú_session_yolorO   Ú gateway.session_worker_constructrD   r*   rR   Ú_worker_configr   ÚdumpsÚ
profile_idr   rQ   rT   r+   )r3   r4   Úrowr5   rL   rN   r:   r;   r<   ÚterminalÚpathÚvalueÚliver6   rD   r-   Úhydrateds   &&&&&&           r   Ú
_bootstraprd   8   sZ  € Ý7Ý7ÝIÜ�zŠz˜&×.Ñ.Ó/€HØ××ÐÙ1°)ÓD×JÑJÖL‰KˆDØ�A�wŒØ$)˜˜a�Ó!ñ Mð ×Ñ˜cŸn™nÕ-€Dô ”4—:’:˜f×1Ñ1Ó2Ø�#�i•.×$Ñ$ X¨uÓ5°|ÀSÈÅ^×EWÑEWÐXdÓEeÐimÐEmØ”˜i¯©°VÓ<ð=fð <?¸y½>×;MÑ;MÈl×;[Ò;[ˆL˜#˜i�.¨Õ6Ñ7Ðacð=fð <?¸y½>×;MÑ;MÈl×;[Ò;[ˆL˜#˜i�.¨Õ6Ñ7Ðacð	=fô g€Gõ
 BÙ.¨yÀ$Ç+Á+×BUÑBUÓV€GˆNÑÜ˜IÓ.€FÜ�v¬4¯:ª:°fÓ+=ÌDÏJÊJÐW^ÓL_Ü%)§Z¢Z°Ó%9È$Ðbfôh€Hà�q˜& )×"6Ñ"6¸ÀØ”f˜XÓ&¨	Ñ3CÀIÐW]Ó3^Ø¨dªl�C˜	•N 6Ö*ÀÀgÈtÏzÉzð\ð HXÐ[^Ð_hÕ[iÔGiÐ  # i¥.Ð1AÕ"BÑCÐoqð\ð �t—{‘{×*Ñ*¨I°t·{±{×7JÑ7JØ™?¨6Ó7Ø˜×)Ñ)Ð+?À×AZÑAZñ\ð \r   c                óD  € VP                  V 4      p\        \        V P                  4      4      pVP                  '       g   VP                  4       '       g   V# ^ RIHp V! VR,          4      pVP                  RR4       VP                  R4      e   VR,          VR&   V# )a€  The frozen session config the child binds as its only config (``bind_worker_policy``).
``command_allowlist`` is approval state rather than launch policy: an ``always`` grant an
earlier worker of an ordinary session persisted, or one the operator removed by hand, comes
from the live profile file, as it did before the child's config was frozen. Bypass sessions
never read the profile.)Ú_load_gateway_configzconfig.yamlÚcommand_allowlistN)
r-   r
   Ústrr]   r+   Úis_absoluteÚgateway.runrf   Úpopr.   )r3   r5   r-   rK   rf   rb   s   &&    r   r[   r[   X   s�   € ð �]‰]˜9Ó%€FÜ”�I×(Ñ(Ó)Ó*€DØ× × Ð ¨×(8Ñ(8×(:Ò(:ØˆÝ0Ù  }Õ 4Ó5€DØ
‡J�JÐ" DÔ)Ø‡x�xÐ#Ó$Ò0Ø&*Ð+>Õ&?ˆÐ"Ñ#Ø€Mr   c                óØ   € ^ RI Hp ^ RIHp \	        V P
                  RR4      pVe   VP                  V4      MRpV! V\	        VRR4      \        VP                  4      R7       V! V4      # )z¸The route's bypass as the in-process turn arms it on the owner, the one place a revocation
is recorded: a ``--yolo`` launch seeded once per boundary, then the persisted ``/yolo`` copy.)Úis_session_yolo_enabled)Úrestore_gateway_yoloÚsession_storeNr@   )Úlaunch)	Útools.approvalrm   Útools.approval_yolorn   Úgetattrr'   Úlookup_by_session_keyÚboolr@   )r3   rO   r5   rm   rn   ÚstoreÚentrys   &&&    r   rY   rY   j   s^   € õ 7Ý8Ü�I×$Ñ$ o°tÓ<€EØ27Ò2CˆE×'Ñ'¨Ô.È€EÙ˜¤¨¨v°tÓ <ÄTÈ&Ï+É+ÓEVÕWÙ" 5Ó)Ð)r   c              #  óÎ  "  € ^ RI Hp ^ RIHpHp ^ RIHpHp \        P                  ! V R,          P                  R4      ;'       g    R4      P                  R4      pVf   Rx € R# \        V\        4      '       d.   VP                  4        UUu/ uF  w  rxVR9  g   K  WxbK  	  uppMRp	V	e‡   \        V	4      0 Rm8w  gu   \        ;QJ d*    R V	P!                  4        4       F  '       g   K   RM	  RM! R V	P!                  4        4       4      '       g   VR,          '       d   VR,          '       g   \#        R4      h R	V9   d   V! VR	,          4      MRp
R
V9   d   V! VR
,          4      MRpTR,          '       d   ^ RIHp T! T R,          4       T! TR,          TR,          4      ;_uu_ 4        T! T
4      ;_uu_ 4        T! T R,          R,          T4      ;_uu_ 4        Rx € RRR4       RRR4       RRR4       R# u uppi   \$         d   p\#        R4      ThRp?ii ; i  + '       g   i     LG; i  + '       g   i     LR; i  + '       g   i     R# ; i5i)aV  Child side of ``turn_v1``: bind what the in-process turn binds on the owner
(execute_finite_admission, the route's YOLO, the committed surface), so ``chat -q``/``-z``
never park a prompt, the session's current YOLO governs this child and a HUD / live-voice /
voice turn reaches the model as it does in process. Frames without it bind nothing.)Úfinite_turn_scope)Údisplay_turn_scopeÚrestore_display)Úrestore_surfaceÚsurface_turn_scoper5   r1   z{}rC   NrA   rB   r=   r?   r@   c              3   óD   "  € T F  p\        V4      \        Jx € K  	  R # 5i©N)Útyperu   ©Ú.0Úvs   & r   Ú	<genexpr>Ú$worker_turn_scope.<locals>.<genexpr>„   s   é € Ð?±¨1”4˜“7¤$Õ&³ùs   ‚ TFÚ invalid_managed_worker_bootstrap)Úenable_session_yolorO   rL   Úexecution_id)rA   rB   >   r@   r=   r?   )Úgateway.session_finitery   Úgateway.session_displayrz   r{   Úgateway.session_surfacer|   r}   r/   r0   r.   Ú
isinstancerX   rW   ÚsetÚanyÚvaluesÚ
ValueErrorr   rq   r‡   )Úframery   rz   r{   r|   r}   ÚturnÚkrƒ   ÚflagsÚsurfaceÚdisplayÚexcr‡   s   &             r   Úworker_turn_scoper˜   u   sÊ  é € õ 9ßKßKÜ�:Š:�e˜H•o×)Ñ)¨.Ó9×AÐA¸TÓB×FÑFÀyÓQ€DØ‚|ÛÙÜXbÐcgÔim×XnÒXn˜dŸj™jœlÔT™l‘d�a¨aÐ7SÑ.SŒTˆQŠT™lÓTÐtx€EØŠœ˜U›Ò'GÔGß‹sÑ?°·±´Ó?�s�sŠsÑ?°·±´Ó?×?Ò?ÀDÈ×DVÔDVÐ_cÐdl×_mÔ_mÜÐ;Ó<Ð<ðFØ9EÈÔ9M‘/ $ |Õ"4Ô5ÐSWˆØ9EÈÔ9M‘/ $ |Õ"4Ô5ÐSWˆð ˆF‡|„|Ý6Ù˜E '�NÔ+Ù	˜4 �>¨4°Õ+=×	>Õ	>Ñ@RÐSZ×@[Õ@[Ù˜u W�~¨nÕ=¸w×GÕGÛ÷ H÷ A\×	>Ñ	>ùó Uøô ô FÜÐ;Ó<À#ÐEûðFú÷ H×Gú÷ A\×@[ú×	>×	>Ð	>üs¨   ‚BI%ÂHÂ!HÂ'&I%ÃI%Ã0(I%ÄI%Ä(I%Ä7I%Å0H Å3I%Æ4I%Æ6IÇ H>	Ç'H+Ç,H>	Ç4IÇ<I%ÈH(ÈH#È#H(È(I%È+H;È6H>	È>IÉ	IÉI"	É	I%c                   óz   a € ] tR t^“t o R tR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tRtV tR# )ÚManagedWorkerc                óú  € Wn         R V n        \        P                  ! 4       V n        \
        P                  ! ^R7      V n        \        P                  ! 4       V n	        \        P                  ! 4       V n        R V n        R V n        \        P                  ! V P                  RRR7      V n        R V n        \        P$                  ! ^ 4      V n        RV n        \+        4       V n        R V n        R V n        . V n        R # )N)Úmaxsizezmanaged-control-writerT)ÚtargetÚnameÚdaemonF)ÚprocessÚworkerÚ	threadingÚLockÚ
write_lockÚqueueÚQueueÚcommandsÚEventÚclosedÚasyncioÚstopÚ
stopped_atÚ
stop_causeÚThreadÚ_write_controlsÚwriterÚreaderÚ	SemaphoreÚ_demandÚ
_requestedr   Ú_framesÚ_arrivedÚstderr_drainÚsecrets)Úselfr    s   &&r   Ú__init__ÚManagedWorker.__init__”   s¸   € ØŒàˆŒÜ#Ÿ.š.Ó*ˆŒÜŸš¨BÔ/ˆŒÜ—o’oÓ'ˆŒô —M’M“OˆŒ	ð ˆŒàˆŒÜ×&Ò&¨d×.BÑ.BÐIaÐjnÔoˆŒð ˆŒÜ ×*Ò*¨1Ó-ˆŒØˆŒÜ“wˆŒØˆŒØ ˆÔàˆŽr   c                óD  €  V P                   P                  4       '       g1    V P                  P                  R R7      pT P                  T4       KP  R#   \        P
                   d     Kj  i ; i  \        \        3 d    T P                   P                  4         R# i ; i)g      à?©ÚtimeoutN)
r©   Úis_setr§   r.   r¥   ÚEmptyÚsendÚOSErrorr�   r�   ©r¹   r‘   s   & r   r¯   ÚManagedWorker._write_controls°   s„   € ð	Ø—k‘k×(Ñ(×*Ò*ðØ ŸM™M×-Ñ-°bÐ-Ó9�Eð —	‘	˜%Ö ñ +øô —{‘{ô Úðûô œÐ$ô 	Ø�K‰K�O‰O×ð	ús3   ‚A0 £A ¿A0 ÁA-Á)A0 Á,A-Á-A0 Á0+BÂBc                óÚ  €  V P                   P                  4       '       d�   V P                  P                  4       '       g}    \	        V P
                  P                  4      p VP                  V P                  V4       \        T\         4      '       g   K•   T P
                  P                  P                  4        R# V P
                  P                  P                  4        R#   \        \        \        \        3 d   pTp Rp?L¤Rp?ii ; i  \         d)     T P
                  P                  P                  4        R# i ; i  T P
                  P                  P                  4        i ; i)zWReader thread body. It owns ``stdout``: no other thread closes it under a blocked read.N)r³   Úacquirer©   r¿   r   r    ÚstdoutÚEOFErrorr�   rÂ   ÚRecursionErrorÚcall_soon_threadsafeÚ_deliverÚRuntimeErrorÚcloserŒ   Ú	Exception)r¹   ÚloopÚitemr—   s   &&  r   Ú_read_framesÚManagedWorker._read_frames»   sÿ   € ð	(Ø—,‘,×&Ñ&×(Ò(°·±×1CÑ1C×1EÒ1EðÜ% d§l¡l×&9Ñ&9Ó:�DðØ×-Ñ-¨d¯m©m¸TÔBô ˜d¤I×.Ô.Øà�L‰L×Ñ×%Ñ%Ö'ˆD�L‰L×Ñ×%Ñ%Ö'øô !¤*¬g´~ÐFô Ø•Dûðûô $ô Øð �L‰L×Ñ×%Ñ%Ö'ðûð
 �L‰L×Ñ×%Ñ%Õ'úsX   ‚E ¢E ÁC$ Á#D Á?E Ã$DÃ?DÄE ÄDÄE ÄEÄE Å EÅE Å&E*c                óp   € V P                   P                  V4       V P                  P                  4        R # r   )rµ   Úappendr¶   r�   ©r¹   rÐ   s   &&r   rË   ÚManagedWorker._deliverÌ   s$   € Ø�‰×Ñ˜DÔ!Ø�‰×ÑÖr   c                óö   € V P                   ^ ,          p\        V\        4      '       d   VhV P                   P                  4        RV n        V P                   '       g   V P
                  P                  4        V# )r9   F)rµ   rŒ   rÎ   Úpopleftr´   r¶   ÚclearrÕ   s   & r   Ú_takeÚManagedWorker._takeÐ   sV   € Ø�|‰|˜A�ˆÜ�dœI×&Ò&ØˆJØ�‰×ÑÔØˆŒØ�|�|ˆ|Ø�M‰M×ÑÔ!Øˆr   c           	     óÔ   a € ^ RI Hp ^ RIHp V! VRS P                  P
                  VS P                  P                  V 3R l3R7      S n        S P                  P                  4        R# )z‹Route the child's stderr (its tracebacks and redirected prints) into the profile's
bounded, redacted, private log instead of discarding it.©Úspawn_context_thread)Údrain_worker_stderrzmanaged-stderr-drainc                  ó   <€ S P                   # r   )r¸   ©r¹   s   €r   Ú<lambda>Ú,ManagedWorker.drain_stderr.<locals>.<lambda>à   s   ø€ Ðlp×lxÒlxr   ©rž   ÚargsN)	Úagent.memory_providerrÞ   Ú"gateway.session_managed_worker_logrß   r    ÚstderrÚpidr·   Ústart)r¹   r`   rÞ   rß   s   f&  r   Údrain_stderrÚManagedWorker.drain_stderrÚ   sU   ø€ õ 	?ÝJÙ0Ð1DÐKaØ7;·|±|×7JÑ7JÈDÐRV×R^ÑR^×RbÑRbÔdxÐ6yô{ˆÔà×Ñ×ÑÖ!r   c                ó|  € V P                   P                  4       '       d   \        R 4      hVRR/8X  dC   V P                  f   \        P
                  ! 4       V n        V P                  P                  4         V P                  P                  V4       R#   \        P                   d   p\        R4      ThRp?ii ; i)Úmanaged_worker_lostr€   r«   NÚworker_control_backpressure)r©   r¿   r   r¬   ÚtimeÚ	monotonicr«   r�   r§   Ú
put_nowaitr¥   ÚFull)r¹   r‘   r—   s   && r   ÚcontrolÚManagedWorker.controlã   s�   € Ø�;‰;×Ñ×ÒÜ#Ð$9Ó:Ð:Ø�V˜VÐ$Ô$Ø�‰Ò&Ü"&§.¢.Ó"2�”Ø�I‰I�M‰MŒOð	LØ�M‰M×$Ñ$ UÖ+øÜ�z‰zô 	LÜ#Ð$AÓBÈÐKûð	Lús   Á8B ÂB;Â*B6Â6B;c                ó\   € V P                   V,           \        P                  ! 4       ,
          # )zÐSeconds left of the ``ack`` window that opened at the first Stop. Pure: only
``control`` stamps ``stopped_at``, so a read before any Stop (the hello) never starts
the window a later Stop must receive in full.)r¬   rð   rñ   )r¹   Úacks   &&r   Ú_stop_budgetÚManagedWorker._stop_budgetï   s   € ð �‰ Õ$¤t§~¢~Ó'7Õ7Ð7r   c              ƒ  óú  "  € V P                   fi   \        P                  ! 4       V n        ^ RIHp V! V P                  R\        P                  ! 4       3R7      V n         V P                   P                  4        V P                  '       g4   V P                  '       g"   RV n
        V P                  P                  4        \        P                  ! V P                  P                  4       4      p\        P                  ! V P                  P                  4       4      p V P                  '       gŽ   V P                  P!                  4       '       gn   \        P                  ! WE0V\        P"                  R7      G Rj  x€L
  V P                  '       g,   V P                  P!                  4       '       g   \%        R4      hV P                  '       g:   V P'                  V4      pV^ 8”  d"   \        P                  ! V0VR7      G Rj  x€L
  V P                  '       g   \%        R	4      hV P)                  4       VP+                  4        VP+                  4        #  LÙ LS  TP+                  4        TP+                  4        i ; i5i)
zìRead one frame. A requested Stop bounds supervision to ``ack`` seconds TOTAL from the
first Stop: a child that keeps emitting valid frames is escalated on the same deadline as a
silent one, instead of leaving the turn started behind it.NrÝ   zmanaged-frame-readerrä   T)r¾   Úreturn_whenÚmanaged_worker_hello_timeoutr½   Úmanaged_worker_stopped)r±   rª   r¨   r¶   ræ   rÞ   rÑ   Úget_running_looprê   rµ   r´   r³   ÚreleaseÚensure_futureÚwaitr«   r¿   ÚFIRST_COMPLETEDr   rø   rÚ   Úcancel)r¹   r¾   r÷   rÞ   ÚarrivedÚstopperÚ	remainings   &&&    r   Ú
next_frameÚManagedWorker.next_frameõ   sª  é € ð �;‰;ÒÜ#ŸMšM›OˆDŒMÝBÙ.¨t×/@Ñ/@ÐG]Ü5<×5MÒ5MÓ5OÐ4QôSˆDŒKà�K‰K×ÑÔØ�|�|ˆ| D§O§O OØ"ˆDŒOØ�L‰L× Ñ Ô"Ü×'Ò'¨¯©×(:Ñ(:Ó(<Ó=ˆÜ×'Ò'¨¯	©	¯©Ó(8Ó9ˆð	Ø—<—<�<¨¯	©	×(8Ñ(8×(:Ò(:Ü—l’l GÐ#5¸wÔT[×TkÑTkÔl×lÐlØ—|—|�|¨D¯I©I×,<Ñ,<×,>Ò,>Ü+Ð,JÓKÐKØ—<—<�<à ×-Ñ-¨cÓ2�	Ø˜q”=Ü!Ÿ,š,¨ y¸)ÔD×DÐDØ—<—<�<Ü'Ð(@ÓAÐAØ—:‘:“<à�N‰NÔØ�N‰NÕñ mñ Eøð
 �N‰NÔØ�N‰NÕüss   ‚BI;ÂI;ÂA=I;ÄI Ä-I Å+I Å8IÅ9I ÆI Æ/I Ç4I È IÈI ÈI È1!I;ÉI ÉI É"I8É8I;c                ó,   € V P                  R R/4       R# )r€   r«   N©rô   rá   s   &r   Ú	interruptÚManagedWorker.interrupt  s   € Ø�‰�f˜fÐ%Ö&r   c                ó4   € V P                  R VRVRV/4       R# )r€   Ú	prompt_idra   Nr
  )r¹   Úkindr  ra   s   &&&&r   ÚrespondÚManagedWorker.respond  s   € Ø�‰�f˜d K°¸GÀUÐKÖLr   c                ó  € V P                   ;_uu_ 4        V P                  P                  P                  \	        V4      4       V P                  P                  P                  4        R R R 4       R #   + '       g   i     R # ; ir   )r¤   r    ÚstdinÚwriter   ÚflushrÃ   s   &&r   rÁ   ÚManagedWorker.send  sJ   € Ø�_�_‹_Ø�L‰L×Ñ×$Ñ$¤\°%Ó%8Ô9Ø�L‰L×Ñ×$Ñ$Ô&÷ �_�_Š_ús   •AA2Á2B	c                ó’  € ^ RI pV P                  e-   V P                  ^ ,          V P                  P                  8X  d   R#  VP	                  V P                  ^ ,          4      p^ RIHp V! V4      V P                  ^,          8X  d(   V'       d   VP                  MVP                  ! 4        R# R#   TP                   d     R# i ; i)zŽSignal the verified interpreter, not only the handle: a launcher that exec-chained
or exited leaves the real worker outside the Popen's reach.N)Úprocess_birth)
Úpsutilr¡   r    ré   ÚProcessÚhermes_cli.process_identityr  ÚkillÚ	terminateÚError)r¹   r  r  Úprocr  s   &&   r   Ú_signal_workerÚManagedWorker._signal_worker   s�   € ó 	Ø�;‰;Ò $§+¡+¨a¥.°D·L±L×4DÑ4DÔ"DÙð	Ø—>‘> $§+¡+¨a¥.Ó1ˆDÝAÙ˜TÓ" d§k¡k°!¥nÔ4ß"�—’¨¯©Ð6Ö9ñ 5øà�|‰|ô 	Úð	ús   ÁAB1 ÂB1 Â1CÃCc                ó0  € \         P                  R8w  d±   V P                  P                  4       f•   ^ RIp \         P
                  ! V P                  P                  4      V P                  P                  8X  dL   \         P                  ! V P                  P                  V'       d   VP                  MVP                  4       R#  V'       d   V P                  P                  MV P                  P                  ! 4        R#   \        \        3 d     LNi ; i)a  POSIX: signal the worker's whole process group (it leads one, WORKER_POPEN), so the tool
children a killed worker never reaps with _die_with_owner go too. Only while the leader is
unreaped and still leads its group; otherwise (Windows, gone) the handle alone.ÚntN)Úosrž   r    ÚpollÚsignalÚgetpgidré   ÚkillpgÚSIGKILLÚSIGTERMÚProcessLookupErrorÚPermissionErrorr  r  )r¹   r  r&  s   && r   Ú_signal_groupÚManagedWorker._signal_group.  s·   € ô �7‰7�dŒ?˜tŸ|™|×0Ñ0Ó2Ò:ÛðÜ—:’:˜dŸl™l×.Ñ.Ó/°4·<±<×3CÑ3CÔCÜ—I’I˜dŸl™l×.Ñ.Ç$°·²ÈFÏNÉNÔ[Ùð D÷
 #ˆ�‰×	Ò	¨¯©×(>Ñ(>Ð	>ÖAøô '¬Ð8ô Ùðús   ·A/D Â'D ÄDÄDc                ó¦  € V P                   P                  4        V P                  P                  4        V P                  P                  4       f%   V P                  RR7       V P                  RR7        V P                  P                  ^R7       V P                  RR7       T P                  P                  e   T P                  P                  ^R7       T P                  P                  P!                  4        T P"                  f&   T P                  P$                  P!                  4        MT P"                  P                  ^R7       T P&                  e   T P&                  P                  ^R7       R # T P                  P(                  e'   T P                  P(                  P!                  4        R # R #   \        P                   d…    T P                  RR7       T P                  RR7       \        \        P                  4      ;_uu_ 4        T P                  P                  ^R7       R R R 4        EK–    + '       g   i      EL¨; ii ; i)NF)r  r½   T)r©   r�   r³   rÿ   r    r%  r   r-  r  Ú
subprocessÚTimeoutExpiredr   r°   ÚidentÚjoinr  rÍ   r±   rÇ   r·   rè   rá   s   &r   rÍ   ÚManagedWorker.close<  s®  € Ø�‰�‰ÔØ�‰×ÑÔØ�<‰<×ÑÓÒ&Ø×Ñ UÐÔ+Ø×Ñ EÐÔ*ð		+Ø�L‰L×Ñ aÐÔ(ð ×Ñ TÐÔ*Ø�;‰;×ÑÒ(Ø�K‰K×Ñ QÐÔ'Ø�‰×Ñ× Ñ Ô"Ø�;‰;ÒØ�L‰L×Ñ×%Ñ%Õ'à�K‰K×Ñ QÐÔ'Ø×ÑÒ(Ø×Ñ×"Ñ"¨1Ð"Ö-Ø�\‰\× Ñ Ò,Ø�L‰L×Ñ×%Ñ%Ö'ñ -øô# ×(Ñ(ô 	-Ø×Ñ TÐÔ*Ø×Ñ DÐÔ)äœ*×3Ñ3×4Õ4Ø—‘×!Ñ!¨!Ð!Ô,÷ 5×4×4Õ4úð		-ús+   Á6F7 Æ7AIÈH:È.IÈ:IÉIÉI)r¶   r³   rµ   r´   r©   r§   r    r±   r¸   r·   r«   r­   r¬   r¡   r¤   r°   N)r   r   r   r   rº   r¯   rÑ   rË   rÚ   rë   rô   rø   r  r  r  rÁ   r   r-  rÍ   r   Ú__classdictcell__)Ú__classdict__s   @r   rš   rš   “   sY   ø‡ € òò8	ò(ò"òò"ò
Lò8òò@'òMò'ò
òB÷(ð (r   rš   c                 óà   € \        V R / 4      P                  VP                  4      pVf   R# V P                  WR4       V P	                  VP                  V4       VP                  RR/4       R# )Ú_managed_workersFzsession:controlr€   r«   T)rs   r.   r)   Ú	authorizeÚcheck_approval_generationrô   )r3   Úactorr4   Ú
generationr¡   s   &&&& r   Úinterrupt_managedr=  Y  sa   € Ü�YÐ 2°BÓ7×;Ñ;¸C¿N¹NÓK€FØ‚~ÙØ×Ñ˜Ð$5Ô6Ø×'Ñ'¨¯©¸
ÔCØ
‡N�N�F˜FÐ#Ô$Ùr   c                 ón  € V P                   VP                  ,          pVP                  pVP                  R 4      pVR8X  d¦   \	        V4      R R08X  d”   VR,          pVP
                  P                  VR4       VP                  P                  VR4      p	V	'       dI   VP                  P                  VP                  RVRVR,          /V	^,          R,          R,           R7       R	# VR9  d   R# \        VP
                  4      ^8¼  d   \        R4      hVR
8X  ds   0 Rmp
VP                  R4      p\	        V4      R R08w  g/   \        V\        4      '       d   \	        V4      V
,
          '       d   \        R4      hVP                  R4      pMÂ\	        V4      0 Rm8w  g�   \        VR,          \        4      '       d€   \        VR,          \        4      '       dc   \         ;QJ d#    R VR,           4       F  '       g   K   R	M	  RM! R VR,           4       4      '       g   \#        VR,          4      \$        Jd   \        R4      hVR,          p\        V\        4      '       d   V'       d   W†P                  9   d   \        R4      hVP&                  VP
                  V&   VR
8X  d2   V P)                  VP                  VR,          VP*                  X4       R	# \-        W„R,          VR,          VR,          \.        P0                  ! 4       R7      pV P3                  VP                  VR,          V4       R	# )r€   Úprompt_settledr  NÚexecution_generationr<  r  z.settled)Ú
event_typeTÚapprovalFrï   Ú
request_idÚdataÚinvalid_worker_frameÚquestionÚchoicesÚmulti_selectc              3   óL   "  € T F  p\        V\        4      '       * x € K  	  R # 5ir   ©rŒ   rh   )r‚   Úcs   & r   r„   Ú _prompt_frame.<locals>.<genexpr>|  s   é € ÐHÑ7G°!œ: a¬Ó-×-Ñ-Ó7Gùs   ‚"$)Ú
clarify_idrF  rG  rH  Úevent>   ÚclarifyrB  >   ÚeditÚcommandrC  ÚdescriptionÚsmart_deniedÚallow_sessionÚallow_permanent>   r€   rG  rF  r  rH  )r(   r)   Úcontrolsr.   r�   Úremote_respondersrk   ÚpendingÚevent_streamÚpublishÚlenr   rŒ   rX   rh   ÚlistrŽ   r€   ru   r  Úregister_approvalrO   r   r¢   r¨   Úregister_clarify)r3   r4   r^   r¡   r‘   rb   rV  r  r  ÚsavedÚfieldsrD  rw   s   &&&&&        r   Ú_prompt_framera  c  s’  € Ø×Ñ˜cŸn™nÕ-€DØ�}‰}€HØ�9‰9�VÓ€DØÐÔ¤C¨£J°6¸;Ð2GÔ$GØ˜+Õ&ˆ	Ø×"Ñ"×&Ñ& y°$Ô7Ø× Ñ ×$Ñ$ Y°Ó5ˆßØ×Ñ×%Ñ% c§n¡n°{ÀIØ&¨¨LÕ(9ð7;ØGLÈQÅxÐPVÕGWÐZdÕGdð &ô fáØÐ*Ô*ÙÜ
ˆ8×%Ñ%Ó&¨"Ô,ÜÐ =Ó>Ð>ØˆzÔÚuˆØ�y‰y˜Ó ˆÜˆu‹:˜& &Ð)Ô)´¸DÄ$×1GÒ1GÌ3ÈtË9ÐW]×K]ÔK]Ü#Ð$:Ó;Ð;Ø—H‘H˜\Ó*‰	ä�‹JÒVÔVÜ! %¨
Õ"3´S×9Ò9ÄÈEÐR[ÕL\Ô^b×AcÒAcß“3ÑH°u¸YÖ7GÓH—3—3’3ÑH°u¸YÖ7GÓH×HÒHÌDÐQVÐWeÕQfÓLgÔosÓLsÜ#Ð$:Ó;Ð;Ø˜+Õ&ˆ	Ü�i¤×%Ò%¯Y¸)×GWÑGWÔ:WÜÐ 6Ó7Ð7Ø,2¯N©N€H×Ñ˜yÑ)ØˆzÔØ×#Ñ# C§N¡N°C¸Õ4EÀtÇzÁzÐSWÔXñ
 ô  ¨9ÀZÕ?PÐZ_Ð`iÕZjØ-2°>Õ-BÌ)Ï/Ê/ÓJ[ô]ˆà×"Ñ" 3§>¡>°3°|Õ3DÀeÔLÙr   c                óR  € ^ RI Hp ^ RIHp ^ RIHp V! \        V P                  4      4      pVP                  4       '       g   R# V! V4      pV'       g   V! 4       '       g   R# ^ RIH	p ^ RIH
pHpHp	 V! V	! \        P                  P                  4       V4      RR7      p
V! V4      pV'       d   V! V
R	R
7       M/ \!        WJ4      CVCpT
P#                  VP%                  4        UUu/ uF  w  rÍVf   K  WÍbK  	  upp4       \        V4      V
R&   ^ RIHp V! V
4       V
# u uppi )u•  Child env for the OWNING profile under multiplex: its HERMES_HOME plus its ``.env``
secrets over a scrubbed base, never the launch profile's process environment (the same
rule MCP stdio children and shell hooks follow) â€” except for the launch profile's own
worker, whose scope legitimately includes its frozen launch env. Single-profile gateways
inherit the process env byte-for-byte, exactly as before.r	   )Úis_multiplex_active)Ú_is_routed_homeN)Úbuild_profile_secret_scope)Ú_scrub_credentialsÚbuild_subprocess_envÚstrip_launch_profile_envT)ÚbaseÚscrub_secretsF©Úinherit_credentialsÚHERMES_HOME)Úapply_subprocess_home_env)Úpathlibr
   Úagent.secret_scoperc  Útools.environments.localrd  rh   r]   ri   re  rf  rg  rh  r$  ÚenvironÚcopyÚ_launch_env_only_credentialsÚupdaterW   Úhermes_constantsrn  )r3   r
   rc  rd  rK   Úroutedre  rf  rg  rh  Úenvr¸   r“   rƒ   rn  s   &              r   Ú_worker_envry  ‹  sö   € õ Ý6Ý8Ù”�I×(Ñ(Ó)Ó*€DØ×Ñ×ÒÙñ ˜TÓ"€FßÑ-×/Ò/ÙÝ=ßkÑkñ
 Ñ$<¼R¿Z¹Z¿_¹_Ó=NÐPTÓ$UÐeiÔ
j€CÙ(¨Ó.€Gßñ 	˜3°EÖ:àHÔ1°$Ó<ÐHÀÐHˆØ‡J�J §¡¤ÔB¡™˜°A”�’¡ÒBÔCÜ˜T›€CˆÑÝ:Ù˜cÔ"Ø€Jùó	 Cs   Ã*D#
Ã7D#
c                ó>  € ^ RI Hp ^ RIHp ^ RIHp V! V 4      P                  4        UUu/ uF  w  rVWQ9  g   K  V! V4      '       d   K  WVbK!  	  pppV! \        V4      RR7      pVP                  4        UUu/ uF  w  rVWX9  g   K  WVbK  	  upp# u uppi u uppi )uJ  Credentials the LAUNCH profile's owner resolves from its frozen launch env
(``launch_secret_scope``: systemd ``Environment=`` / ``op run`` keys with no ``.env`` line) that
the scrub removed from *env* â€” the same mapping the owner's own ``get_secret`` reads for this
profile. Credential names only: non-credential names the constructor removed on purpose
(unbound session context, venv markers) stay removed, and Hermes-internal secrets
(``AUXILIARY_*_API_KEY``, relay auth) never reach a child. Only the launch home's worker calls
this; a routed home's worker sees its own files only.)rf  )Ú_is_hermes_internal_secret)Úlaunch_secret_scopeFrk  )rq  rf  Ú#tools.environments.local_env_policyr{  Ú!tui_gateway.launch_profile_policyr|  rW   rX   )	rK   rx  rf  r{  r|  r“   rƒ   ÚmissingÚplains	   &&       r   rt  rt  ±  s“   € õ <ÝNÝEÙ 3°DÓ 9× ?Ñ ?Ô Aô FÑ A™˜Ø‘,ô Ù'AÀ!×'Dô ˆqŠtÑ A€Gñ Fáœt G›}À%ÔH€EØ$Ÿ]™]œ_Ô?™_‘T�Q°±ŒDˆAŠD™_Ò?Ð?ùóFùó @s   ¬
B»BÁBÁ:
BÂ	Bc                 ó^   € R RRRR/V'       d   RV/M/ CR/ /V P                   VR,          &   R# )ÚresultÚfinal_responseÚ ÚinterruptedTÚinterrupt_messageÚusageÚadmission_id)Úpending_results)r3   r^   Úcauses   &&&r   Ú_interrupted_before_bootstrapr‹  Â  sD   € àÐ# R¨¸Ðp×afÐBUÐW\ÑA]ÐlnÐpØ�ð6€I×Ñ˜c .Õ1Ñ2ñ r   c                ó~   € \        V R/ 4      P                  VR4      pV'       d   V^ ,          V8X  d
   V^,          # R# )z©The gateway restart/shutdown cause latched for this generation before its worker existed
(``run_runtime._stop_spawning_managed``), consumed once; None for a user's Stop.Úpending_stop_causesN)rs   rk   )r3   r)   r<  Úlatcheds   &&& r   Ú_latched_stop_causer�  É  s<   € ô �iÐ!6¸Ó;×?Ñ?À
ÈDÓQ€Gß  W¨Q¥Z°:Ô%=ˆ7�1�:ÐGÀ4ÐGr   c                ó|   € V P                  R4      '       d%   VP                  '       d   / V CRVP                  /C# V # )zUThe wire result carries no interruption cause; the owner recorded which stop it sent.r…  r†  )r.   r­   )Úacceptedr¡   s   &&r   Ú_with_stop_causer’  Ð  s:   € à‡|�|�M×"Ò" v×'8×'8Ð'8ØC�(ÐCÐ/°×1BÑ1BÑCÐCØ€Or   c                óþ  a€ ^ RI pV P                  p \        WS4      pV'       d   Wa8w  d   \        WQV4      MRp\	        \
        P                  . \        WQ4      OT;'       g    V.O4      4      pV U	u. uF  q•P                  V	4      ;'       g    / NK  	  p
p	R Uau/ uF  oS\        T3R lT
 4       4      bK  	  ppTR,          TR,          ,           TR,          ,           pR/ TCRTR	TR,          R
YÜR,          ,           R\        R T
 4       4      R\        TP                  R4      ;'       g#    T
R,          P                  R4      ;'       g    R4      /C/# u up	i   TP                   d    / u # i ; iu upi )aþ  A managed turn's ``message.complete.usage``: the worker exits with its turn, so the session-cumulative counters come from the rows its usage writes committed. A worker that compresses mid-turn ends on a child of this reservation's session; the owner's execution row records that tip (compression moves it in the same transaction), so the path from the tip back to the reservation plus the reservation's own compression ancestors is summed, and stale siblings or the conversation a branch came from never count.NÚinput_tokensÚoutput_tokensÚcache_read_tokensÚcache_write_tokensc              3   ól   <"  € T F)  p\        VP                  S4      ;'       g    ^ 4      x € K+  	  R# 5i)r9   N©Úintr.   )r‚   r^   Úkeys   & €r   r„   Ú)_settled_session_usage.<locals>.<genexpr>â  s)   øé € Ð>¹°#”s˜3Ÿ7™7 3›<×,Ð,¨1×-Ð-»ùs   ƒ!4¥4Úsession_usageÚprompt_tokensÚcompletion_tokensÚtotal_tokensÚ	api_callsc              3   ój   "  € T F)  p\        VP                  R 4      ;'       g    ^ 4      x € K+  	  R# 5i)Úapi_call_countNr™  )r‚   r^   s   & r   r„   rœ  ç  s.   é € Ð.cÑ^bÐWZ¬s°3·7±7Ð;KÓ3L×3QÐ3QÐPQ×/RÐ/RÓ^bùs   ‚!3¤3Úmodelr„  )r”  r•  r–  r—  Úreasoning_tokenséÿÿÿÿ)Úsqlite3ÚdbÚ_execution_tipÚ_continuation_pathr\  rX   ÚfromkeysÚ_compression_ancestorsÚget_sessionr  Úsumrh   r.   )r3   r)   r‘  rˆ   r§  r¨  Útipr`   ÚidsÚsidÚrowsr›  ÚcountsÚprompts   &&&&       `  r   Ú_settled_session_usagerµ  ×  sˆ  ø€ ãØ	�‰€BðÜ˜RÓ.ˆß:=À#ÔBSÔ! "°#Ô6ÐY]ˆÜ”4—=‘=Ð!cÔ#9¸"Ó#IÐ!cÈT×MaÐMaÐV`ÐUaÐ!cÓdÓeˆÙ58Ó9±S¨c—‘˜sÓ#×)Ð) rÒ)±SˆÐ9ñKhô iñ KhÀ3ˆc”3Ô>¹Ó>Ó>Ò>ñ Kh€Fð ià�NÕ# fÐ-@Õ&AÕAÀFÐK_ÕD`Õ`€FØð b ð b¨¸ÐATÐV\Ð]lÕVmØ,¨f¸oÕ7NÕ.NØ)¬3Ñ.cÑ^bÓ.cÓ+cØ%¤s¨8¯<©<¸Ó+@×+_Ð+_ÀDÈÅHÇLÁLÐQXÓDY×+_Ð+_Ð]_Ó'`ñbð cð cùò :øØ�=‰=ô ØŠ	ðüòis0   “A!E! Á4EÂEÂE! ÂE:ÅE! Å!E7Å6E7c                óæ   € V'       g   R# V P                  4       ;_uu_ 4       pVP                  RV34      P                  4       pRRR4       X'       d
   V^ ,          # R#   + '       g   i     L#; i)zRThe session this worker execution last wrote to, as the owner's ledger records it.Nz=SELECT session_id FROM worker_executions WHERE execution_id=?)Ú	_read_ctxÚexecuteÚfetchone)r¨  rˆ   Úconnr^   s   &&  r   r©  r©  ë  sQ   € çÙØ	�‰�Œ˜4Ø�l‰lÐZÐ]iÐ\kÓl×uÑuÓwˆ÷ 
çˆ3ˆq�6Ð"˜dÐ"÷ 
�ús   £"A Á A0	c                óú   € V.TrCWA8w  d_   \        V4      ^È8:  dO   V P                  V4      pV'       d   V P                  V4      '       g   R# VR,          pVP                  V4       Kd  WA8X  d   VRRR1,          # R# )zgIds from *start* to *tip* when *tip* reaches *start* through compression continuations only, else None.NÚparent_session_idr¦  )r[  r­  Ú_is_compression_child_rowrÔ   )r¨  rê   r¯  r`   Úcurrentr^   s   &&&   r   rª  rª  ô  so   € à�E˜3ˆ'Ø
Ô
œs 4›y¨CÔ/Ø�n‰n˜WÓ%ˆß˜"×6Ñ6°s×;Ò;ÙØÐ)Õ*ˆØ�‰�GÖØ Ô)ˆ4‘�"��:Ð3¨tÐ3r   c                ó  € . V P                  V4      r2V'       db   V P                  V4      '       dK   \        V4      ^È8  d;   VR,          pWB9   g   WA8X  d   M$VP                  V4       V P                  V4      pKi  VRRR1,          # )zWRoot-first ids of the sessions *session_id* continues by compression, excluding itself.r¼  Nr¦  )r­  r½  r[  rÔ   )r¨  r)   Ú	ancestorsr¾  Úparents   &&   r   r¬  r¬     st   € à˜RŸ^™^¨JÓ7ˆwß
�b×2Ñ2°7×;Ò;ÄÀIÃÐQTÔ@TØÐ,Õ-ˆØÔ &Ô"6ØØ×Ñ˜Ô Ø—.‘. Ó(ŠØ‘T�r�T�?Ðr   c                ór   € \        V RR4      pVf	   / ;q0n        VP                  R4      W1P                  &   V# )zôMark the generation pre-worker: until the worker registers, a gateway stop has nothing to
signal, so it latches for this generation instead (#134889 GW-22). Set before ``@`` expansion,
which may await the network, so a Stop there is never lost.Ú_managed_spawningNr<  )rs   rÃ  r.   r)   )r3   r4   r^   Úspawnings   &&& r   Ú_mark_spawningrÅ    s>   € ô �yÐ"5°tÓ<€HØÒØ13Ð3ˆÔ.Ø"Ÿw™w |Ó4€H�^‰^ÑØ€Or   c           	     ó2  € VP                  R4      p\        V R/ 4      pVe!   VP                  VP                  4      V8w  d   R# WAP                   V P                  P	                  VP                  R4       \        W\        WP                  V4      4       R# )z²A Stop latched for this generation while it had no worker (a gateway stop during ``@``
expansion, or a user's Stop): consume it and record the interrupted result, never spawning.r<  Úpending_stopsNFT)r.   rs   r)   rÃ  rk   r‹  r�  )r3   r4   r^   r<  Ústopss   &&&  r   Ú_stopped_before_spawnrÉ    s}   € ð —‘˜Ó&€JÜ�I˜°Ó3€EØÒ˜UŸY™Y s§~¡~Ó6¸*ÔDÙØ�n‰nÐØ×Ñ×#Ñ# C§N¡N°DÔ9Ü! )Ô2EÀi×Q_ÑQ_ÐakÓ2lÔmÙr   c              ƒ  ó^  "  € \        WV4      pVP                  R4      p \        P                  ! \        V 4      G Rj  x€L
 p\        P                  ! \        \        4      P                  4      G Rj  x€L
 P                  ^,          p^ RI	H
p ^ RIHp V! V P                  4      p	T! \        P                  \         P"                  RR.3RTR\        P$                  R	TR
\        P$                  RV	f   \        P&                  M\        P$                  /\(        B G Rj  x€L
 p
\7        T
4      pT	e   TP9                  T	4       \;        T RR4      pTf	   / ;qÀn        Y¼TP.                  &   TP-                  TP.                  R4       \3        YP.                  T4      Tn        Yº3#  ELg EL5 L‹  \        P*                   dA    TP-                  TP.                  R4       \1        Y\3        YP.                  T4      4        R# \4         d    TP-                  TP.                  R4       h i ; i5i)zÔSpawn the turn's child and register it for Stops: ``(worker, process)``, or None when the spawn was cancelled (the
interrupted result is already recorded). The generation stays marked spawning until registration.r<  N)Úacquire_process)Úworker_log_pathz-mzagent.managed_workerÚcwdr  rx  rÇ   rè   r8  ) rÅ  r.   rª   Ú	to_threadry  r
   Ú__file__ÚresolveÚparentsÚgateway.session_worker_spawnrË  rç   rÌ  r]   r0  ÚPopenÚsysÚ
executableÚPIPEÚDEVNULLÚWORKER_POPENÚCancelledErrorrk   r)   r‹  r�  ÚBaseExceptionrš   rë   rs   r8  r­   )r3   r4   r^   rÄ  r<  rx  rÍ  rË  rÌ  Úlog_pathr    r¡   Úworkerss   &&&          r   Ú_spawn_registered_workerrÝ  $  sÖ  é € ô ˜i¨cÓ2€HØ—‘˜Ó&€JðÜ×%Ò%¤k°9Ó=×=ˆÜ×&Ò&¤t¬H£~×'=Ñ'=Ó>×>×GÑGÈÕJˆÝ@ÝFÙ" 9×#7Ñ#7Ó8ˆÙ'¬
×(8Ñ(8¼3¿>¹>È4ÐQgÐ:hñ `Øð`Ü%Ÿ?™?ð`Ø03ð`Ü<F¿O¹Oð`à)1Ò)9”:×%Ò%¼z¿¹ð`äR^ñ`÷ `ˆô ˜7Ó#€FØÒØ×Ñ˜HÔ%Ü�iÐ!3°TÓ:€GØ‚Ø/1Ð1ˆÔ,Ø$ˆC�N‰NÑØ‡L�L�—‘ Ô&Ü+¨I·~±~ÀzÓR€FÔØˆ?Ðò3 >Ú>ñ`øô ×!Ñ!ô à�‰�S—^‘^ TÔ*Ü% iÔ6IÈ)×UcÑUcÐeoÓ6pÔqÚÜô Ø�‰�S—^‘^ TÔ*Øðüsf   ‚H-¡F. ¿F&Á 4F. Á4F)Á5B+F. Ä F,Ä!F. Ä%BH-Æ&F. Æ)F. Æ,F. Æ.AH*Ç?H-ÈH*ÈH*È*H-c              ƒ  ó¸   "  € ^ RI HpHp V! V4      '       g,   V! V4      pRVR/ /V P                  VR,          &   VR,          # \	        WW#4      G Rj  x€L
 #  L5i)zéThe ingress route into a managed worker. A removed folder is refused before a worker exists,
like the in-process runner: a worker failing in its policy scope reads as a LOST execution
(``unknown``) and parks every follower behind it.)Úworkspace_readyÚworkspace_unavailable_resultr‚  r‡  rˆ  rƒ  N)r&   rß  rà  r‰  Úexecute_managed)r3   r4   r^   r5   rß  rà  r‚  s   &&&&   r   Úadmit_managedrâ  F  s^   é € ÷ UÙ˜6×"Ò"Ù-¨fÓ5ˆØ:BÀFÈGÐUWÐ9Xˆ	×!Ñ! # nÕ"5Ñ6ØÐ&Õ'Ð'Ü  °Ó=×=Ð=Ñ=ùs   ‚AAÁAÁAc              ƒ   óœ  "  € ^ RI Hp ^ RIHpHp \        WV4        V! WV4      G Rj  x€L
 w  rxTeI   T P                  P                  TP                  R4       RT! Y(4      R/ /T P                  TR,          &   T# \        YT4      '       d   R# \        YT4      G Rj  x€L
 p	T	f   R# T	w  r«T P                  pT P                  TP                  TR,          T
4       R;rÞRp T
P                  \         ^ R	7      G Rj  x€L
 pT
P"                  P%                  4       '       d   \'        R
4      h^ RIHp T! T \-        \.        T TR,          Y²R,          TR7      4      G Rj  x€L
 pTR,          TR,          3T
n        \2        P4                  ! \6        YY#Y÷4      G Rj  x€L
 pT
P8                  P;                  R TR,          TR,          3 4       4       \2        P4                  ! T
P<                  T4      G Rj  x€L
  T
P>                  PA                  4         T
P                  R\B        R	7      G Rj  x€L
 pT PD                  PG                  TP                  4      TR,          8w  d   \'        R4      hT PH                  TP                  ,          PJ                  PL                  ;_uu_ 4        \O        YY*T4      '       d    RRR4       K´   RRR4       TRRRR/8X  d   \'        R4      hTPG                  R4      pTR8X  d+   \Q        T4      RR08X  d   TR,          TR,          8X  d   EK  TR8X  da   \Q        T4      RR08X  dO   \S        TR,          \T        4      '       d2   T PW                  TP                  TR,          RRTR,          /4       EK|  T! YP                  TR,          T4      '       d   EK   TR8X  d›   \Q        T4      RR08X  d‰   Tf…    \Y        TR,          4      w  rÞT PH                  TP                  ,          P\                  P_                  TP                  R4       \2        P4                  ! T
P<                  RR/4      G Rj  x€L
  EKA  TRR/8X  Ed   Teþ   \a        \b        Pd                  4      ;_uu_ 4        \2        P4                  ! TPf                  ^
4      G Rj  x€L
  RRR4       \i        YÚ4      pR/ TCR R/CRT/\2        P4                  ! \j        YR!,          YßR",          4      G Rj  x€L
 CT P                  TR,          &   TR#,          TP                  TP                  R4       \2        P4                  ! T
Pl                  4      G Rj  x€L
  # \'        R$4      h ELD  \         d)    T P                  P                  TP                  R4       h i ; i EL EL« ELL EL EL» EL„  + '       g   i     ELö; i  \Z         d   p\'        R4      ThRp?ii ; i ELœ ELC  + '       g   i     ELJ; i EL
 L«  \n        \2        Pp                  3 EdY   p^ RI9pTPu                  \v        4      Py                  R%\S        T\&        4      '       d   TPz                  M\}        T4      Pv                  4       Tf©   \S        T\2        Pp                  4      '       g(   \S        T\&        4      '       dr   TPz                  R
8X  da   \        YT
P€                  4      u Rp?TP                  TP                  R4       \2        P4                  ! T
Pl                  4      G Rj  x€L 
  # h ^ R&IAHBp ^ RIHp T! T \-        TYT4      4      G Rj  x€L 
  T PH                  TP                  ,          pTPJ                  PL                  ;_uu_ 4        TP\                  P_                  TP                  R4       T P‡                  T4       TPJ                  P‰                  TP                  RR'R(R'RTR,          R)R*R+R/4       RRR4       M  + '       g   i     M; iT PŠ                  P                  TR,          R4      pTe(   TP�                  4       '       g   TP�                  R'4       \‘        R,4      ThRp?ii ; i  TP                  TP                  R4       \2        P4                  ! T
Pl                  4      G Rj  x€L 
  i ; i5i)-r9   )Úpublish_worker_tool_event)Úmanaged_turn_textÚrefused_turn_resultNr‚  r‡  rˆ  r„  r<  )r÷   rý   )Útracked_writeÚprincipal_id)rˆ  r    rè  Úhelloré   Úbirthc              3   ój   "  € T F)  p\        V\        4      '       g   K  V'       g   K%  Vx € K+  	  R # 5ir   rJ  r�   s   & r   r„   Ú"execute_managed.<locals>.<genexpr>z  s%   é € ÐiÑ)L AÔPZÐ[\Ô^a×PbœaÔghŸašaÓ)Lùs   ‚3Ÿ3©
3rM   ÚsecretTÚstale_generationr€   ÚerrorÚreasonÚmanaged_worker_failedÚreadyÚdeltarN   zmessage.deltaÚinvalid_worker_resultÚfinishÚfinishedÚlocal_viewerr)   rˆ   rƒ  rE  zManaged worker lost: %s)Úlose_admission_workerzWorker execution is unknown.ÚcontentÚoutcomeÚunknownÚstatusÚmanaged_worker_unknown)IÚgateway.run_turn_progressrä  Úgateway.session_context_refsrå  ræ  rÅ  rÚ  rÃ  rk   r)   r‰  rÉ  rÝ  r8  Úadopt_agentr  ÚHELLO_SECONDSr«   r¿   r   Úgateway.session_runtime_workersrç  r   r   r¡   rª   rÎ  rd   r¸   ÚextendrÁ   r°   rê   ÚSTOP_ACK_SECONDSÚ	executingr.   r(   rY  Úlockra  r�   rŒ   rh   Úpublish_executionr   r�   rV  Úsnapshotr   r0  r1  r  r’  rµ  rÍ   rÎ   rÙ  ÚloggingÚ	getLoggerr   Úwarningrð  r€   r‹  r­   Ú"gateway.session_worker_reservationrø  Ú_publish_pendingrZ  ÚwaitersÚdoneÚ
set_resultr   )r3   r4   r^   r5   rä  rå  ræ  rN   ÚrefusalÚspawnedr¡   r    rÜ  r‘  r‡  rL   ré  rç  r‘   r  r—   r	  rø  rb   Úwaiters   &&&&                     r   rá  rá  R  sX  é € ÝCçSÜ�9 3Ô'ðÙ/°	ÀÓG×G‰ˆð ÒØ×#Ñ#×'Ñ'¨¯©¸Ô=Ø:BÑDWÐX[ÓDeÐgnÐprÐ9sˆ	×!Ñ! # nÕ"5Ñ6ØˆÜ˜Y¨S×1Ò1ÙÜ,¨Y¸SÓA×A€GØ‚ÙØ�O€FØ×(Ñ(€Gð ×Ñ˜#Ÿ.™.¨#¨lÕ*;¸VÔDØÐ€HØ€EðT.ð ×'Ñ'¬¸1Ð'Ó=×=ˆØ�;‰;×Ñ×Òä#Ð$<Ó=Ð=åAÙ# I¬wÔ7OÐQZØ!$ ^Õ!4¸gÐXfÕTgÐotô0vó w÷ wˆà˜u� u¨W¥~Ð6ˆŒä×'Ò'¬
°IÀCÐQVÓ]×]ˆØ�‰×ÑÑi¨%°	Õ*:¸EÀ(½OÑ)LÓiÔiÜ×Ò §¡¨UÓ3×3Ð3Ø�‰×ÑÔØØ ×+Ñ+¨DÔ6FÐ+ÓG×GˆEà×"Ñ"×&Ñ& s§~¡~Ó6¸#¸lÕ:KÔKÜ'Ð(:Ó;Ð;Ø×#Ñ# C§N¡NÕ3×@Ñ@×E×EÓEÜ  °¸e×DÒDØ÷ FÑEØD÷ Fð ˜ ¨(Ð4KÐLÔLÜ'Ð(?Ó@Ð@Ø—9‘9˜VÓ$ˆDØ�wŒ¤3 u£:°&¸%°Ô#@ÀUÈ5Å\ÐUZÐ[`ÕUaÔEaÚØ�wŒ¤3 u£:°&¸&Ð1AÔ#AÄjÐQVÐW]ÕQ^Ô`c×FdÒFdØ×+Ñ+¨C¯N©N¸CÀÕ<MÈÐagÐinÐouÕivÐ`wÔxÚÙ(¨·N±NÀCÈÕDUÐW\×]Ò]ÚØ�xÔ¤C¨£J°6¸8Ð2DÔ$DÈÒIYðNÜ&3°E¸(µOÓ&D‘O�Hð ×"Ñ" 3§>¡>Õ2×;Ñ;×DÑDÀSÇ^Á^ÐUYÔZÜ×'Ò'¨¯©°f¸hÐ5GÓH×HÐHÚØ˜ Ð,Õ,°Ò1Eô œj×7Ñ7×8Õ8Ü!×+Ò+¨G¯L©L¸"Ó=×=Ð=÷ 9ä+¨HÓ=�ð Ð@ Ð@¨>¸4Ñ@À'È5ðBHä#×-Ò-Ô.DÀiÐWcÕQdÐfnð  wEõ  qFó  G÷  GðBH�	×)Ñ)¨#¨nÕ*=Ñ>ð  Ð 0Õ1ð< 	�‰�C—N‘N DÔ)Ü×Ò §¡Ó-×-Ñ-ô= $Ð$:Ó;Ð;òU HøÜô Ø×#Ñ#×'Ñ'¨¯©¸Ô=Øðúò Bò >òwò ^â3ò H÷ F×EÐEûô  "ô NÜ+Ð,CÓDÈ#ÐMûðNúò Iò >÷ 9×8Ð8úò Gñ@ 	.øô; ”w×-Ñ-Ð.õ IÛØ×Ñœ(Ó#×+Ñ+Ð,EÜ$ SÔ*;×<Ò<ˆC�JŠJÄ$ÀsÃ)×BTÑBTô	VàŠ=Ü˜#œw×5Ñ5×6Ò6Ü˜sÔ$5×6Ò6¸3¿:¹:ÐIaÔ;aô 5°YÀV×EVÑEVÓWÔWð& 	�‰�C—N‘N DÔ)Ü×Ò §¡Ó-×-Ò-ð' ÝLÝAÙ˜I¤wÐ/DÀiÐV[Ó'\Ó]×]Ñ]Ø×!Ñ! #§.¡.Õ1ˆØ×Ñ×#×#Ó#Ø�M‰M×"Ñ" 3§>¡>°4Ô8Ø×&Ñ& sÔ+Ø×Ñ×%Ñ% c§n¡n°vÐ?]ØÐ9¸>È3È~ÕK^Ð`iÐktØ˜'ð7#ô $÷ $×#×#Ð#úð ×"Ñ"×&Ñ& s¨>Õ':¸DÓAˆØÒ f§k¡k§m¢mØ×ÑÐ<Ô=ô &Ð&>Ó?ÀSÐHûð5Iûð8 	�‰�C—N‘N DÔ)Ü×Ò §¡Ó-×-Ò-üsÉ  ‚cžU1 ªU.«U1 ±A/cÂ V'Â!AcÃ%X Ã?V*Ä #X Ä$=X Å!V-Å";X ÆV0ÆAX Ç8V3Ç99X È2V6È3A9X Ê,V9Ë
X ËDX ÏW Ï)A'X ÑW,Ñ6X Ò%W2Ò,W/Ò-W2Ò1AX Ó<XÓ=!X Ô?cÕX	ÕcÕ#X Õ.U1 Õ13V$Ö$cÖ*X Ö-X Ö0X Ö3X Ö6X Ö9W
	×	X ×W)×W$×$W)×)X ×/W2×2X	×=
X Ø	cØa?Ø'B>a:Û%a?Û&b Û*?cÜ)\,Ü*cÜ0$a:Ý]ÝA a:ÞA/`à	a:à`àAa:áa:á:a?á?b âA c	ãcãc	ã	cr   ):r   rª   Ú
contextlibr   r   Úcollectionsr   Údataclassesr   r   Ú	functoolsr   r/   r$  r¥   r¢   Útypesr   ro  r
   r0  rÔ  rð   Úagent.managed_workerr   r   r   r  r   Úhermes_state_runtimer   r  r  rØ  rÌ   r   r7   rd   r[   rY   r˜   rš   r=  ra  ry  rt  r‹  r�  r’  rµ  r©  rª  r¬  rÅ  rÉ  rÝ  râ  rá  r   r   r   Ú<module>r     sù   ðÙ OÛ ß /Ý ß 'Ý Û Û 	Û Û Ý !Ý Û Û 
Û ç HÑ HÝ GÝ 2ð €ð Ð ð $ T¨;¸Ð=€ôZ˜lô Zòô(\ò@ò$*ð ñó ð÷:C(ñ C(òLò%òP#òL@ô"òHòôcò(#ò	4ò	òò
òòD	>ôn.r   