+
    lHàj  ã                  óÂ   € R t ^ RIHt ^ RIHtHtHt ^ RIHt ]	]
]	]	3,          ,          tRRR/R R llltR	 R
 ltR R ltR R ltRRR/R R llltRtRtR R ltR# )uþ  Connection-ledger keys for tools.mcp_tool under a profile multiplexer.

Every ledger in ``tools.mcp_tool`` (``_servers``, connecting/error/cooldown maps, circuit
breaker, lazy configs, trust metadata) is keyed by a *connection key*: the bare server name
outside a multiplexer (single-profile processes are unchanged, byte for byte), and
``(owner_scope, name)`` under one. Two profiles that both configure ``github`` with their own
token are two connections; keying by name alone let the first profile's connection shadow the
second's forever â€” its ``register_mcp_servers`` saw the name as "already connected", adopted
nothing (different credentials) and left the profile silently tool-less (#106005, #91654).

A profile may still *adopt* another profile's live connection when the route and credentials
match (``mcp_tool_registration._same_server_route``); ``_server_tool_scopes[key]`` records every
scope that has done so, and ``_resolve_server_key`` finds that shared connection for a caller
whose own scope has none.
)Úannotations)ÚOptionalÚTupleÚUnion)Ú_coreNÚcurrentTc               ó(   € V ^8„  d   QhRRRRRRRR/# ©	é   ÚnameÚstrÚscopeúOptional[str]r   ÚboolÚreturnÚ	ServerKey© )Úformats   "Ú9/home/ubuntu/.hermes/hermes-agent/tools/mcp_tool_scope.pyÚ__annotate__r      s)   € ÷ 4ñ 4�cð 4 -ð 4ÀDð 4ÐT]ñ 4ó    c               óV   € Vf   V'       d   \         P                  ! 4       pVf   V # W3# )zŒConnection key for *name* owned by *scope* (the current registry scope when *current*).
``None`` scope (no multiplexer) keeps the bare name.)r   Ú_mcp_registry_scope)r   r   r   s   &&$r   Ú_server_keyr      s*   € ð ‚}ŸÜ×)Ò)Ó+ˆØ’=ˆ4Ð3 u mÐ3r   c               ó    € V ^8„  d   QhRRRR/# )r
   Úkeyr   r   r   r   )r   s   "r   r   r   "   s   € ÷ 5ñ 5�9ð 5 ñ 5r   c                óD   € \        V \        4      '       d
   V ^,          # T # )é   ©Ú
isinstanceÚtuple©r   s   &r   Ú	_key_namer"   "   s   € Ü ¤U×+Ò+ˆ3ˆq�6Ð4°Ð4r   c               ó    € V ^8„  d   QhRRRR/# )r
   r   r   r   r   r   )r   s   "r   r   r   &   s   € ÷ 6ñ 6�Ið 6 -ñ 6r   c                óD   € \        V \        4      '       d
   V ^ ,          # R# )zGOwning registry scope encoded in *key* (None for a bare, unscoped key).Nr   r!   s   &r   Ú
_key_scoper%   &   s   € ä ¤U×+Ò+ˆ3ˆq�6Ð5°Ð5r   c               ó$   € V ^8„  d   QhRRRRRR/# )r
   r   r   r   r   r   r   r   )r   s   "r   r   r   +   s&   € ÷ Wñ W˜yð W°ð WÀ4ñ Wr   c                ó€   € Vf   R# \        V 4      V8H  ;'       g$    V\        P                  P                  V R4      9   # )z›Whether the connection under *key* serves *scope*: owned by it or adopted into it.
Caller holds ``_core._lock`` or tolerates a racy read (status surfaces).Tr   )r%   r   Ú_server_tool_scopesÚget)r   r   s   &&r   Ú_key_visible_in_scoper*   +   s<   € ð ‚}ÙÜ�c‹?˜eÑ#×VÐV u´×0IÑ0I×0MÑ0MÈcÐSUÓ0VÑ'VÐVr   c               ó(   € V ^8„  d   QhRRRRRRRR/# r	   r   )r   s   "r   r   r   3   s)   € ÷ ñ ˜cð ¨-ð ÈDð Ð\eñ r   c               óv  € Vf   V'       d   \         P                  ! 4       p\        WRR7      pVe+   V\         P                  9   g   V\         P                  9   d   V# \         P
                  P                  4        F8  w  rEW9   g   K  \        V4      V 8X  g   K  V\         P                  9   g   K6  Vu # 	  V# )zþThe connection key a call to *name* from *scope* must use: the scope's own connection
