+
    jHàjPb  ã                   óž  € R t ^ RIt^ RIHt ^ RIHt ^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIHt ]	P                  ! ]4      tR(t]
P$                  ! 4       t^tR tR tR tR tR	 tR
 tR tR tR tR t ! R R4      tR t R t!R t"R t#]RR/R l4       t$R t%R t&R t'R t(R t)R t*R t+R t,R  t-R! t.R" t/R# t0R$ t1R% t2R& t3]R' 4       t4R# ))a  Editor MCP servers are session state the gateway owns; an ACP connection only requests them.

Only a fingerprint and the selected schema manifest are durable. Editors must
resupply the exact transport specification after owner restart, including argv:
credentials are not reliably distinguishable from ordinary command arguments.
A different specification is a ``session.mutate editor_mcp`` (control capability,
revision/generation fenced, idle only), never an implicit swap on attach.

The frozen manifest is part of the session's prompt-cache prefix, so it only changes
at a turn boundary: through that mutation while the session is idle, or through the
re-freeze the drain runs at the start of an admission (``refreeze_editor_mcp``).
Inside an execution it never changes.
N)Úcontextmanager)Úreplace)ÚRuntimeStoreErrorc                 ó4   € \         P                  ! V R RR7      # )T)Ú	sort_keysÚ
separators)Ú,Ú:)ÚjsonÚdumps)Úvalues   &Ú>/home/ubuntu/.hermes/hermes-agent/gateway/session_local_mcp.pyÚ_jsonr   !   s   € Ü�:Š:�e t¸
ÔCÐCó    c                 óx   € \         P                  ! \        V 4      P                  4       4      P	                  4       # ©N)ÚhashlibÚsha256r   ÚencodeÚ	hexdigest)Úserverss   &r   Úfingerprintr   %   s'   € Ü�>Š>œ% ›.×/Ñ/Ó1Ó2×<Ñ<Ó>Ð>r   c                 ó†  € ^ RI HpHpHp ^ RIHp RVRVRV/p\        V \        4      '       g%   \        RRR\        V 4      P                   2R	7      h\        V 4      ^8”  d   \        RRR
\        V 4       2R	7      h\        \        V 4      4      R8”  d   \        RRRR	7      h\        4       p V  Fu  pVP                  RR4      pWX,          P                  V4      p	V	P                   '       d   V	P                   V9   d   \#        R4      hVP%                  V	P                   4       Kw  	  R#   T\&        \(        \*        \"        3 dy   p
\        Y¤4      '       d*   RP-                  R T
P/                  RR7       4       4      pM'\1        T
4      R8X  d   RM\        T
4      P                  p\        RRRT 2R	7      T
hRp
?
ii ; i)é    )ÚMcpServerStdioÚMcpServerHttpÚMcpServerSse)ÚValidationErrorÚstdioÚhttpÚsseÚinvalid_paramszeditor.mcp_serverszmust be a list, got )ÚfieldÚdetailzat most 16 servers, got i   z.the serialized server list exceeds 65536 bytesÚtypezduplicate serverz; c              3   ó†   "  € T F7  pR P                  \        \        VR,          4      4       RVR,           2x € K9  	  R# 5i)Ú.Úlocz: r$   N)ÚjoinÚmapÚstr)Ú.0Úerrs   & r   Ú	<genexpr>Ú#validate_servers.<locals>.<genexpr>A   s<   é € ð HÙ'F ð  #Ÿx™x¬¬C°°UµÓ(<Ó=Ð>¸bÀÀVÅÀÕNÛ'Fùs   ‚?AF)Úinclude_inputzunusable server spec: N)Ú
acp.schemar   r   r   Úpydanticr   Ú
isinstanceÚlistr   r$   Ú__name__Úlenr   ÚsetÚgetÚmodel_validateÚnameÚ
ValueErrorÚaddÚKeyErrorÚAttributeErrorÚ	TypeErrorr(   Úerrorsr*   )r   r   r   r   r   ÚkindsÚnamesÚspecÚkindÚmodelÚexcÚwhys   &           r   Úvalidate_serversrG   )   s«  € ßFÑFÝ(Ø�n f¨m¸UÀLÐQ€EÜ�gœt×$Ò$ÜÐ 0Ð8LØ)=¼dÀ7»m×>TÑ>TÐ=UÐ'VôXð 	Xä
ˆ7ƒ|�bÔÜÐ 0Ð8LØ)AÄ#ÀgÃ,ÀÐ'PôRð 	Rä
Œ5�‹>Ó˜UÔ"ÜÐ 0Ð8LØ'WôYð 	Yä‹E€EðPÛˆDØ—8‘8˜F GÓ,ˆDØ•K×.Ñ.¨tÓ4ˆEØ—:—:�: §¡¨uÔ!4Ü Ð!3Ó4Ð4Ø�I‰I�e—j‘jÖ!ó øð œX¤~´yÄ*ÐMô Pä�c×+Ò+Ø—)‘)ñ HØ'*§z¡zÀ zÔ'FóHó H‰Cô ),¨C«Ð4FÔ(FÑ$ÌDÐQTËI×L^ÑL^ˆCÜÐ 0Ð8LØ)?À¸uÐ'EôGØLOð	PûðPús   Â/A;D, Ä,G ÅA3F;Æ;G c                 ó  € V P                  R 4      ;'       g    / pVP                  R4      ;'       g    . pV'       g   R# Vf   \        R4      h\        P                  ! \	        V4      4      V\
        &   / VCRR\        V4      //CV R &   R# )ÚeditorÚmcp_serversNÚlaunch_credentials_unavailabler   )r7   r   r
   Úloadsr   ÚPRIVATE_KEYr   )ÚrequestÚprivaterI   r   s   &&  r   Úprivate_editor_requestrP   I   s|   € Ø�[‰[˜Ó"×(Ð( b€FØ�j‰j˜Ó'×-Ð-¨2€GßÙØ‚ÜÐ @ÓAÐAÜŸ:š:¤e¨G£nÓ5€GŒKÑØX˜6ÐX =°=Ä+ÈgÓBVÐ2WÑX€GˆHÓr   c                óV  € V R8X  d4   \        V\        4      '       d   \        V4      R08w  d   \        R4      hM(V R8w  g   \        V\        4      '       d   RV9  d   VR3# VR,          p\	        V4       \
        P                  ! \        V4      4      p/ VCRR\        V4      //CV3# )z´``(store payload, servers)`` of an ``editor_mcp`` or a ``branch`` naming servers: the list
stays in owner memory; the receipt digest and every store write see only its fingerprint.Ú
editor_mcprJ   r!   ÚbranchNr   )	r2   Údictr6   r   rG   r
   rL   r   r   )Ú	operationÚpayloadr   s   && r   Úprivate_mutation_payloadrW   T   s£   € ð �LÔ Ü˜'¤4×(Ò(¬C°«L¸]¸OÔ,KÜ#Ð$4Ó5Ð5ð -Là	�hÔ	¤j°¼$×&?Ò&?À=ÐX_ÔC_Ø˜ˆ}ÐØ�mÕ$€GÜ�WÔÜ�jŠjœ˜w›Ó(€GØLˆgÐL�} }´kÀ'Ó6JÐ&KÑLÈgÐUÐUr   c                ó’   € R\         P                  ! V P                   RV 2P                  4       4      P	                  4       ,           # )z]A session's own ledger scope: never shared with another session (a fork included) or profile.zeditor-session:r	   )r   r   Ú
