+
    iHàjt  ã                  óv  a € 0 t $ R t^ RIHt ^ RIt^ RIt^ RIHtHtH	t	 ^ RI
HtHt ^ RIHtHtHt ]P"                  ! ]4      tRt]! R]]]R7      tR	]R
&   ]P/                  ]! 4       4       ]P2                  ! R4      tR R lt/ tR]R&    ! R R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# )aj  Delegation provider registry.

Populated by plugins via :meth:`PluginContext.register_delegation_provider`; ``delegate_task``
asks :func:`get_active_provider` which strategy turns each task into a child run. Selection is
``delegation.backend`` in config.yaml, ``default`` when unset. The default strategy (today's
behaviour: every child follows the ``delegation`` section, else the parent's route) is itself a
plugin, the bundled ``plugins/delegation/default``, registered through the same seam as any other.
A session may override the selection (``agent/delegation_backends.py``). A configured backend that is
not registered or reports unavailable fails closed: ``delegate_task`` returns a tool error naming the
backend and the fix, and never quietly runs the children on another route. Its schema parameters are
absent, since the schema is built from the same resolution.
)ÚannotationsN)ÚAnyÚMappingÚOptional)ÚDelegationProviderÚDelegationRouteError)ÚProviderRegistryÚis_available_safeÚ	lower_keyÚdefaultÚ
Delegation)ÚlabelÚprovider_clsÚloggerÚ	normalizez$ProviderRegistry[DelegationProvider]Ú	_registryz^[a-z0-9][a-z0-9_-]{0,63}$c               ó    € V ^8„  d   QhRRRR/# )é   ÚconfigúMapping[str, Any]ÚreturnÚstr© )Úformats   "Ú>/home/ubuntu/.hermes/hermes-agent/agent/delegation_registry.pyÚ__annotate__r   #   s   € ÷ Wñ WÐ0ð W°Sñ Wó    c                óÎ   € \        V \        4      '       d   V P                  R4      MRp\        V\        4      '       d"   VP	                  4       '       d   \        V4      # \        # )zF``delegation.backend`` normalized; blank/non-string means ``default``.ÚbackendN)Ú
isinstancer   Úgetr   Ústripr
   ÚDEFAULT_BACKEND)r   Úraws   & r   Úconfigured_backendr$   #   sC   € ä#-¨f´g×#>Ò#>ˆ&�*‰*�YÔ
