+
    lHàj5  ã                  óT  € ^ RI Ht ^ RIt^ RIt^ RIHt ^ RIHtHtH	t	H
t
Ht ]P                  ! ]4      tRtRt]],           t]! 0 Rm4      tRt]P*                  ! ]4      tRt]! RR7       ! R	 R
4      4       tR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R lt R# )é    )ÚannotationsN)Ú	dataclass)ÚAnyÚListÚOptionalÚSetÚTuplez^[a-z0-9][a-z0-9-]{0,31}$zF1-32 lowercase letters, digits or '-', starting with a letter or digitT)Úfrozenc                  óB   € ] tR t^t$ RtR]R&   RtR]R&   RtR]R&   RtR# )	ÚHostedTargetznA hosted connector target. ``alias`` names one account of that connector; ``to`` is the
new alias of a rename.ÚstrÚnameNúOptional[str]ÚaliasÚto© )	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__r   r   Ú__static_attributes__r   ó    Ú=/home/ubuntu/.hermes/hermes-agent/tools/connectors/targets.pyr   r      s"   ‡ ñð ƒIØ€Eˆ=ÓØ€Bˆ×r   r   c               ó$   € V ^8„  d   QhRRRRRR/# )é   Úkeyr   Úvaluer   Úreturnr   )Úformats   "r   Ú__annotate__r"      s&   € ÷ Rñ R�Cð R ð R°-ñ Rr   c                óf   € Ve   \         P                  V4      '       d   R # RV  RV: R\         R2# )NÚ'z' z" is not a valid account name: use Ú.)Ú	_ALIAS_REÚ	fullmatchÚ_ALIAS_FORMAT)r   r   s   &&r   Ú
_bad_aliasr)      s6   € Ø‚}œ	×+Ñ+¨E×2Ò2ÙØˆsˆe�2�e‘YÐ@ÄÀÈqÐQÐQr   c               ó    € V ^8„  d   QhRRRR/# )r   Úrawr   r    z3tuple[list[HostedTarget], list[str], Optional[str]]r   )r!   s   "r   r"   r"   %   s   € ÷ $ñ $˜3ð $Ð#Vñ $r   c                óÂ  aa	€ V f   . . R 3# \        V \        \        34      '       d   V .p \        V \        4      '       g   . . R3# . p. pV  EF  pR ;op\        V\        4      '       Ed%   \	        \        V4      \        ,
          4      pV'       d   . . RRP                  V4       R23u # \        VP                  R4      ;'       g    R4      P                  4       P                  4       o	\        VP                  RR4      4      pV'       d   R	V9   g   R
V9   d   . . R3u # VP                  R	4      e!   \        VR	,          4      P                  4       MR oVP                  R
4      e!   \        VR
,          4      P                  4       MR pM4\        T;'       g    R4      P                  4       P                  4       Ruo	pS	'       g   . . R3u # V'       d   S	V9  d   VP                  S	4       EK©  \        S	SV4      p\        ;QJ d     VV	3R lV 4       F  '       d   K   RM	  RM! VV	3R lV 4       4      '       g   EKû  VP                  V4       EK  	  WR 3# )Nz<'connectors' must be a list of names or {name, mcp} objects.zunknown target field(s) ú, z›: a target is {"name": "<slug>"} or {"name": "<server>", "mcp": true}. Transport, URLs and credentials come from the catalog manifest, never from the call.r   Ú ÚmcpFr   r   zM'alias' and 'to' name hosted connector accounts; an MCP target takes neither.z&every target needs a non-empty 'name'.c              3  ó\   <"  € T F!  qP                   VP                  3SS38g  x € K#  	  R # 5i©N)r   r   )Ú.0Útr   r   s   & €€r   Ú	<genexpr>Ú$normalize_targets.<locals>.<genexpr>G   s%   øé € ÐC¹7°a—‘˜Ÿ™Ð  T¨5 MÖ1»7ùs   ƒ),T)Ú
isinstancer   ÚdictÚlistÚsortedÚsetÚ_TARGET_FIELDSÚjoinÚgetÚstripÚlowerÚboolÚappendr   Úall)
r+   Úmanagedr/   Úitemr   ÚunknownÚis_mcpÚtargetr   r   s
   &       @@r   Únormalize_targetsrH   %   sü  ù€ Ø