profile_idr   r   )Ú	authorityÚsids   &&r   Úsession_scoper\   b   s:   € àœwŸ~š~°×1EÑ1EÐ0FÀaÈÀuÐ.M×.TÑ.TÓ.VÓW×aÑaÓcÕcÐcr   c                óø   € ^ RI Hp \        V4       UUu/ uFW  w  r4VRV! VR,          4       R\        P                  ! V  RV 2P                  4       4      P                  4       R,           2bKY  	  upp# u uppi )zÄIndex -> ledger name: the editor's own server name (the model sees ``mcp__editor_github_<tag>__x``)
plus a per-session tag, so two sessions borrowing same-named servers never adopt one connection.)Úsanitize_mcp_name_componentÚeditor_r9   Ú_r	   :Né   N)Útools.mcp_tool_schemar^   Ú	enumerater   r   r   r   )Úscoper   r^   ÚirB   s   &&   r   Ú_server_namesrf   g   sŠ   € õ Bä[dÐelÔ[môoÙ[mÑPWÐPQð �Ñ4°T¸&µ\ÓBÐCÀ1Ü—.’. E 7¨!¨A¨3 ×!6Ñ!6Ó!8Ó9×CÑCÓEÀbÕIÐJðLò LÙ[mòoð oùó os   •AA6c                ód  € RV 9   d6   V R,          P                  4        UUu/ uF  w  r#\        V4      VbK  	  upp# \        P                  ! V R,          P	                  4       4      P                  4       R,          p\        \        V4      4       Uu/ uF  q"RV RV 2bK  	  up# u uppi u upi )zZThe names a session's manifest was frozen under; manifests without ``names`` predate them.rA   rd   ºNé   Nr_   r`   )ÚitemsÚintr   r   r   r   Úranger5   )Údatar   re   r9   Úprefixs   &&   r   Ú_frozen_namesro   o   s™   € à�$„Ø,0°­M×,?Ñ,?Ô,AÔBÑ,A¡ ”�A“˜’Ñ,AÒBÐBÜ�^Š^˜D �M×0Ñ0Ó2Ó3×=Ñ=Ó?ÀÕD€FÜ/4´S¸³\Ô/BÓCÑ/B¨!�˜˜  ! Ð%Ò%Ñ/BÑCÐCùó CùâCs   ¢B'ÂB-c                ó,  € V '       g   R# RV 9   d-   YR,          P                  4        Uu0 uF  pRV 2kK
  	  up9   # VP                  R\        P                  ! V R,          P	                  4       4      P                  4       R,           R24      # u upi )zVWhether *toolset* is one of the editor toolsets frozen in *data* (a manifest or None).FrA   úmcp-zmcp-editor_rd   rh   r`   )ÚvaluesÚ
startswithr   r   r   r   )rm   Útoolsetr9   s   && r   Ú_frozen_toolsetru   w   sƒ   € çÙØ�$„Ø¸'µ]×5IÑ5IÔ5KÓLÑ5K¨T˜T $ ›=Ñ5KÑLÑLÐLØ×Ñ ¬G¯NªN¸4À½=×;OÑ;OÓ;QÓ,R×,\Ñ,\Ó,^Ð_bÕ,cÐ+dÐdeÐfÓgÐgùò Ms   «Bc                 óè  € / pVP                  4        FÑ  w  rEW,          pVP                  R R4      R8X  dH   RVR,          RVR,          RVP                  R. 4       Uu/ uF  qwR,          VR,          bK  	  upRV/pMNRVR,          R	VP                  R	. 4       Uu/ uF  qwR,          VR,          bK  	  up/pVR ,          R
8X  d   R
VR&   VP                  ^^RR7       WƒV&   KÓ  	  V# u upi u upi )r$   r   ÚcommandÚargsÚenvr9   r   ÚcwdÚurlÚheadersr    Ú	transportF)Úconnect_timeoutÚtool_timeoutÚlazy)rj   r7   Úupdate)	r   rA   rz   Úconfigsre   r9   rB   ÚeÚconfigs	   &&&      r   Ú_configsr…   €   sþ   € Ø€GØ—;‘;–=‰ˆØ�zˆØ�8‰8�F˜GÓ$¨Ô/Ø  i¥°&¸$¸v½,Ø¸T¿X¹XÀeÈRÔ=PÓQÑ=P¸ �i¨¨7­Ò3Ñ=PÑQÐSXÐZ]ð_‰Fð ˜T %�[¨)ÐUY×U]ÑU]Ð^gÐikÔUlÓ5mÑUlÐPQ¸µiÀÀ7ÅÒ6KÑUlÑ5mÐnˆFØ�F�|˜uÔ$Ø&+��{Ñ#à�‰ a°b¸uˆÔEØ�‹ñ !ð €Nùò Rùâ5ms   ÁC*ÂC/c                   ó*   a € ] tR t^‘t o RtR tRtV tR# )Ú_Heldz­One session scope's editor connections. ``users`` executions borrow them right now; between
executions they stay connected only while the session has a viewer (``_viewed``).c                óV   € \         P                  ! 4       V n        ^ V n        RV n        R# )r   N)Ú	threadingÚLockÚlockÚusersr   )Úselfs   &r   Ú__init__Ú_Held.__init__•   s   € Ü—N’NÓ$ˆŒ	ØˆŒ
ØˆÖr   )r   r‹   rŒ   N)r4   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rŽ   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   r‡   r‡   ‘   s   ø‡ € ñY÷ ð  r   r‡   c                 óÂ   € \         ;_uu_ 4        \        V R R4      pVf	   / ;q n        VP                  V\	        4       4      uuRRR4       #   + '       g   i     R# ; i)Ú_editor_mcp_heldN)Ú
_HELD_LOCKÚgetattrr˜   Ú
setdefaultr‡   )rZ   rd   Útables   && r   Ú_heldr�   ›   sD   € ß	ŽÜ˜	Ð#5°tÓ<ˆØŠ=Ø13Ð3ˆEÔ.Ø×Ñ ¤u£wÓ/÷	 
��‹ús   �3AÁA	c           
      ó  a a€ \         ;QJ dB    V V3R  l\        \        S R/ 4      P                  4       4       4       F  '       g   K   R# 	  R# ! V V3R  l\        \        S R/ 4      P                  4       4       4       4      # )c              3   ón   <"  € T F*  w  rVP                   ;'       d    \        SV4      S8H  x € K,  	  R # 5ir   )Úsubscribersr\   )r+   r[   ÚliverZ   rd   s   &  €€r   r-   Ú_viewed.<locals>.<genexpr>¤   s8   øé € ð RÙ P‘9�3ð ×Ñ×JÐJ¤M°)¸SÓ$AÀUÑ$JÔJÛ Pùs   ƒ5�5ÚsessionsTF)Úanyr3   rš   rj   )rZ   rd   s   ffr   Ú_viewedr¥   £   st   ù€ ß‹3õ RÜ $¤W¨Y¸
