+
    jHàjþ  ã                  óœ   € R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHt R t	R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# )a  ``hermes plugins remove``: tree + install-metadata removal kept consistent, config bookkeeping, and the
dashboard/TUI remove path.

Sibling of :mod:`hermes_cli.plugins_cmd` (the facade re-exports the names other modules use and is
imported late here, never at module level).
)ÚannotationsN)ÚPath)ÚAnyc                 ó   € ^ RI Hp  V # )z`The facade, read at call time: tests patch ``plugins_cmd.<name>`` and sibling calls must see it.©Úplugins_cmd)Ú
hermes_clir   r   s    ÚB/home/ubuntu/.hermes/hermes-agent/hermes_cli/plugins_cmd_remove.pyÚ_pcr
      s   € å&ØÐó    zplugin-pending-deletec               ó   € V ^8„  d   QhRR/# )é   Úreturnr   © )Úformats   "r	   Ú__annotate__r      s   € ÷ =ñ =˜dñ =r   c                 ó@   € ^ RI Hp  V ! 4       R,          \        ,          # )z]``<HERMES_HOME>/cache/plugin-pending-delete``: trees a running process still held at removal.©Úget_hermes_homeÚcache)Úhermes_constantsr   Ú_PENDING_DELETE_DIRr   s    r	   Ú_pending_delete_rootr      s   € å0ÙÓ˜wÕ&Ô)<Õ<Ð<r   c               ó   € V ^8„  d   QhRR/# )r   r   ÚNoner   )r   s   "r	   r   r      s   € ÷ =ñ = dñ =r   c                 óÜ  € \        4       p V P                  4       '       g   R# V P                  4        Fµ  pVP                  R8X  d‡   VP	                  4       '       dq   \        VP                  RR7      P                  4       4      p\        4       P                  VRR7       VP                  4       '       g   VP                  RR7       K˜  Kš  \        4       P                  VRR7       K·  	  R# )z¶Delete what an earlier remove parked because another process held it; cheap when empty.
A ``<name>.path`` note names a stripped tree that could not even be moved out of ``plugins/``.Nú.pathz	utf-8-sig©ÚencodingT©Úignore_errors©Ú
missing_ok)r   Úis_dirÚiterdirÚsuffixÚis_filer   Ú	read_textÚstripr
   Úrmtree_readonlyÚexistsÚunlink)ÚrootÚentryÚhelds      r	   Úsweep_pending_plugin_deletesr/      s¨   € ô  Ó!€DØ�;‰;�=Š=ÙØ—‘–ˆØ�<‰<˜7Ô" u§}¡}§¢Ü˜Ÿ™°˜Ó=×CÑCÓEÓFˆDÜ‹E×!Ñ! $°dÐ!Ô;Ø—;‘;—=’=Ø—‘¨�Ö-ñ !ô ‹E×!Ñ! %°tÐ!Ö<ó  r   c               ó    € V ^8„  d   QhRRRR/# )r   Útreer   r   r   r   )r   s   "r	   r   r   /   s   € ÷ `ñ `˜ð ` ñ `r   c                ó|  €  \        4       P                  V 4       R#   \         d0    \        P                  R8w  g   T P                  4       '       g   h  Mi ; i\        4       pTP                  RRR7       \        \        P                  ! T P                   R2TR7      4      R,          p \        P                  ! Y4       R#   \         dl    R F  pY,          P                  RR7       K  	  YP                  P                   RT P                   R	2,          P                  \!        T 4      R
R7        R# i ; i)a]  Delete *tree*. On Windows a running gateway / plugin host that loaded the plugin keeps its
native modules mapped and its open files locked (WinError 5/32), and deleting stops at the first
one. The rest is then moved out of ``plugins/`` into the pending-delete area, so nothing loadable
stays behind, and the sweep at the next start finishes the job.NÚntT)ÚparentsÚexist_okÚ-©ÚprefixÚdirÚpluginr!   r   zutf-8r   )zplugin.yamlz
plugin.ymlzplugin.jsonz__init__.py)r
   r)   ÚPermissionErrorÚosÚnamer*   r   Úmkdirr   ÚtempfileÚmkdtempÚreplaceÚOSErrorr+   ÚparentÚ