‚{Ø�2�tˆ|ÐÜ�#œœT�{×#Ò#ØˆeˆÜ�cœ4× Ò Ø�2ÐUÐUÐUØ"$€GØ€CÜˆØÐˆ�Ü�dœD×!Ó!ÜœS ›Y¬Õ7Ó8ˆGßØ˜2Ø.¨t¯y©y¸Ó/AÐ.Bð C`ð `ðò ô
 �t—x‘x Ó'×-Ð-¨2Ó.×4Ñ4Ó6×<Ñ<Ó>ˆDÜ˜$Ÿ(™( 5¨%Ó0Ó1ˆFß˜7 dœ?¨d°d¬lØ˜2ÐnÐnÒnØ26·(±(¸7Ó2CÒ2O”C˜˜W�Ó&×,Ñ,Ô.ÐUYˆEØ,0¯H©H°T«NÒ,F”�T˜$•Z“×&Ñ&Ô(ÈD‰Bä˜tŸz˜z r›?×0Ñ0Ó2×8Ñ8Ó:¸EˆLˆD�&ßØ�rÐCÐCÒCßØ˜3ŒØ—
‘
˜4Ô ÚÜ˜d E¨2Ó.ˆß‹3ÕC¹7ÓC�3�3Š3ÕC¹7ÓC×CÕCØ�N‰N˜6×"ñ5 ð6 ˜ÐÐr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   Úactionr   rC   úlist[HostedTarget]r/   z	list[str]r    r   r   )r!   s   "r   r"   r"   L   s*   € ÷ /ñ /˜Cð /Ð*<ð /À9ð /ÐQ^ñ /r   c                óz  € V \         9  d0   R RP                  \         4       RRP                  \        4       R2# V \        9   d7   V'       d    RV  RRP                  R V 4       4       R2# V'       g   RV  R2# M6V'       d/   RV  R	RP                  V4       R
RP                  \        4       R2# \        W4      # )zaction must be one of r-   z. zÉ apply to local MCP servers (targets {"name": ..., "mcp": true}); the rest apply to managed connectors. Disconnecting an account is done by the user in the Nous Portal dashboard, not through this tool.r$   zR' is an MCP action: every target must carry "mcp": true (got managed connector(s) c              3  ó8   "  € T F  qP                   x € K  	  R # 5ir1   ©r   ©r2   r3   s   & r   r4   Ú"validate_action.<locals>.<genexpr>Y   s   é € Ð6OÁwÀ!·v¶vÃwùó   ‚z7). Managed connectors use connect / reconnect / status.zX' requires 'connectors': the MCP server name(s), e.g. [{"name": "linear", "mcp": true}].z.' is a managed-connector action; MCP targets (z) use r%   )ÚALL_ACTIONSr<   ÚMCP_ACTIONSÚ_validate_accounts)rJ   rC   r/   s   &&&r   Úvalidate_actionrU   L   sá   € Ø”[Ô à$ T§Y¡Y¬{Ó%;Ð$<¸BØ�y‰yœÓ%Ð&ð '!ð!ð	
ð ”Ôßà�F�8ð -Ø-1¯Y©YÑ6OÁwÓ6OÓ-OÐ,Pð Q0ð0ð÷
 à�F�8ð ;ð ;ðð ÷
 
à�ˆxÐEÀdÇiÁiÐPSÃnÐEUÐU[Ø�y‰yœÓ%Ð& að)ð	
ô ˜fÓ.Ð.r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rJ   r   rC   rK   r    r   r   )r!   s   "r   r"   r"   i   s'   € ÷ Sñ S˜sð SÐ-?ð SÀMñ Sr   c                ó¶  a€ V R 8w  d=   \         ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   R# V R8X  d=   \         ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   R# V R 8X  db   \        V4      ^8w  g3   V^ ,          P                  '       d   V^ ,          P                  '       g   R# \	        R	V^ ,          P                  4      # \         ;QJ d    R
 V 4       F  '       g   K   RM	  RM! R
 V 4       4      '       d   \        V4      ^8”  d   R# V R8X  d   R# \        V3R lV 4       R4      # )Úrenamec              3  ó8   "  € T F  qP                   x € K  	  R # 5ir1   )r   rO   s   & r   r4   Ú%_validate_accounts.<locals>.<genexpr>j   s   é € Ð!8±¨1§$¦$³ùrQ   TFzE'to' is the new name of an account and applies to action rename only.Údisplayc              3  ó8   "  € T F  qP                   x € K  	  R # 5ir1   ©r   rO   s   & r   r4   rZ   l   s   é € Ð"<±G¨q§7¦7³GùrQ   zYdisplay takes connector slugs to suggest (e.g. ["gmail"]); accounts are named on connect.z—rename takes exactly one target {"name": "<slug>", "alias": "<current name>", "to": "<new name>"}. Use action status to list each connector's accounts.r   c              3  ó8   "  € T F  qP                   x € K  	  R # 5ir1   r]   rO   s   & r   r4   rZ   t   s   é € Ð