ÀBÓ%G×%MÑ%MÓ%OÔ PóR�3Œ3ð RŠ3ð Rˆ3õ RÜ $¤W¨Y¸
ÀBÓ%G×%MÑ%MÓ%OÔ PóRó Rð Rr   c           	      óÌ   € ^ RI Hp ^ RIHp VP	                  4        UUu. uF6  w  rEV! WP4      V9   g   K  W#! WP4      ,          P
                  '       g   K4  VNK8  	  upp# u uppi )r   )Ú_servers©Ú_server_key)Útools.mcp_toolr§   Útools.mcp_tool_scoper©   rj   Úsession)rd   rA   r§   r©   re   r9   s   &&    r   Ú
_connectedr­   ¨   s^   € Ý'Ý0à"Ÿ[™[œ]ô d™]‘'�!Ù˜4Ó'¨8Ñ3ô Ø8@ÀÈTÓAYÕ8Z×8bÕ8b÷ ˆA™]ò dð dùó ds    A ¶A ÁA c                 ó2   € ^ RI Hp V! VR7       RV n        R# )r   )Úshutdown_mcp_servers)rd   N)Útools.mcp_tool_lifecycler¯   r   )Úheldrd   r¯   s   && r   Ú_disconnectr²   °   s   € Ý=Ù˜uÕ%Ø€DÖr   ÚpartialFc             #  ó¤  "  € ^ RI HpHp ^ RIHp \        W4      p	\        W$.4      p
V! V4      ;_uu_ 4        V	P                  ;_uu_ 4        V	P                  RV
39  d)   V	P                  '       d   \        R4      h\        W‘4       \        W4      p\        V4      \        V4      8w  d   V! \        W#V4      4       \        W4      pW©n        V	;P                  ^,          un        RRR4        \        X4      \        V4      8w  d   V'       g   \        R4      hV Uu0 uF  pRW<,           2kK  	  ppVP                  4        Uu. uF  qæP                  V4      V9   g   K  VNK  	  pp\!        V4       Uu/ uF  qîVP#                  V4      bK  	  upV3x € V	P                  ;_uu_ 4        V	;P                  ^,          un        V	P                  '       g   \%        W4      '       g   \        W‘4       RRR4       RRR4       R#   + '       g   i     EL*; iu upi u upi u upi   + '       g   i     L=; i  T	P                  ;_uu_ 4        T	;P                  ^,          un        T	P                  '       g   \%        Y4      '       g   \        Y‘4       RRR4       i   + '       g   i     i ; i; i  + '       g   i     R# ; i5i)a  Yield ``(schemas, connected indexes)`` inside the session's tool scope. Only ``partial`` (a
selection being frozen) may leave a server out; an execution needs every server its manifest
was frozen with. A held connection is reused; the last borrower closes it unless a viewer remains.)ÚregistryÚsession_tool_scope)Úregister_mcp_serversNÚsession_busyÚacp_mcp_discovery_failedrq   )Útools.registryrµ   r¶   Útools.mcp_tool_discoveryr·   r�   r   r‹   rŒ   r   r²   r­   r5   r…   Úget_all_tool_namesÚget_toolset_for_toolÚsortedÚ
get_schemar¥   )rZ   rd   r   rA   rz   r³   rµ   r¶   r·   r±   ÚwantedÚ	connectedre   ÚtoolsetsÚnÚtoolss   &&&&&$          r   Ú	_borrowedrÅ   ¶   sî  é € ÷
 <Ý=Ü�Ó"€Dä˜'˜Ó(€FÙ	˜E×	"Õ	"Ø�Y�Y‹YØ×Ñ¨¨f ~Ô5ð —:—:�:Ü+¨NÓ;Ð;Ü˜DÔ(Ü" 5Ó0ˆIÜ�9‹~¤ U£Ô+Ù$¤X¨g¸cÓ%BÔCÜ& uÓ4�	Ø%ÔØ�JŠJ˜!�O�J÷ ð
	-Ü�9‹~¤ U£Ô+·GÜ'Ð(BÓCÐCÙ3<Ó=±9¨a˜$˜u�x˜jÓ)±9ˆHÐ=Ø (× ;Ñ ;Ô =ÓnÑ =˜1×A^ÑA^Ð_`ÓAaÐemÑAm—Q�QÑ =ˆEÐnÜ6<¸U´mÓD±m°�h×)Ñ)¨!Ó,Ò,±mÑDÀiÐOÒOà——“Ø—
