+
    „WÝjK  ã                  ó˜   € R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt R t	R R lt
RR R	 lltR
 R ltRR/R R lltRR R lltR R ltR# )a*  Capability consent (#64228): declared-vs-granted reads, the consent screen, ``hermes plugins
capabilities`` and the legacy ``allow_tool_override`` grant.

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).
)Úannotations)ÚPath)ÚOptional)Ú_child_dictc                 ó   € ^ 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    ÚWC:\Users\johnn\AppData\Local\hermes\hermes-agent\hermes_cli\plugins_cmd_capabilities.pyÚ_pcr      s   € å&ØÐó    c               ó(   € V ^8„  d   QhRRRRRRRR/# )é   Ú	plugin_idÚstrÚkeyÚvalueÚboolÚreturnÚNone© )Úformats   "r
   Ú__annotate__r      s(   € ÷ ñ  cð °ð ¸Dð ÀTñ r   c                óŽ   € ^ RI HpHp V! 4       p\        \        \        VR4      R4      V 4      p\	        V4      Wa&   V! V4       R# )zEWrite ``plugins.entries.<plugin_id>.<key> = value`` into config.yaml.)Úload_configÚsave_configÚpluginsÚentriesN)Úhermes_cli.configr   r   r   r   )r   r   r   r   r   ÚconfigÚentrys   &&&    r
   Ú_set_plugin_entry_flagr!      s:   € ç:Ù‹]€FÜœ¤K°¸	Ó$BÀIÓNÐPYÓZ€EÜ�e“€E�JÙ�Ör   c               ó$   € V ^8„  d   QhRRRRRR/# )r   ÚmanifestÚdictÚplugin_namer   r   Úlistr   )r   s   "r
   r   r       s'   € ÷ Zñ Z°4ð ZÀcð ZÐTXñ Zr   c                óR   € ^ RI Hp T! T ;'       g    / P                  R4      V4      # )zFExtract + normalize the ``capabilities:`` declaration from a manifest.)Úparse_declared_capabilitiesÚcapabilities)Úhermes_cli.plugin_capabilitiesr(   Úget)r#   r%   r(   s   && r
   Ú$_declared_capabilities_from_manifestr,       s#   € åJÙ&¨¯¨°B×';Ñ';¸NÓ'KÈ[ÓYÐYr   c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r   r&   r   )r   s   "r
   r   r   &   s   € ÷ `ñ `¨ð `°ñ `r   c                ó„  € \        4       P                  V 4      pVf   . # V^,          R8X  dJ   ^ RIHp V! 4        F6  pWP                  VP
                  39   g   K!  \        VP                  4      u # 	  . # V^,          '       g   . # \        \        4       P                  \        V^,          4      4      V^ ,          4      # )zFRead the declared capabilities for an installed/bundled plugin by key.Ú
entrypoint)Údiscover_entrypoint_manifests)r   Ú_find_plugin_entryÚhermes_cli.pluginsr0   r   Únamer&   r)   r,   Ú_read_manifestr   )r   r    r0   r#   s   &   r
   Ú_declared_capabilities_for_keyr5   &   s�   € ä‹E×$Ñ$ SÓ)€EØ‚}Øˆ	ØˆQ…x�<ÔÝDÙ5Ö7ˆHØ—|‘| X§]¡]Ð3Ö3Ü˜H×1Ñ1Ó2Ò2ñ 8ð ˆ	Ø��8Œ8Øˆ	Ü/´³×0DÑ0DÄTÈ%ÐPQÍ(Ã^Ó0TÐV[Ð\]ÕV^Ó_Ð_r   ÚcontextÚinstallc               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r   r   Údeclaredr&   r6   r   r   r   )r   s   "r
   r   r   6   s*   € ÷ -ñ -°ð -¸tð -ÐQTð -Ðeiñ -r   c               ó¬  € ^ RI HpHpHp V! W4      pV'       g   V'       d   V! V. V4       R# VR8X  d   RMRpV P	                  RV RV R24       V F?  p	VP                  V	4      p