write_textÚstr)r1   r,   Úparkedr=   s   &   r	   Ú_discard_treerG   /   s  € ð
Ü‹×Ñ˜dÔ#ÙøÜô Ü�7‰7�dŒ? $§+¡+§-¢-Øñ #0ðúô  Ó!€DØ‡J�J�t d€JÔ+Ü”(×"Ò"¨T¯Y©Y¨K°q¨/¸tÔDÓEÈÕP€Fð`Ü
�
Š
�4Ö øÜô `ó PˆDØ�[× Ñ ¨DÐ Ö1ñ Pà	—;‘;×#Ñ#Ð$ A d§i¡i [°Ð6Õ	6×BÑBÄ3ÀtÃ9ÐW^ÐB×_ð`ús(   ‚ �5AÁAÁAÂ-C ÃA2D;Ä:D;c               ó    € V ^8„  d   QhRRRR/# )r   Útargetr   r   r   r   )r   s   "r	   r   r   G   s   € ÷ ñ  ð ¨ñ r   c           	     ój  € V P                   \        4       P                  4       9  d   \        V 4       R# \	        \
        P                  ! RV P                    R2V P                  R7      4      pVR,          p \        P                  ! W4        \        4       P                  T P                   R
 4       \        T4       R#   \         df    \        4       P                  TRR7       \        P                   R8w  d   h \        4       P                  T P                   R	 4       \        T 4        R# i ; i  \         dt     \        P                  ! Y 4       M>  \         d1   p\        4       P                  RT P                    RT R24      ThRp?ii ; i\        4       P                  TRR7       h i ; i)zARemove one plugin and its metadata without splitting their state.NÚ.z.remove-r7   r:   Tr   r3   c                ó   € R # ©Nr   ©Ú_currents   &r	   Ú<lambda>Ú%_remove_plugin_core.<locals>.<lambda>V   ó   € Á4r   c                ó   € R # rM   r   rN   s   &r	   rP   rQ   Z   rR   r   z#Plugin metadata update failed and 'z@' could not be restored automatically; recovery copy remains at )r=   r
   Ú_read_install_metadatarG   r   r?   r@   rC   r<   rA   r;   r)   Ú_update_install_recordÚ	ExceptionrB   ÚPluginOperationError)rI   ÚstagingÚbackupÚrestore_excs   &   r	   Ú_remove_plugin_corer[   G   si  € à‡{�{œ#›%×6Ñ6Ó8Ô8Ü�fÔÙÜ”8×#Ò#¨Q¨v¯{©{¨m¸8Ð+DÈ&Ï-É-ÔXÓY€GØ�xÕ€Fð
Ü
�
Š
�6Ô"ðÜ‹×$Ñ$ V§[¡[Ñ2GÔHô �'Öøô+ ô Ü‹×Ñ˜g°TÐÔ:Ü�7‰7�dŒ?Øô 	‹×$Ñ$ V§[¡[Ñ2GÔHÜ�fÔÚðûô ô 	ð	Ü�JŠJ�vÕ&øÜô 	Ü“%×,Ñ,Ø5°f·k±k°]ð CDØDJÀ8È1ðNóð ðûð	úô
 	‹×Ñ˜g°TÐÔ:Øð	úsC   Á8C Â%D4 ÃA,D1Ä0D1Ä4F2Å EÅF2ÅFÅ"+FÆFÆ F2c               ó    € V ^8„  d   QhRRRR/# )r   r=   rE   r   r   r   )r   s   "r	   r   r   h   s   € ÷ ñ �Sð ˜Tñ r   c                ó
  € \        4       P                  4       p\        4       P                  4       p\        4       P                  WV4      p \	        W V4      pVP                  4        VP                  RV  RV 24       XP                  R4      '       d   VP                  R4       VP                  4        R#   \
        \        4       P                  3 d+   p\        4       P                  TRT  RT 24        Rp?L¥Rp?ii ; i)z#Remove an installed plugin by name.z+[red]Error:[/red] Could not remove plugin 'ú': Nu   [red]âœ—[/red] Plugin [bold]z[/bold] removed from Úcleared_memory_providerzq[yellow]memory.provider pointed at this plugin and was reset; run `hermes memory setup` to pick another.[/yellow])
r
   Ú_consoleÚ_plugins_dirÚ_require_installed_pluginÚ_remove_user_pluginrB   rW   Ú_failÚprintÚget)r=   ÚconsoleÚplugins_dirrI   ÚresultÚexcs   &     r	   Ú
cmd_removerk   h   sÝ   € ä‹e�n‰nÓ€GÜ“%×$Ñ$Ó&€KÜ‹U×,Ñ,¨TÀÓH€Fð[Ü$ [¸Ó?ˆð ‡M�M„OØ‡M�MÐ0°°Ð6KÈKÈ=ÐYÔZØ‡z�zÐ+×,Ò,Ø�‰ð Lô 	Mà‡M�M†Oøô ”S“U×/Ñ/Ð0ô [Ü‹�‰�GÐJÈ4È&ÐPSÐTWÐSXÐY×ZÑZûð[ús   ÁB9 Â9DÃ C=Ã=Dc               ó(   € V ^8„  d   QhRRRRRRRR/# )r   rh   r   r=   rE   rI   r   údict[str, Any]r   )r   s   "r	   r   r   y   s.   € ÷ Nñ N Tð N°ð N¸dð NÀ~ñ Nr   c                ót  a€ WP                  R4      ,          pVP                  4       '       d;   VP                  4        RRRV/\        4       P	                  VP
                  04      C# \        V3R l\        4       P                  4        4       R4      pV'       d
   V^,          MSP
                  p\        4       P                  V4      SP
                  0,          p^ RI	H
pHp V! S4      p	\        4       P                  VRR	7       \        S4       V! V	4       RRRV/\        4       P	                  V4      C# )
uÅ  Shared ``remove`` tail for the CLI, the dashboard and the ``plugins.manage`` RPC.

*target* is the resolved directory; when ``plugins_dir/name`` itself is a symlink only the link
goes â€” the tree it points at may be another installed plugin (a dev alias to a sibling checkout),
and following it deleted that plugin plus its install metadata while the alias stayed dangling.
Config bookkeeping (aliases, toolset) is gathered before the tree disappears.
Ú/ÚokTr=   c              3  ól   <"  € T F)  p\        \        V^,          4      4      S8X  g   K%  Vx € K+  	  R# 5i)é   N)r   rE   )Ú.0ÚerI   s   & €r	   Ú	<genexpr>Ú&_remove_user_plugin.<locals>.<genexpr>…   s)   øé € ÐXÑ:˜¼dÄ3ÀqÈÅtÃ9»oÐQWÑ>W—!’!Ó:ùs   ƒ"4ª
4N)Úforget_plugin_grantsÚ
plugin_keyF)Úenable)r(   Ú
is_symlinkr+   r
   Ú_forget_plugin_configr=   ÚnextÚ_discover_all_pluginsÚ_plugin_aliasesÚhermes_cli.plugin_oauthrw   rx   Ú_toggle_plugin_toolsetr[   )
rh   r=   rI   Úlinkr-   ÚkeyÚaliasesrw   rx   Ú	grant_keys
   &&f       r	   rc   rc   y   sñ   ø€ ð Ÿ™ C›Õ(€DØ‡�×ÒØ�‰ŒØ�d˜F DÐU¬C«E×,GÑ,GÈÏÉÈÓ,TÐUÐUÜÔXœS›U×8Ñ8Ô:ÓXÐZ^Ó_€Eßˆ%�Ž( §¡€CÜ‹e×#Ñ# CÓ(¨F¯K©K¨=Õ8€GßHÙ˜6Ó"€IÜƒE× Ñ  ¨UÐ Ô3Ü˜ÔÙ˜Ô#Ø�$˜ ÐM¬«×(CÑ(CÀGÓ(LÐMÐMr   c               ó    € V ^8„  d   QhRRRR/# )r   r=   rE   r   rm   r   )r   s   "r	   r   r   �   s   € ÷ Rñ R sð R¨~ñ Rr   c                óø  a € \        4       P                  4       p\        ;QJ d5    V 3R l\        4       P                  4        4       F  '       g   K   RM*	  RM&! V 3R l\        4       P                  4        4       4      '       d   RRRR/# \        4       P	                  S 4      pVf   RRRRS  R	V R
2/#  \        VS V4      #   \        \        4       P                  3 d   pRRRRS  RT 2/u Rp?# Rp?ii ; i)z7Delete a plugin tree under ``~/.hermes/plugins/`` only.c              3  óP   <"  € T F  w  rr4rVVS8H  ;'       d    VR 8H  x € K  	  R# 5i)ÚbundledNr   )rs   ÚnÚ_verÚ_dÚsrcÚ_pathÚ_keyr=   s   &      €r	   ru   Ú/dashboard_remove_user_plugin.<locals>.<genexpr>“   s.   øé € Ð
mÑOlÑ.K¨a°rÀˆ1�‰9×)Ð)˜ 	Ñ)Ô)ÓOlùs   ƒ#&TFrp   Úerrorz5Bundled plugins cannot be removed from the dashboard.NzPlugin 'z' was not found under rK   zCould not remove plugin 'r^   )r
   ra   Úanyr}   Ú_user_installed_plugin_dirrc   rB   rW   )r=   rh   rI   rj   s   f   r	   Údashboard_remove_user_pluginr“   �   sâ   ø€ ä“%×$Ñ$Ó&€Kß
ƒsÔ
mÌsËu×OjÑOjÔOlÓ
m‡s‡s‚sÔ
mÌsËu×OjÑOjÔOlÓ
m×mÒmØ�e˜WÐ&]Ð^Ð^Ü‹U×-Ñ-¨dÓ3€FØ‚~Ø�e˜W¨°°Ð6LÈ[ÈMÐYZÐ&[Ð\Ð\ðRÜ" ;°°fÓ=Ð=øÜ”S“U×/Ñ/Ð0ô RØ�e˜WÐ(AÀ$ÀÀsÈ3È%Ð&PÐQÕQûðRús   Â7C ÃC9Ã#C4Ã.C9Ã4C9)Ú__doc__Ú
__future__r   r<   r?   Úpathlibr   Útypingr   r
   r   r   r/   rG   r[   rk   rc   r“   r   r   r	   Ú<module>r˜      sO   ðñõ #ã 	Û Ý Ý òð .Ð õ=õ=õ `õ0õBõ"N÷.Rr   