’
˜a••
Ø—z—z�z¬'°)×*CÒ*CÜ Ô,÷ ÷+ 
#Ñ	"ß�YˆYüò  >ùÚnùÚDç—û�——“Ø—
’
˜a••
Ø—z—z�z¬'°)×*CÒ*CÜ Ô,÷ ——�ý÷+ 
#×	"Ð	"üs»   ‚6K¸J<Á%H
	Á3A6H
	Ã)J<Ã2 I ÄI Ä"HÄ6I Å
H#Å&H#Å,I Å;H(ÆI ÆJ<Æ0AH-	Ç8J<È 
KÈ
HÈ	J<ÈI È-H=È8J<É J9ÉAJ&Ê	J9Ê&J6Ê1J9Ê9J<Ê<K	Ë	Kc                ód  € \        V RR4      ;'       g    / pV F~  p\        W4      pVP                  V4      pVf   K%  VP                  ;_uu_ 4        VP                  '       g+   VP
                  e   \        W4      '       g   \        WT4       RRR4       K€  	  R#   + '       g   i     K•  ; i)z�The last viewer left (or the sessions retired): close their held editor connections. One an
execution still borrows is closed by that execution when it ends.r˜   N)rš   r\   r7   r‹   rŒ   r   r¥   r²   )rZ   Úsession_idsrœ   r[   rd   r±   s   &&    r   Úrelease_editor_mcprÈ   Û   s…   € ô �IÐ1°4Ó8×>Ð>¸B€EÛˆÜ˜iÓ-ˆØ�y‰y˜ÓˆØŠ<ÙØ�Y�Y‹YØ—:—:�: $×"2Ñ"2Ò">ÄwÈy×G`ÒG`Ü˜DÔ(÷ ‰Yó ÷
 �YˆYús   Á=BÂB/c                ó0  € \         P                  ! VP                  ;'       g    R4      pVP                   Uu0 uF  p\	        WE4      '       d   K  VkK  	  ppRpV'       Edi   \        W4      p\        W4      p	V	P                  ;_uu_ 4        V	P                  '       d   \        R4      h\        W˜4       RRR4       \        Wƒ4      p
\        WW:VP                  RR7      ;_uu_ 4       w  r¼\        \        V
4      \        V4      ,
          4       F/  p\         P#                  RW=,          P%                  R4      V4       K1  	  RRR4       X Uu/ uF  qÝW­,          bK  	  p
pRTR	\'        V4      R
XRV
P)                  4        UUu/ uF  w  rÕ\+        V4      VbK  	  upp/pYjP-                  4        Uu0 uF  pRV 2kK
  	  up,          p\/        Y''       d   \1        V4      MR\3        \        V4      4      R7      pT;'       g    / P%                  R
/ 4      T;'       g    / P%                  R
/ 4      8g  ;'       g    VP                  VP                  8g  pWï3# u upi   + '       g   i     EL²; i  + '       g   i     EL8; iu upi u uppi u upi )zö``(policy, manifest changed)``: *policy* with its editor selection freshly discovered from
*servers* under *sid*'s own scope (blocking). A broken server is left out of the frozen selection
(main skipped it too), so no later execution respawns it.ÚnullNr¸   T©r³   zFEditor MCP server %r failed discovery; session %s continues without itr9   rd   r   ÚschemasrA   rq   )Úeditor_mcp_jsonrÂ   )r
   rL   rÍ   rÂ   ru   r\   r�   r‹   rŒ   r   r²   rf   rÅ   rz   r¾   r6   ÚloggerÚwarningr7   r   rj   r*   rr   r   r   Útuple)rZ   r[   Úpolicyr   Úoldr9   rÂ   rm   rd   r±   rA   rÌ   rÁ   re   ÚreboundÚchangeds   &&&&            r   Úrebind_editor_mcprÕ   é   s  € ô �*Š*�V×+Ñ+×5Ð5¨vÓ
6€CØ!'§¢ÓS¡˜¼È×8R—�¡€HÐSØ€Dß€wÜ˜iÓ-ˆÜ�YÓ&ˆØ�Y�Y‹YØ�z�zˆzÜ'¨Ó7Ð7ä˜Ô$÷	 ô
 ˜eÓ-ˆÜ�y¨¸¿¹ÈT×RÕRÑVjÐW^ÜœC ›J¬¨Y«Õ7Ö8�Ü—‘ÐgØ&�zŸ~™~¨fÓ5°sö<ñ 9÷ Sñ '0Ó0¡i �E•H’¡iˆÐ0Ø˜ ¬{¸7Ó/CÀYÐPWØ°e·k±k´mÔD±m©7¨1œ#˜a›& $š,±mÒDðFˆà¯|©|¬~Ó>©~ t�t˜D˜6“]©~Ñ>Õ>ˆÜ�f¾T¬e°D¬kÀtÔV[Ô\bÐckÓ\lÓVmÔn€GØ—	�	�r�‰˜y¨"Ó-°$·*°*¸"×1AÑ1AÀ)ÈRÓ1PÑP÷ 6ð 6Ø×"Ñ" f§o¡oÑ5ð àÐÐùò- T÷
 �YˆYú÷ S×RÐRüò 1ùãDùÚ>s6   ¹IÁIÂ)I Ã+AI4ÅJÆJÆ5JÉ I1	É4J	c                 óN   € V'       g   V# \        WW#4      w  r$\        WV4       V# r   )rÕ   Úattach_editor_mcp)rZ   r[   rÑ   r   r`   s   &&&& r   Úbind_editor_mcprØ     s'   € ßØˆÜ! )°&ÓB�I€FÜ�i¨Ô1Ø€Mr   c                 ór  € \        V4       \        P                  ! VP                  ;'       g    R 4      pV'       d.   \        P
                  ! VR,          \        V4      4      '       g   \        R4      h\        V RR4      pVf	   / ;q@n	        \        P                  ! \        V4      4      WCR,          &   R# )ú{}r   Úacp_mcp_policy_conflictÚ_local_editor_mcpNrd   )rG   r
   rL   rÍ   ÚhmacÚcompare_digestr   r   rš   rÜ   r   )rZ   rÑ   r   rm   Úborroweds   &&&  r   r×   r×     sŠ   € Ü�WÔÜ�:Š:�f×,Ñ,×4Ð4°Ó5€Dß”t×*Ò*¨4°Õ+>ÄÈGÓ@T×UÒUÜÐ 9Ó:Ð:Ü�yÐ"5°tÓ<€HØÒØ13Ð3ˆÔ.Ü"Ÿjšj¬¨w«Ó8€H�'�]Ór   c                ón  € Vf   R# \        V\        4      '       d   VP                  R4      MRpV. 8X  d   R# ^ RIHp ^ RIHp V! V P                  V P                  VP                  ,          P                  4      pVf   \        R4      hV! VP                  V4       V'       d   \        WV4       R# R# )a4  Call after ordinary resume authorization, before attaching the viewer. An empty or omitted