(live, connecting or lazily registered) when it has one, else a shared connection it
adopted, else its own (not yet existing) key so bookkeeping lands under this scope.F)r   )r   r   r   Ú_serversÚ_lazy_server_configsr(   Úitemsr"   )r   r   r   Úownr   Úscopess   &&$   r   Ú_resolve_server_keyr2   3   s‰   € ð ‚}ŸÜ×)Ò)Ó+ˆÜ
�d¨5Ô
1€CØ‚}˜œuŸ~™~Ô-°¼×8RÑ8RÔ1RØˆ
Ü×0Ñ0×6Ñ6Ö8‰ˆØŽ?œy¨›~°Ö5¸#ÄÇÁÖ:OØŠJñ 9ð €Jr   c               ó    € V ^8„  d   QhRRRR/# )r
   r   r   r   ÚNoner   )r   s   "r   r   r   L   s   € ÷ .ñ . cð .¨dñ .r   c           
     ó�  a € ^ RI Hp \        P                  ;_uu_ 4        \         FZ  p\        \        V4      pV Uu. uF  p\        V\        4      '       g   K  VNK  	  up F  pVP                  V4      VS V3&   K  	  K\  	  \         Fh  p\        \        V4      pV Uu0 uF  p\        V\        4      '       g   K  VkK  	  ppVP                  V4       VP                  V 3R lV 4       4       Kj  	  . p\        P                  P                  4        UU	u. uF  w  rIV	e   K  \        V4      S 8X  g   K  VNK!  	  up	p FQ  pS \        P                  V&   T\        \        P                  P!                  V4      RR4      ;'       g    R,          pKS  	  \        P"                   Uu. uF  p\        V4      S 8X  g   K  VNK  	  up F!  pV\        P"                  V,          ,          pK#  	  \%        \        P                  4      \%        \        P"                  4      ,           FL  p\        V4      S 8X  g   K  \        P&                  P)                  V\%        4       4      P+                  S 4       KN  	  RRR4       ^ RIHp
 V
! S 4       VP1                  XS 4       R# u upi u upi u up	pi u upi   + '       g   i     LG; i)a  Move every bare-name connection under ``(scope, name)``. A single-profile process keys its
connections by bare name; once it starts multiplexing, the launch profile's lookups resolve
``(launch scope, name)``, so without this its live servers read as disconnected until a restart.)Úregistryc              3  ó,   <"  € T F	  pSV3x € K  	  R # 5i©Nr   )Ú.0Úkr   s   & €r   Ú	<genexpr>Ú-rekey_unscoped_connections.<locals>.<genexpr>Z   s   øé € Ð1©D q˜ �
«Dùs   ƒNÚ_registered_tool_names)Úrekey_unscopedr   )Útools.registryr6   r   Ú_lockÚ_KEYED_LEDGERSÚgetattrr   r   ÚpopÚ_KEYED_SETSÚdifference_updateÚupdateÚ_server_scope_keysr/   r%   r-   r)   Ú_lazy_server_tool_namesÚsetr(   Ú
setdefaultÚaddÚtools.mcp_tool_costsr>   Úmove_to_scope)r   r6   ÚattrÚledgerr:   r   ÚkeysÚbareÚ
tool_namesÚownerr>   s   f          r   Úrekey_unscoped_connectionsrT   L   s  ø€ õ (Ü	��‹ß"ˆDÜœU DÓ)ˆFÙ#)Ó@¡6˜a¬Z¸¼3×-?Ÿ˜¡6Ô@�Ø'-§z¡z°#£�˜˜s�|Ó$ó Añ #÷  ˆDÜœ5 $Ó'ˆDÙ#Ó:™t˜!¤z°!´S×'9—A�A™tˆDÐ:Ø×"Ñ" 4Ô(Ø�K‰KÔ1©DÓ1Ö1ñ	  ð ˆ
Ü&+×&>Ñ&>×&DÑ&DÔ&FÔsÑ&F™(˜!È%”AÔ\fÐghÓ\iÐmrÑ\r—A�AÑ&FÕsˆCØ,1ŒE×$Ñ$ SÑ)Øœ'¤%§.¡.×"4Ñ"4°SÓ"9Ð;SÐUYÓZ×`Ð`Ð^`Õ`ŠJñ tô  %×<Ò<ÓWÑ<˜!Ä
È1ÃÐQVÑ@V—A�AÑ<ÔWˆCØœ%×7Ñ7¸Õ<Õ<ŠJñ Xä”u—~‘~Ó&¬¬U×-JÑ-JÓ)K×KÐKˆCÜ˜#‹ %Ö'Ü×)Ñ)×4Ñ4°S¼#»%Ó@×DÑDÀUÖKñ L÷% 
õ* 4Ù�5ÔØ×Ñ˜: uÖ-ùò) Aùò ;ùó tùò X÷! 
�úsn    J5¾J 
ÁJ 
Á!AJ5Â"J%
Â?J%
ÃAJ5ÄJ*
Ä'J*
Ä9J*
Ä?AJ5ÆJ5Æ*J0ÇJ0ÇA/J5È;;J5Ê J5Ê5K	r8   )r-   rG   r(   Ú_server_connect_errorsr.   Ú_lazy_server_fingerprintsrH   Ú_server_connect_retry_afterÚ_server_connect_failuresÚ_server_error_countsÚ_server_breaker_opened_atÚ_server_errors_all_applicationÚ_server_trust_levelsÚ_tool_read_only_hintsÚ_server_cost_policies)Ú_server_connectingÚ_parallel_safe_servers)Ú__doc__Ú
__future__r   Útypingr   r   r   Útools.mcp_tool_commonr   r   r    r   r   r"   r%   r*   r2   rA   rD   rT   r   r   r   Ú<module>re      sp   ðñõ  #ç )Ñ )å 'à�%˜˜S˜•/Õ!€	ñ4È4÷ 4ð 4õ5õ6õ
WñÐSW÷ ð ð 6€ð ?€÷.r   