T P	                  R	T	 R
V
'       d   V
P                  MR 24       KA  	  V P	                  R4       \        4       P                  4       '       g   V P	                  RV RV R24       R# \        4       P                  RV P                  4      '       d3   V! WV4       V P	                  RRP                  V4       RV R24       R# V P	                  RV RV R24       R# )u†  Show the capability consent screen and record the decision; True when granted.

On consent the pending capabilities are granted under
``plugins.entries.<id>.granted_capabilities`` with a hash of the declared set. On decline â€”
or in ANY non-interactive context â€” they stay ungranted (fail closed) and the plugin must
degrade via ``ctx.has_capability()``. Consent + audit, NOT a sandbox.
)ÚCAPABILITY_REGISTRYÚpending_capabilitiesÚrecord_consentTr7   Úrequestsznow requestsz
  [yellow]Plugin [bold]z[/bold] z% the following capabilities:[/yellow]z
    [bold]u   [/bold] â€” Ú u•     [dim]Granting trusts the plugin author with these host surfaces. This is consent, not a sandbox â€” plugins run as regular Python in-process.[/dim]zu  [yellow]Non-interactive session: capabilities NOT granted (fail closed).[/yellow] Run `hermes plugins capabilities z'` to review and `hermes plugins enable z` to grant interactively.Fz"  Grant these capabilities? [y/N] u     [green]âœ“[/green] Granted: z, z ([dim]plugins.entries.z.granted_capabilities[/dim])z  [dim]Declined. z stays enabled with these capabilities off; it should degrade gracefully (ctx.has_capability()). Re-run `hermes plugins enable z` to grant later.[/dim])r*   r;   r<   r=   Úprintr+   Údescriptionr   Ú_is_ttyÚ_ask_yesÚinputÚjoin)Úconsoler   r9   r6   r;   r<   r=   ÚpendingÚverbÚcapÚspecs   &&&$       r
   Ú_run_capability_consentrK   6   sj  € ÷ iÑhÙ" 9Ó7€GßçÙ˜9 b¨(Ô3Ùà  IÔ-‰:°>€DØ‡M�MÐ-¨i¨[¸ÀÀÐFkÐlÔmÛˆØ"×&Ñ& sÓ+ˆØ�‰˜
 3 % |Ï°D×4DÒ4DÐRTÐ3UÐVÖWñ ð ‡M�Mð	ôô
 ‹5�=‰=�?Š?Ø�‰ð,à,5¨;ð 7&Ø&/ [Ð0IðKô	Lñ
 ä
ƒu‡~�~Ð:¸G¿M¹M×JÒJÙ�y¨8Ô4Ø�‰Ø,¨T¯Y©Y°wÓ-?Ð,@ð A%Ø%. KÐ/KðMô	Nñ à‡M�MØ
˜I˜;ð '"à"+ Ð,Cð	EôFñ r   Nc               ó    € V ^8„  d   QhRRRR/# )r   r3   zOptional[str]r   r   r   )r   s   "r
   r   r   f   s   € ÷ -dñ -d˜=ð -d°Dñ -dr   c                ó¨  € ^ RI HpHpHp \	        4       P                  4       pV ei   \	        4       P                  V 4      pVf2   \	        4       P                  V\	        4       P                  V 4      4       V^,          ;'       g
    V^ ,          p . p\	        4       P                  4        F–  pV^,          ;'       g
    V^ ,          pV e   WV^ ,          39  d   K2  \        V4      p	V! V4      p
V Uu0 uF  q³! W‹4      '       g   K  VkK  	  ppV	'       g   V'       g   V f   K{  VP                  W‡^,          WšV34       K˜  	  V e:   V'       g2   \	        4       P                  V\	        4       P                  V 4      4       V'       g   VP                  R4       R# \        V4       F£  w  r�ršpVP                  RV RV R24       V	'       g   VP                  R4       V	 F.  pW¼9  d   RpMWº9   d   R	pMR
pVP                  RV RV 24       K0  	  \        V\        V	4      ,
          4       F  pVP                  RV R24       K  	  K¥  	  R# u upi )u?   ``hermes plugins capabilities [<id>]`` â€” declared vs granted.)r;   Úgranted_capabilitiesÚplugin_capability_grantedNz3[dim]No plugins declare or hold capabilities.[/dim]z[bold]z[/bold] [dim](z)[/dim]z  declared: [dim](none)[/dim]z[yellow]not granted[/yellow]z[green]granted[/green]uI   [green]granted[/green] [dim](via legacy allow_* key â€” deprecated)[/dim]z  z: z>: [green]granted[/green] [dim](not declared in manifest)[/dim])r*   r;   rN   rO   r   Ú_consoler1   Ú_failÚ_unknown_plugin_messageÚ_discover_all_pluginsr5   Úappendr@   ÚsortedÚset)r3   r;   rN   rO   rF   ÚhitÚrowsr    r   r9   ÚgrantedrI   Ú	effectiveÚsourceÚmarks   &              r
   Úcmd_capabilitiesr]   f   sö  € ÷ñ ô
 ‹e�n‰nÓ€GØÒÜ‹e×&Ñ& tÓ,ˆØŠ;Ü‹E�K‰K˜¤£×!>Ñ!>¸tÓ!DÔEØ�1�v×Ð˜˜Q�ˆØ€DÜ“×,Ñ,Ö.ˆØ�A�h×"Ð"˜% �(ˆØÒ °%¸µ(¨OÔ ;ÙÜ1°#Ó6ˆÙ& sÓ+ˆá$7Ó_Ñ$7˜SÐ;TÐUX×;^—S�SÑ$7ˆ	Ð_ß§	¨dªlÙØ�‰�S �( H°yÐAÖBñ /ð Ò§Ü‹�‰�GœS›U×:Ñ:¸4Ó@ÔAßØ�‰ÐKÔLÙä5;¸D¶\Ñ1ˆ�X¨	Ø�‰˜˜s˜e >°&°¸ÐAÔBßØ�M‰MÐ9Ô:ÛˆCØÔ#Ø5‘Ø”Ø/‘àb�Ø�M‰M˜B˜s˜e 2 d VÐ,Ö-ñ ô ˜)¤c¨(£mÕ3Ö4ˆCØ�M‰M˜B˜s˜eÐ#aÐbÖcó 5ó 6Bùò `s   Ã2IÄIc               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   Úallow_tool_overridezOptional[bool]r   r   r   )r   s   "r
   r   r   –   s"   € ÷ !ñ !¨sð !Èð !Ð\`ñ !r   c                óä   € Vf%   \        4       P                  RV P                  4      p\        VRV4       V'       d   V P	                  RV RV R24       R# V P	                  RV RV R	24       R# )
zCResolve and persist the ``allow_tool_override`` grant for a plugin.NzÚ[yellow]Allow this plugin to replace built-in tools (e.g. shell_exec, write_file)?[/yellow]
  This is a privileged capability: an override can intercept everything the agent routes through that tool.
  Grant it? [y/N] r_   u!   [green]âœ“[/green] Granted [bold]zD[/bold] permission to override built-in tools ([dim]plugins.entries.z".allow_tool_override: true[/dim]).z[dim]z@ may not override built-in tools. Re-run `hermes plugins enable z2 --allow-tool-override` to grant this later.[/dim])r   rC   rD   r!   r@   )rF   r   r_   s   &&&r
   Ú_resolve_tool_override_grantra   –   sŠ   € àÒ"ä!›eŸn™nð!ð
 �M‰Mó
Ðô ˜3Ð 5Ð7JÔKßØ�‰Ø/°¨uð 5%à%( EÐ)KðMö	Nð
 	�‰Ø�C�5ð &Ø&) Uð + ð ö	!r   )Ú?)N)Ú__doc__Ú
__future__r   Úpathlibr   Útypingr   r*   r   r   r!   r,   r5   rK   r]   ra   r   r   r
   Ú<module>rg      sH   ðñõ #å Ý å 6òõ÷Zõ`ð -ÐW`÷ -÷`-d÷`!r   