list keeps the session's servers: ACP load always carries one, so a second editor without MCP
config must not strip the first one's tools for every viewer. Removal is only the fenced
``editor_mcp`` change with ``[]``.NrJ   )Úvalidate_editor)Úpolicy_for_sourcerÛ   )r2   rT   r7   Úgateway.session_local_editorrá   Úgateway.session_policyrâ   Úrunnerr£   Ú
session_idÚsourcer   r×   )rZ   ÚrefrI   r   rá   râ   rÑ   s   &&&    r   Úresume_editor_mcpré     s�   € ð
 ‚~ÙÜ+5°f¼d×+CÒ+Cˆf�j‰j˜Ô'È€GØ�"„}ÙÝ<Ý8Ù˜y×/Ñ/°×1CÑ1CÀCÇNÁNÕ1S×1ZÑ1ZÓ[€FØ‚~ÜÐ 9Ó:Ð:Ù�F—M‘M 6Ô*ßÜ˜)¨WÖ5ñ r   c                óª   € \        W4      p\        W4      pVP                  ;_uu_ 4        \        W24       RRR4       R#   + '       g   i     R# ; i)zbAn empty selection committed: *sid*'s held editor connections close now (blocking), viewer or not.N)r\   r�   r‹   r²   )rZ   r[   rd   r±   s   &&  r   Úretire_editor_mcprë   .  s3   € ä˜)Ó)€EÜ�Ó"€DØ	��‹Ü�DÔ ÷ 
��Šús   «AÁA	c                óÜ  € ^ RI Hp ^ RIHp V! V! V P                  V4      R,          4      p\
        P                  ! VP                  ;'       g    R4      p\        V RR4      pVf	   / ;qpn	        V'       g   VP                  \        W4      R4       R# \        P                  ! VR,          \        V4      4      '       d+   \
        P                  ! \        V4      4      WvR,          &   R# R# )	zaAfter a committed change: *sid*'s borrowed credentials follow its committed policy (memory only).©Úrestore_policy©Úlocal_receiptrÑ   rÚ   rÜ   Nr   rd   )rä   rî   Úhermes_state_localrð   Údbr
   rL   rÍ   rš   rÜ   Úpopr\   rÝ   rÞ   r   r   )rZ   r[   r   rî   rð   rÑ   rm   rß   s   &&&     r   Úinstall_editor_mcprô   6  s°   € å5Ý0Ù™M¨)¯,©,¸Ó<¸XÕFÓG€FÜ�:Š:�f×,Ñ,×4Ð4°Ó5€DÜ�yÐ"5°tÓ<€HØÒØ13Ð3ˆÔ.ßØ�‰”] 9Ó2°DÖ9Ü	×	Ò	˜T -Õ0´+¸gÓ2F×	GÒ	GÜ"&§*¢*¬U°7«^Ó"<ˆ�g•Óñ 
Hr   c                ó¤   € V eL   VP                  R4      '       d3   V P                  P                  VRVR,          RVR,          /RR7       R# R# R# )z One ``session.tools_changed`` on the session's stream when a change altered the manifest:
server names and the generation only, never a transport specification.NÚtools_changedrJ   Úexecution_generationzsession.tools_changed)Ú
event_type)r7   Úevent_streamÚpublish)r¡   ræ   Úresults   &&&r   Úannounce_tools_changedrü   E  sY   € ð Ò˜FŸJ™J ×7Ò7Ø×Ñ×!Ñ! *¨}¸fÀ]Õ>SØ" FÐ+AÕ$Bð/DØPgð 	"ö 	iñ 8Ñr   c             ƒ  óö  "  € ^ RI Hp ^ RIHp VR,          R,          pV! VR,          4      pVP                  R8w  d   \        R4      h\        P                  ! \        WR,          W„4      G R	j  x€L
 w  rš\        P                  ! V	P                  ;'       g    R
4      P                  R/ 4      pT! YY‰T
\        V\        R7       Uu. uF  qÄ\        V4      ,          R,          NK  	  upR7      #  L�u upi 5i)zñ``session.mutate editor_mcp``: discover the new list and freeze it into the policy the next
turn runs under. Equal schemas leave the manifest, and so the prompt-cache prefix, as it was;
only the fingerprint and the borrowed credentials swap.)Ú_rebindrí   ÚsnapshotÚreceiptrÑ   Úacpr!   ræ   NrÚ   rA   )Úkeyr9   )rö   rJ   )Úgateway.session_mutation_policyrþ   rä   rî   rç   r   ÚasyncioÚ	to_threadrÕ   r
   rL   rÍ   r7   r¾   rk   )rZ   r¡   rV   Úpreparedr   rþ   rî   r   rÒ   rÑ   rÔ   rA   re   s   &&&&$        r   Úprepare_editor_mcpr  M  sØ   é € õ 8Ý5Ø�zÕ" 9Õ-€GÙ