ÀD€CÜ'¨¬S×1Ò1°c·i±i·k²kŒ9�S‹>ÐVÄÐVr   zdict[str, DelegationProvider]Ú
_first_usec                  ó2   € ] tR t^,tRtR R ltR R ltRtR# )Ú_BundledRegistrarz¹The one ``ctx`` method a bundled strategy's ``register()`` calls on first use. It keeps the provider
outside the plugin registry, whose entries only the plugin manager adds and removes.c               ó    € V ^8„  d   QhRRRR/# )r   Únamer   r   ÚNoner   )r   s   "r   r   Ú_BundledRegistrar.__annotate__0   s   € ÷ ñ ˜Sð  Tñ r   c                	ó   € Wn         R # ©N©r)   )Úselfr)   s   &&r   Ú__init__Ú_BundledRegistrar.__init__0   s   € ØŽ	r   c               ó    € V ^8„  d   QhRRRR/# )r   Úproviderr   r   r*   r   )r   s   "r   r   r+   3   s   € ÷ )ñ )Ð5Gð )ÈDñ )r   c                	ó,   € V\         V P                  &   R # r-   )r%   r)   )r/   r3   s   &&r   Úregister_delegation_providerÚ._BundledRegistrar.register_delegation_provider3   s   € Ø (Œ
�4—9‘9Ór   r.   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r0   r5   Ú__static_attributes__r   r   r   r'   r'   ,   s   † ñ\õ÷)ñ )r   r'   c               ó    € V ^8„  d   QhRRRR/# )r   r)   r   r   Úboolr   )r   s   "r   r   r   7   s   € ÷ Hñ H˜Cð H Dñ Hr   c                óF   € ^ RI Hp \        V RV  20V! 4       ,          4      # )é    )Ú_get_disabled_pluginszdelegation/)Úhermes_cli.plugins_discoveryrA   r>   )r)   rA   s   & r   Ú_bundled_disabledrC   7   s%   € ÝBÜ�˜ T FÐ+Ð,Ñ/DÓ/FÕFÓGÐGr   c               ó    € V ^8„  d   QhRRRR/# ©r   r)   r   r   úOptional[DelegationProvider]r   )r   s   "r   r   r   <   s   € ÷  ñ  ˜ð  Ð <ñ  r   c                óÐ  € ^ RI Hp ^ RIHp \        P                  V 4      '       d   \        V 4      '       d   R# V \        9   d   \        V ,          # V! 4       R,          V ,          pVR,          P                  4       '       g   R# VP                  RV P                  RR4       2VR
\        R	7      pVf   R# VP                  \        V 4      4       \        P                  V 4      # )aJ  The bundled strategy ``plugins/delegation/<name>/`` on first use when the plugin sweep has not
registered it (a runtime that never ran discovery, or pinned it with zero plugins): delegation is a
core tool and must not depend on the sweep. ``plugins.disabled`` wins on every call, so a later
disable takes effect without a restart.)Úget_bundled_plugins_dir)Úplugin_loaderNÚ
delegationzplugin.yamlzplugins.delegation.Ú-Ú_)Úparentsr   )Úpluginszplugins.delegation)Úhermes_cli.pluginsrH   rN   rI   Ú_BUNDLED_NAME_REÚmatchrC   r%   Úis_fileÚload_plugin_moduleÚreplacer   Úregisterr'   r    )r)   rH   rI   Ú
plugin_dirÚmodules   &    r   Ú_load_bundledrX   <   sÃ   € õ
 ;Ý%Ü×!Ñ! $×'Ò'Ô+<¸T×+BÒ+BÙØŒzÔÜ˜$ÕÐÙ(Ó*¨\Õ9¸DÕ@€JØ˜Õ&×/Ñ/×1Ò1ÙØ×-Ñ-Ø
˜dŸl™l¨3°Ó4Ð5Ð6¸
ÐLmÜð .ó €Fð ‚~ÙØ
‡O�OÔ% dÓ+Ô,Ü�>‰>˜$ÓÐr   c               ó    € V ^8„  d   QhRRRR/# )r   r3   rF   r   r>   r   )r   s   "r   r   r   S   s   € ÷ Mñ MÐ5ð M¸$ñ Mr   c                ó<   € V R J;'       d    \        V \        R4      # )Nz/delegation provider %s.is_available() raised %s)r	   r   )r3   s   &r   Ú
_availabler[   S   s-   € Ø˜4Ð÷ Mð MÔ$5Ø”&ÐKó%Mð Mr   c               ó    € V ^8„  d   QhRRRR/# rE   r   )r   s   "r   r   r   X   s   € ÷ ñ �#ð Ð6ñ r   c                ó  € \         P                  V 4      p\        V4      '       d   V# \        V 4      p\        V4      '       d   V# Vf:   Vf6   ^ RIHp V! 4        \         P                  V 4      p\        V4      '       d   V# R# )záThe available provider for ``name``: the registered one, else a bundled strategy of that name
(also when the registered one reports unavailable), else one plugin discovery sweep (a caller
that never imported ``model_tools``).N)Údiscover_plugins)r   Úget_providerr[   rX   rO   r^   )r)   Ú
registeredÚbundledr^   s   &   r   Ú_usablerb   X   sv   € ô ×'Ñ'¨Ó-€JÜ�*×ÒØÐÜ˜DÓ!€GÜ�'×ÒØˆØÒ˜gšoÝ7ÙÔÜ×+Ñ+¨DÓ1ˆ
Ü�j×!Ò!ØÐÙr   c               ó    € V ^8„  d   QhRRRR/# )r   r)   r   r   z(tuple[Optional[DelegationProvider], str]r   )r   s   "r   r   r   k   s   € ÷ <ñ <˜ð <Ð!Iñ <r   c                óœ   € \        V 4      pVe   VR3# \        P                  V 4      pVf   V \        8X  d   R# Vf	   RRV  R23# VRV  R23# )z¬``(provider, "")`` when backend ``name`` can run here, else ``(provider or None, reason)``; the reason is
the user-facing fix (it becomes the ``delegate_task`` tool error).NÚ zDelegation backend 'zÊ' is not installed: no enabled plugin provides it. Install or enable the plugin that does (`hermes plugins list`), or switch back to the default backend (`hermes config set delegation.backend default`).zÊ' is unavailable here (its plugin reports it cannot run). Fix its setup, or switch back to the default backend: `/delegation default` for this session, or `hermes config set delegation.backend default`.)Nz�No default delegation strategy is available: the bundled plugin delegation/default is disabled. Remove it from plugins.disabled in config.yaml.)rb   r   r_   r"   )r)   r3   r`   s   &  r   Úbackend_statusrf   k   sŽ   € ô �t‹}€HØÒØ˜ˆ|ÐÜ×'Ñ'¨Ó-€JØÒ˜d¤oÔ5ðSð 	SàÒØØ" 4 &ð )@ð AðBð 	Bð Ø
˜t˜fð %:ð 	;ð<ð <r   c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r   r   r   )r   s   "r   r   r   €   s   € ÷ ñ Ð 1ð Ð6Hñ r   c                óf   € \        \        V 4      4      w  rV'       g   Vf   \        V R24      hV# )zÃThe provider ``config`` (the ``delegation`` section) selects; ``default`` when unset. Raises
:class:`DelegationRouteError` naming the backend and the fix when it is not registered or unavailable.z No subagent was started.)rf   r$   r   )r   r3   Úreasons   &  r   Úget_active_providerrj   €   s7   € ô &Ô&8¸Ó&@ÓAÑ€Hß�Ò!Ü" f XÐ-FÐ#GÓHÐHØ€Or   )$Ú__conditional_annotations__r;   Ú
__future__r   ÚloggingÚreÚtypingr   r   r   Úagent.delegation_providerr   r   Úagent.provider_registryr   r	   r
   Ú	getLoggerr7   r   r"   r   Ú__annotations__ÚexportÚglobalsÚcompilerP   r$   r%   r'   rC   rX   r[   rb   rf   rj   )rk   s   @r   Ú<module>rw      s¶   øðôõ #ã Û 	ß )Ñ )ç Nß RÑ Rà	×	Ò	˜8Ó	$€à€á2BØ
Ð%7ÀÐR[ô3€	Ð/ó ð 
× Ñ ‘“Ô à—:’:Ð;Ó<Ð õWð -/€
Ð)Ó .÷)ñ )õHõ
 õ.Mõ
õ&<÷*r   