$™G�q�7Ž7›GùrQ   zYa call with an 'alias' takes that one target only; name other accounts in separate calls.Ú	reconnectNc              3  óh   <"  € T F'  p\        R VP                  4      ;o'       g   K#  Sx € K)  	  R# 5i)r   N)r)   r   )r2   r3   Úes   & €r   r4   rZ   y   s(   øé € ÐK™G�q¬Z¸ÀÇÁÓ-IÐ(I¨Ó(I—’›Gùs   ƒ 2¨
2)ÚanyÚlenr   r   r)   Únext)rJ   rC   ra   s   &&@r   rT   rT   i   sò   ø€ Ø�ÔŸc›cÑ!8±Ó!8ŸcŸcšcÑ!8±Ó!8×8Ò8ÙVØ�ÔŸs›sÑ"<±GÓ"<ŸsŸsšsÑ"<±GÓ"<×<Ò<ÙlØ�ÔÜˆw‹<˜1Ô G¨A¥J×$4×$4Ð$4¸GÀA½J¿M¿M¸Mñdô ˜$ ¨¥
§¡Ó.Ð.ß
ƒsÑ
$™GÓ
$‡s‡s‚sÑ
$™GÓ
$×$Ò$¬¨W«¸Ô)9ÙjØ�ÔáÜÔK™GÓKÈTÓRÐRr   c               ó   € V ^8„  d   QhRR/# )r   r    zset[str]r   )r!   s   "r   r"   r"   |   s   € ÷ ñ �xñ r   c                 óÊ   €  ^ RI Hp  V ! 4        Uu0 uF  qP                  kK  	  up# u upi   \         d+   p\        P                  RT4       \        4       u Rp?# Rp?ii ; i)r   )Úlist_catalogz,MCP catalog for the routing check failed: %sN)Úhermes_cli.mcp_catalogrg   r   Ú	ExceptionÚloggerÚdebugr:   )rg   ra   Úexcs      r   Úcatalog_namesrm   |   sL   € ðÝ7á ,¤Ó/¡˜1—”¡Ñ/Ð/ùÒ/øÜô Ü�‰ÐCÀSÔIÜ‹u�ûðús&   ‚- ‘(¥- ¨- ­A"¸AÁA"ÁA"c               ó   € V ^8„  d   QhRR/# )r   r    zOptional[set[str]]r   )r!   s   "r   r"   r"   †   s   € ÷ ñ Ð(ñ r   c            	     ój  €  ^ RI Hp  ^ RIHp V! 4       '       g   R# V ! 4       P	                  4        Uu0 uFD  p\        V\        4      '       g   K  \        VP                  RR4      4      P                  4       kKF  	  up# u upi   \         d"   p\        P                  RT4        Rp?R# Rp?ii ; i)r   )ÚConnectorClient)Úconnectors_availableNÚ	connectorr.   z/connector list for the routing check failed: %s)Útools.connectors.gateway.clientrp   Útools.connectors.gateway.configrq   Úlist_connectorsr6   r7   r   r=   r?   ri   rj   rk   )rp   rq   rD   rl   s       r   Úhosted_namesrv   †   s•   € ð
ÝCÝHá#×%Ò%Ùá+Ó-×=Ñ=Ô?ó[Ù?�DÄ:ÈdÔTX×CYô 7”�D—H‘H˜[¨"Ó-Ó.×4Ñ4Ö6Ù?ñ[ð 	[ùò [øäô Ü�‰ÐFÈÔLÝûðús3   ‚B �B ´BÁ-BÁ>B ÂB ÂB2ÂB-Â-B2c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r    r   )r!   s   "r   r"   r"   ”   s   € ÷ ñ  Cð ¨Cñ r   c                ó   € V  R V  R2# )z~ is a local MCP server, not a hosted connector account. Call manage_connections with action install and connectors [{"name": "z", "mcp": true}].r   rN   s   &r   Úmisrouted_to_hosted_errorry   ”   s   € àˆ&ð à˜Ð4ð	6ðr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rJ   r   r   r    r   )r!   s   "r   r"   r"   œ   s!   € ÷ ñ  3ð ¨cð °cñ r   c                ó   € V R V  RV R2# )z< is a hosted connector account, not a local MCP server, so 'zO' does not apply. Call manage_connections with action connect and connectors ["z"].r   )rJ   r   s   &&r   Úmisrouted_to_mcp_errorr|   œ   s)   € àˆ&ÐLÈVÈHð UYØY]ÐX^Ð^bð	dðr   )r[   ÚstatusÚconnectr_   rX   )ÚinstallÚenableÚ	authorize>   r   r/   r   r   )!Ú
__future__r   ÚloggingÚreÚdataclassesr   Útypingr   r   r   r   r	   Ú	getLoggerr   rj   ÚCONNECTOR_ACTIONSrS   rR   Ú	frozensetr;   ÚALIAS_PATTERNÚcompiler&   r(   r   r)   rH   rU   rT   rm   rv   ry   r|   r   r   r   Ú<module>rŒ      s¨   ðÝ "ã Û 	Ý !ß 2Õ 2à	×	Ò	˜8Ó	$€àKÐ Ø0€Ø +Õ-€áÒ9Ó:€à,€Ø�JŠJ�}Ó%€	ØX€ñ �$Ô÷ð ó ðõRõ$õN/õ:Sõ&õõ÷r   