˜ Õ*Ó
+€CØ
‡z�z�UÔÜÐ 0Ó1Ð1Ü#×-Ò-Ô.?ÀÐT`ÕLaÐcfÓp×p�O€FÜ�JŠJ�v×-Ñ-×5Ð5°Ó6×:Ñ:¸7ÀBÓG€EÙ�9¨À7ÜAGÈÔSVÕAWÓXÑAW¸A¬¨A«¥°× 7Ð 7ÑAWÑXôZð Zñ qùò  Yùs*   ‚A.C9Á0C2Á1(C9Â/C9Ã	!C4Ã*	C9Ã4C9c                óâ  a aaaa	a
a€ ^ RI Hp ^ RIHoHo ^ RIHo R o	VVV 3R lVP                  4        4        Uu. uF  pVf   K	  VNK  	  upo
V3R loV
V3R lp VP                  V\        ^,           R7      p\        ;QJ d    T	3R lT 4       F  '       g   K   R
# 	  R# ! T	3R lT 4       4      # u upi   \        \        \        3 d    \        P                  R	S R
R7        R# i ; i)züWhether a held server's live ``tools/list`` differs from the tools its connection was
discovered with. Editor servers ignore ``tools/list_changed`` (the manifest is frozen), so
the admission start asks; an unanswered list (bounded) counts as unchanged.)Úmcp_tool_loop)Ú_paginate_full_listr§   r¨   c           	      ó`   € \        V  Uu. uF  qP                  R R7      NK  	  up4      # u upi )r
   )Úmode)r   Ú
model_dump)rÄ   Útools   & r   ÚdumpÚ!_live_tools_changed.<locals>.dumpe  s(   € Ü¹uÓE¹u°t—o‘o¨6�oÖ2¹uÑEÓFÐFùÒEs   Š+c              3   óT   <"  € T F  pSP                  S! VS4      4      x € K  	  R # 5ir   )r7   )r+   r9   r©   r§   rd   s   & €€€r   r-   Ú&_live_tools_changed.<locals>.<genexpr>h  s&   øé € Ð!dÑUcÈT (§,¡,©{¸4ÀÓ/G×"HÐ"HÓUcùs   ƒ%(c              “   óV  <"  € V P                   ;_uu_4       GR j  x€L
  V P                  f    R R R 4      GR j  x€L
  R # S! V P                  P                  RV P                  4      G R j  x€L
 uuR R R 4      GR j  x€L
  #  Lg LJ L L  + GR j  x€L 
 '       g   i     R # ; i5i)NrÄ   )Ú	_rpc_lockr¬   Ú
list_toolsr9   )Úserverr
  s   &€r   ÚrelistÚ#_live_tools_changed.<locals>.relistk  sn   øé € Ø×#×#×#Ó#Ø�~‰~Ò%Ø÷ $×#Ñ#ñ -¨V¯^©^×-FÑ-FÈÐQW×Q\ÑQ\Ó]×]÷ $×#Ö#ñ ^÷ $×#×#Ó#üsw   ƒB)œB�B) B°B)»B¼B)Á+BÁ-BÁ.BÁ1B)Á>B
Á?B)ÂB)ÂBÂ
B)ÂB&	ÂBÂ
B&	ÂB&	Â 	B)c               “   ó˜  <"  € S U u. uF  p \         P                  ! S! V 4      4      NK!  	  pp  V'       d%   \         P                  ! V\        R 7      G Rj  x€L
  V F  pVP	                  4        K  	  . p\        SV4       Fœ  w  rVP                  4       ;'       d    VP                  4       '       * pV'       d   VP                  4       MRpV'       d'   Vf#   VP                  WP                  4       34       Kz  \        P                  RV P                  VR7       Kž  	  V# u up i  LÒ  T F  pTP	                  4        K  	  i ; i5i)©ÚtimeoutNz;Editor MCP server %r: tools/list for the drift check failed©Úexc_info)r  Úensure_futureÚwaitÚ_RELIST_TIMEOUTÚcancelÚzipÚdoneÚ	cancelledÚ	exceptionÚappendrû   rÎ   rÏ   r9   )r  ÚtasksÚtaskÚansweredÚsettledÚerrorr±   r  s         €€r   Ú
relist_allÚ'_live_tools_changed.<locals>.relist_allq  s   øé € áEIÓJÁT¸6”×&Ò&¡v¨f£~Ö6ÁTˆÐJð	ßÜ—l’l 5´/ÔB×BÐBã�Ø—‘–ñ àˆÜ  eÖ,‰LˆFØ—i‘i“k×:Ð:¨$¯.©.Ó*:Ô&:ˆGß(/�D—N‘NÔ$°TˆEß˜5š=Ø—‘ ¯©«Ð 7Ö8ä—‘Ð\Ð^d×^iÑ^iØ(-ð ö /ñ -ð ˆùò! Kñ Cøã�Ø—‘–ò üsL   ƒE
ˆ%D%­E
°'D, ÁD*ÁD, ÁAE
ÂE
Â=E
ÃAE
Ä*D, Ä,EÅE
r  z#Editor MCP drift check of %s failedTr  Fc              3   óv   <"  € T F.  w  rVR J;'       d    S! V4      S! VP                   4      8g  x € K0  	  R # 5ir   )Ú_tools)r+   r  rÄ   r  s   &  €r   r-   r  Š  s7   øé € ÐfÑ]eÉMÈFˆu˜DÐ ×GÐG¡T¨%£[±D¸¿¹Ó4GÑ%GÔGÓ]eùs   ƒ9•$9)rÄ   r	  rª   r
  r§   r«   r©   rr   Ú_run_on_mcp_loopr   ÚRuntimeErrorÚTimeoutErrorÚInterruptedErrorrÎ   rÏ   r¤   )rd   rA   r	  r  r,  r)  r
  r©   r§   r  r±   r  s   f&    @@@@@@r   Ú_live_tools_changedr4  ]  sÕ   þ€ õ $ß<Ý0òGö "eÐUZ×UaÑUaÔUcÔ!dó #Ñ!d�vØ÷ ˆFÑ!dñ #€Dõ^öð&à ×1Ñ1°*ÄoÐXYÕFYÐ1ÓZˆ÷ ‹3ÔfÑ]eÓf�3Œ3ÐfŠ3Ðfˆ3ÔfÑ]eÓfÓfÐfùòE#øô> œ,Ô(8Ð9ô Ü�‰Ð<¸eÈdˆÔSÚðús   ½B7ÁB7ÁB< Â<.C.Ã-C.c              ƒ  óÌ   "  € \        V RR4      '       g   R#  \        W4      G Rj  x€L
  R#  L  \         d'    \        P	                  RTP
                  RR7        R# i ; i5i)a£  The drain, once the FIFO head is authorized and before it is claimed (claim gate and mutation
lock held, nothing executing), re-checks the editor schemas; a drifted manifest is re-frozen through the
``editor_mcp`` writer path, so the turn runs on it instead of failing ``acp_mcp_schema_changed``.
Best-effort: the FIFO must not pause on it, so a failed re-check only logs and the turn then
reports real drift as before.rÜ   NzNEditor MCP re-check of session %s failed; the turn runs on its frozen manifestTr  )rš   Ú	_refreezeÚ	ExceptionrÎ   rÏ   ræ   )rZ   rè   r¡   s   &&&r   Úrefreeze_editor_mcpr8  �  sX   é € ô �9Ð1°4×8Ò8Ùð6Ü˜	Ó'×'Ô'øÜô 6Ü�‰ÐgØ—~‘~°ð 	÷ 	6ð6üs1   ‚A$™0 §.¨0 ¬A$®0 °-A!ÁA$Á A!Á!A$c              ƒ   ó6  a a	a
a"  € ^ RI Hp ^ RIHp \        P
                  ! VS P                  VP                  4      G Rj  x€L
 pV! VR,          4      o
S
P                  '       g   R# \        P                  ! S
P                  4      o	S P                  P                  S	R,          4      oSf   R# V V	V
V3R lp\        P
                  ! V4      G Rj  x€L
 w  rgpV'       d   VS	R,          8X  d   V'       g   R# \        S VS4      G Rj  x€L
  R#  LÐ L@ L
5i)r   rí   rï   NrÑ   rd   c            	      ó  <€ \        SS4      p \        SSR ,          SV SP                  RR7      ;_uu_ 4       w  r\        V4      \        V 4      8H  pYT;'       d    \	        SR ,          V 4      3uuRRR4       #   + '       g   i     R# ; i)rd   TrË   N)ro   rÅ   rz   r5   r4  )rA   rÌ   rÁ   ÚcompleterZ   rm   rÑ   r   s       €€€€r   ÚprobeÚ_refreeze.<locals>.probe©  sr   ø€ Ü˜d GÓ,ˆÜ�y $ w¥-°¸%ÀÇÁÐUY×ZÕZÑ^rÐ_fÜ˜9“~¬¨U«Ñ3ˆHà h×&\Ð&\Ô3FÀtÈGÅ}ÐV[Ó3\Ð\÷ [×Z×ZÓZús   ¸8A;Á;B	rÌ   )rä   rî   rñ   rð   r  r  rò   ræ   rÍ   r
   rL   rÜ   r7   Ú_commit_refreeze)rZ   rè   rî   rð   r   r<  rÌ   r;  Údriftedrm   rÑ   r   s   f&       @@@r   r6  r6  œ  sÛ   ûé € Ý5Ý0ä×%Ò% m°Y·\±\À3Ç>Á>ÓR×R€GÙ˜G HÕ-Ó.€FØ×!×!Ð!ÙÜ�:Š:�f×,Ñ,Ó-€DØ×)Ñ)×-Ñ-¨d°7­mÓ<€GØ‚Ù÷]ð ]ô (/×'8Ò'8¸Ó'?×!?Ñ€G�wç˜ 4¨	¥?Ô2¿7ÙÜ
˜9 c¨7Ó
3×3Ò3ñ' Sñ "@ñ 4ùsB   †<DÁDÁ$DÁ(A,DÃDÃ$DÃ:DÄDÄDÄDÄDc              ƒ  óú  "  € ^ RI Hp ^ RIHp \        P
                  ! W@P                  VP                  4      G Rj  x€L
 p\        P
                  ! V P                  P                  VP                  4      G Rj  x€L
 p\        RRV/4      w  rrRVP                  RR\        P                  ! 4       P                  ,           R	VR
,          RVR,          RRRV/pV! WW‚VR,          R7      G Rj  x€L
  R#  L· L| L
5i)zµThe ``editor_mcp`` change on the owning principal's behalf, through ``session.mutate``'s own
writer (the drain holds the session's locks, and a schema re-check needs no capability).)Úwrite_mutationrï   NrR   rJ   ræ   Ú
request_idzeditor-mcp-refreeze:Úexpected_revisionÚruntime_revisionÚexpected_generationÚruntime_generationrU   rV   Úprincipal_id)rG  )Úgateway.session_mutationsrA  rñ   rð   r  r  rò   ræ   Úget_sessionrW   ÚuuidÚuuid4Úhex)	rZ   rè   r   rA  rð   ÚownerÚrowrV   Úparamss	   &&&      r   r>  r>  ¶  sÓ   é € õ 9Ý0Ü×#Ò# M·<±<ÀÇÁÓP×P€EÜ×!Ò! )§,¡,×":Ñ":¸C¿N¹NÓK×
K€CÜ/°¸}ÈgÐ>VÓWÑ€GØ˜CŸN™N¨LÐ:PÔSW×S]ÒS]ÓS_×ScÑScÕ:cØ! 3Ð'9Õ#:Ð<QÐSVÐWkÕSlØ˜<¨°Gð=€Fñ ˜¨ÀuÈ^ÕG\Ô
]×]Ò]ñ QÙ
Kñ
 ^ùs4   ‚;C;½C5¾<C;Á:C7Á;A3C;Ã.C9Ã/C;Ã7C;Ã9C;c           	     ó²   € ^ RI HpHpHp VP                  e"   VP                  P                  V4      '       g   V# V! WRR7      p\        W5! WW74      R7      # )zœA durable config-secret reference names the policy identity, which the child's own editor
selection changed; the frozen secrets themselves are the parent's.)ÚPREFIXÚconfig_referenceÚrecover_config_secrets)Úskip)Úconfig_secret_ref© )Ú"gateway.session_policy_credentialsrQ  rR  rS  rU  rs   r   )rZ   ÚchildÚparentrÑ   rQ  rR  rS  Úsecretss   &&&&    r   Ú_child_secret_refr[  Ä  sU   € ÷ dÑcØ×ÑÒ'¨v×/GÑ/G×/RÑ/RÐSY×/ZÒ/ZØˆÙ$ Y¸RÔ@€GÜ�6Ð-=¸iÐPVÓ-`ÔaÐar   c              ƒ  óä  "  € ^ RI Hp ^ RIHp ^ RIHp  \        P                  ! W`P                  VP                  4      G Rj  x€L
 pT! TR,          4      pTf…   TP                  '       g   R# \        T R/ 4      P                  \        P                  ! TP                  4      R,          4      pTf   \        R4      h\        P                  ! \!        T4      4      pMTP"                  R	8w  d   \        R
4      hT! 4       G Rj  x€L
 p	RT	9  d   Y’3# R\$        P&                  ! 4       P(                  ,           p
T! TR,          TR,          T
4      p\        P                  ! \*        YY‚4      G Rj  x€L
 w  rÍ\-        YT\/        TRR7      4      p/ T	CRT
RTRTP                  RTP                  R\1        TP2                  4      RTP4                  /CT3#  EL’  \         d    Ru # i ; i Lå L{5i)aÔ  ``(prepared, servers)`` for a fork of an editor session: the child's selection under its OWN
scope, from the fork's list or else a copy of the parent's borrowed servers. The child never
shares the parent's scope or connections. ``(None, None)`` when no editor servers are involved.

Discovery starts every server, so *gate* (the branch's prepare-only fences: receipt, revision,
generation, idle) runs first; an exact retry's durable receipt comes back as ``prepared``.rí   )Úlocal_identityrï   NrÑ   rÜ   rd   rK   r  r!   rÿ   zbranch:rY   rG  Úask)Úedit_approval_policyrB  rX  Úparent_editor_mcp_jsonrÍ   rÂ   rU  )NN)rä   rî   Úhermes_state_keysr]  rñ   rð   r  r  rò   ræ   r   rÍ   rš   r7   r
   rL   r   rç   rJ  rK  rL  rÕ   r[  r   r3   rÂ   rU  )rZ   rè   r   Úgaterî   r]  rð   ÚsavedrY  ÚgatedrB  rX  rÑ   r`   s   &&&&          r   Úprepare_branch_editorre  Î  s·  é € õ 6Ý0Ý0ðÜ×'Ò'¨·|±|ÀSÇ^Á^ÓT×Tˆñ ˜E (�OÓ,€FØ‚Ø×%×%Ð%ØÐÜ˜)Ð%8¸"Ó=×AÑAÄ$Ç*Â*ÈV×McÑMcÓBdÐelÕBmÓnˆØŠ?Ü#Ð$DÓEÐEÜ—*’*œU 7›^Ó,‰Ø	�‰˜%Ô	ÜÐ 0Ó1Ð1Ù“&�L€EØ˜ÔØˆ~ÐØœTŸZšZ›\×-Ñ-Õ-€JÙ˜5 Õ.°°nÕ0EÀzÓR€EÜ×'Ò'Ô(9¸9ÈVÓ]×]�I€Fä˜y°¼ÀÐ^cÔ9dÓe€Fð;ˆeð ;�\ :¨w¸Ð?WÐY_×YoÑYoØ˜v×5Ñ5°zÄ4ÈÏÉÓCXØ ×!9Ñ!9ñ;à<CðDð Dò+ UøÜô ØÒðúñ ñ
 ^ùsa   ‚G0–.G ÁGÁG Á	$G0Á.BG0ÄG,ÄA+G0Å2G.Å3A#G0ÇG ÇG)Ç&G0Ç(G)Ç)G0Ç.G0c           	   #   ó¸  "  € VP                   '       g   R x € R # \        P                  ! VP                   4      p\        V R/ 4      P	                  VR,          4      pVf   \        R4      h\        WR,          V\        W#4      VP                  4      ;_uu_ 4       w  rEWBR,          8w  d   \        R4      hR x € R R R 4       R #   + '       g   i     R # ; i5i)NrÜ   rd   rK   rÌ   Úacp_mcp_schema_changed)	rÍ   r
   rL   rš   r7   r   rÅ   ro   rz   )rZ   rÑ   rm   r   rÌ   r`   s   &&    r   Úeditor_mcp_scoperh  ó  s©   é € à×!×!Ð!ÛÙÜ�:Š:�f×,Ñ,Ó-€DÜ�iÐ!4°bÓ9×=Ñ=¸dÀ7½mÓL€GØ‚ÜÐ @ÓAÐAÜ	�9 7�m¨W´mÀDÓ6RÐTZ×T^ÑT^×	_Ô	_ÑcoÐdkØ˜9•oÔ%ä#Ð$<Ó=Ð=Û÷	 
`×	_×	_Ò	_üs   ‚BCÂCÂ<
CÃC	Ã	C)rR   )5r“   r  Ú
contextlibr   Údataclassesr   r   rÝ   r
   Úloggingr‰   rJ  Úhermes_state_runtimer   Ú	getLoggerr4   rÎ   rM   rŠ   r™   r   r   r   rG   rP   rW   r\   rf   ro   ru   r…   r‡   r�   r¥   r­   r²   rÅ   rÈ   rÕ   rØ   r×   ré   rë   rô   rü   r  r4  r8  r6  r>  r[  re  rh  rV  r   r   Ú<module>rn     s.  ðñó Ý %Ý Û Û Û Û Û Û å 2à	×	Ò	˜8Ó	$€à€Ø�^Š^Ó€
Ø€òDò?òPò@YòVòdò
oòDòhò÷" ñ  ò0òRò
dòð ð!-Àó !-ó ð!-òH)òò<ò9ò6ò(!ò=òiòZò -gò`6ò4ò4^òbò"DðJ ñó òr   