Ë
    âß²j3c  ã                  ód  — U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZ ddlmZmZ ddlmZ ddlmZ  ej&                  e«      Zi Zded	<   i Zd
ed<   i Zd
ed<   daded<   daded<   dadae G d„ d«      «       Zi Zded<    e	j@                  «       Z! edd¬«      Z"ded<    ee#«      jI                  «       jJ                  jJ                  dz  dz  Z&d3d„Z'd4d„Z(d5d„Z)d6d„Z*d7d „Z+d8d!„Z,d9d"„Z-d:d#„Z.d;d$„Z/d;d%„Z0d<d&„Z1d=d'„Z2d>d(„Z3d)d*œd?d+„Z4d3d,„Z5d@d-„Z6d3d.„Z7d3d/„Z8d0d1iZ9d2„ Z:y)Au6  Provider module registry.

Provider profiles can live in three places:

1. Bundled plugins: ``plugins/model-providers/<name>/`` (shipped with hermes-agent)
2. User plugins: ``$HERMES_HOME/plugins/model-providers/<name>/``
3. Pip-installed plugins: distributions exposing a ``hermes_agent.plugins``
   entry point (``module:func`` callable or a self-registering ``module``)

Each plugin directory contains:
  - ``__init__.py`` â€” calls ``register_provider(profile)`` at import
  - ``plugin.yaml`` â€” manifest (name, kind: model-provider, version, description)

Discovery is lazy: the first call to ``get_provider_profile()`` or
``list_providers()`` imports the bundled and pip-installed plugins once per
process; the ``$HERMES_HOME`` plugins of the profile home bound at lookup time
load into that home's own layer, so one process serving several profiles
(multiplex gateway, Desktop ``serve``) resolves each profile's installs. User
plugins override bundled plugins on name collision, so third parties can
monkey-patch or replace any built-in profile without editing the repo.

For backward compatibility, ``providers/*.py`` files (other than ``base.py``
and ``__init__.py``) are still discovered via ``pkgutil.iter_modules``.
This lets out-of-tree users drop a single-file profile into an editable
install without the plugin dir structure. New profiles should prefer the
plugin layout.

Usage::

    from providers import get_provider_profile
    profile = get_provider_profile("nvidia")   # ProviderProfile or None
    profile = get_provider_profile("kimi")     # checks name + aliases
é    )ÚannotationsN)Ú
ContextVar)Ú	dataclassÚfield)ÚPath)ÚProviderProfileúdict[str, ProviderProfile]Ú	_REGISTRYúdict[str, str]Ú_ALIASESÚ_SOURCESú
str | NoneÚ_current_sourcezlist[ProviderProfile] | NoneÚ_PROVIDER_LIST_CACHEFc                  óX   — e Zd ZU dZ ee¬«      Zded<    ee¬«      Zded<   dZ	ded	<   y
)Ú
_HomeLayeru…  The ``$HERMES_HOME/plugins`` providers of ONE profile home.

    One process serves many profiles (multiplex gateway, Desktop ``serve``) and each profile installs
    its own plugins, so user plugins are keyed by the home bound at lookup time instead of the home
    that happened to be bound at first discovery â€” that made a plugin installed in a secondary
    profile ``Unknown provider`` in Desktop while the same profile worked in a terminal (#88143).
    ``stamps`` are the plugin dirs' mtimes: a directory added by ``hermes plugins install`` while the
    process runs changes them, and the next lookup imports it without a restart.
    )Údefault_factoryr	   Úregistryr   Úaliases© ÚtupleÚstampsN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Údictr   Ú__annotations__r   r   r   ó    ú7/home/ubuntu/.hermes/hermes-agent/providers/__init__.pyr   r   @   s2   … ññ ,1ÀÔ+F€HÐ(ÓFÙ#°DÔ9€Gˆ^Ó9Ø€FˆEÔr   r   zdict[str, _HomeLayer]Ú_HOME_LAYERSÚ_provider_registration_target)ÚdefaultzContextVar[_HomeLayer | None]Ú_REGISTRATION_TARGETÚpluginsúmodel-providersc                 óÆ   — t        t        j                  j                  d«      dd«      } | €y	  | «        y# t        $ r }t
        j                  d|«       Y d}~yd}~ww xY w)aÀ  Mirror profiles into ``hermes_cli.auth.PROVIDER_REGISTRY`` if that module is loaded.

    ``hermes_cli.auth`` takes its own snapshot of ``list_providers()`` when it is imported. If a
    plugin's imports pull that module in while :func:`_discover_providers` is still running, the
    snapshot is partial and later plugins never reach the auth registry ("Unknown provider",
    #102123). Calling back into auth once discovery is complete closes that window. Looked up via
    ``sys.modules`` on purpose: this layer must never import ``hermes_cli`` (that would run auth's
    top-level code mid-scan and risk a circular import). Never raises: registration must not fail
    because of the auth mirror.
    zhermes_cli.authÚsync_plugin_provider_registryNzauth registry sync skipped: %s)ÚgetattrÚsysÚmodulesÚgetÚ	ExceptionÚloggerÚdebug)ÚsyncÚexcs     r    Ú_sync_auth_registryr2   ^   sV   € ô ”3—;‘;—?‘?Ð#4Ó5Ð7VÐX\Ó]€DØ€|Øð<Ù�øÜò <Ü�‰Ð5°s×;Ñ;ûð<ús   ¯7 ·	A Á AÁA c                ó�  — t         j                  «       }|�D| |j                  | j                  <   | j                  D ]  }| j                  |j                  |<   Œ nT| t
        | j                  <   t        xs dt        | j                  <   | j                  D ]  }| j                  t        |<   Œ da	t        rt        st        «        yyy)ua  Register a provider profile by name and aliases.

    Later registrations with the same name replace earlier ones â€” so user
    plugins under ``$HERMES_HOME/plugins/model-providers/`` can override
    bundled profiles without editing repo code. A registration made while a
    ``$HERMES_HOME`` plugin is being imported lands in that home's layer.
    NÚruntime)r$   r,   r   Únamer   r
   r   r   r   r   Ú_discoveredÚ_discoveringr2   )ÚprofileÚlayerÚaliass      r    Úregister_providerr;   r   sª   € ô !×$Ñ$Ó&€EØÐØ'.ˆ�‰�w—|‘|Ñ$Ø—_‘_ò 	0ˆEØ#*§<¡<ˆE�M‰M˜%Ò ñ	0ð #*Œ	�'—,‘,ÑÜ!0Ò!=°IŒ�—‘ÑØ—_‘_ò 	+ˆEØ%Ÿl™lŒH�UŠOð	+à#ÐÝ�<ÜÕð (€{r   c                óÄ   — t        «       }|j                  j                  | «      xs t        j                  | | «      }||j                  v ryt
        j                  |«      S )u"  Discovery source of the profile currently registered under *name* (see ``_SOURCES``), or None.

    ``"user"`` is what lets a ``$HERMES_HOME`` plugin re-registering a bundled name win in
    ``hermes_cli.auth.PROVIDER_REGISTRY`` too â€” a bundled profile never rewrites a built-in row.
    Úuser)Ú_home_layerr   r,   r   r   r   )r5   r9   Ú	canonicals      r    Úprovider_sourcer@   Š   sM   € ô ‹M€EØ—‘×!Ñ! $Ó'ÒC¬8¯<©<¸¸dÓ+C€IØ�E—N‘NÑ"ØÜ�<‰<˜	Ó"Ð"r   c                óÊ  — t         s
t        «        t        «       }|j                  j	                  | «      xs t
        j	                  | | «      }|j                  j	                  |«      xs t        j	                  |«      }|€at        | t        «      rQ| j                  «       j                  d«      r2|j                  j	                  d«      xs t        j	                  d«      }|S )z{Look up a provider profile by name or alias.

    Returns None if the provider has no profile (falls back to generic).
    zcustom:Úcustom)r6   Ú_discover_providersr>   r   r,   r   r   r
   Ú
isinstanceÚstrÚlowerÚ
startswith)r5   r9   r?   r8   s       r    Úget_provider_profilerH   —   s¤   € õ
 ÜÔÜ‹M€EØ—‘×!Ñ! $Ó'ÒC¬8¯<©<¸¸dÓ+C€IØ�n‰n× Ñ  Ó+ÒG¬y¯}©}¸YÓ/G€Gð €œ: d¬CÔ0°T·Z±Z³\×5LÑ5LÈYÔ5WØ—.‘.×$Ñ$ XÓ.ÒI´)·-±-ÀÓ2IˆØ€Nr   c                óŽ  — t        | xs d«      j                  «       j                  «       }t        |«      }|�|j                  du ryddlm}  ||«      syt        |xs d«      j                  «       j                  d«      \  }}}|r|syt        |j                  «       j                  «       «      }|duxr |j                  du S )aä  Whether an active route or its aggregator-targeted model rejects image tool parts.

    Routing aggregators such as ``openrouter`` send vendor-prefixed model IDs
    (for example, ``xiaomi/mimo-v2.5``), but their own profile cannot describe
    every routed provider's tool-message compatibility. Preserve the transport
    profile as the default and consult a registered target profile only for
    routing aggregators. Missing or unrecognized identities deliberately fail open.
    Ú NFTr   )Úis_routing_aggregatorú/)rE   ÚstriprF   rH   Úsupports_vision_tool_messagesÚhermes_cli.providersrK   Ú	partition)	ÚproviderÚmodelÚprovider_namer8   rK   Útarget_nameÚ	separatorÚ_Útarget_profiles	            r    Ú)routed_model_rejects_vision_tool_messagesrX   ¨   s½   € ô ˜š BÓ'×-Ñ-Ó/×5Ñ5Ó7€MÜ" =Ó1€GØÐ˜w×DÑDÈÑMØõ ;Ù  Ô/Øä # E¢K¨RÓ 0× 6Ñ 6Ó 8× BÑ BÀ3Ó GÑ€K�˜AÙ™KØÜ)¨+×*;Ñ*;Ó*=×*CÑ*CÓ*EÓF€NØ Ð%Ò_¨.×*VÑ*VÐZ_Ð*_Ð_r   c                 ó  — t         s
t        «        t        «       } t        €`t	        «       }g }t
        j                  «       D ];  }t        |«      |vsŒ|j                  t        |«      «       |j                  |«       Œ= |at        D �cg c]  }|j                  | j                  vsŒ|‘Œ }}|j                  | j                  j                  «       D �ci c]  }t        |«      |“Œ c}j                  «       «       |S c c}w c c}w )zžReturn all registered provider profiles (one per canonical name); the bound home's
    ``$HERMES_HOME`` plugins shadow process-wide profiles of the same name.)r6   rC   r>   r   Úsetr
   ÚvaluesÚidÚaddÚappendr5   r   Úextend)r9   ÚseenÚcacher8   ÚpÚresults         r    Úlist_providersrd   Ã   sÓ   € õ ÜÔÜ‹M€EÜÐ#ä›ˆØ')ˆÜ ×'Ñ'Ó)ò 	&ˆGÜ�'‹{ $Ò&Ø—‘œ˜G›Ô%Ø—‘˜WÕ%ð	&ð  %ÐÜ-ÖN�A°·±¸u¿~¹~Ò1MŠaÐN€FÐNØ
‡M�M U§^¡^×%:Ñ%:Ó%<Ö= ”2�a“5˜!‘8Ò=×DÑDÓFÔGØ€Mùò OùÚ=s   Â	C>Â'C>ÃDc                 óF  — 	 ddl m} m}  | «       } ||«      }t        5  t
        j                  |«      }|€t        «       x}t
        |<   ddd«       |�-t        |«      x}j                  k7  rt        ||«       ||_	        S # t        $ r d\  }}Y Œzw xY w# 1 sw Y   ŒNxY w)zRThe layer for the home bound right now, importing plugin dirs it has not seen yet.r   )Úget_hermes_homeÚhermes_home_key)NrJ   N)Úhermes_constantsrf   rg   r-   Ú_HOME_LAYERS_LOCKr!   r,   r   Ú_plugin_dir_stampsr   Ú_scan_home_layer)rf   rg   ÚhomeÚkeyr9   r   s         r    r>   r>   Ø   sª   € ðßEáÓ ˆÙ˜dÓ#ˆô 
ñ 5Ü× Ñ  Ó%ˆØˆ=Ü(2«Ð4ˆE”L Ñ%÷5ð ÐÔ'9¸$Ó'?Ð?˜VÀEÇLÁLÒPÜ˜ Ô$ØˆŒØ€Løô ò Ø‰	ˆŠcðú÷5ð 5ús   ‚B Ÿ+BÂBÂBÂB c                ó<   — dd„} || dz  «       || dz  dz  «      fS )z[mtimes of ``plugins/`` and ``plugins/model-providers/``: they change when a child is added.c                ó`   — 	 t        j                  | «      j                  S # t        $ r Y y w xY w)N)ÚosÚstatÚst_mtime_nsÚOSError)Úpaths    r    Ústampz!_plugin_dir_stamps.<locals>.stampï   s-   € ð	Ü—7‘7˜4“=×,Ñ,Ð,øÜò 	Ùð	ús   ‚! ¡	-¬-r%   r&   )rt   r   r   )rl   ru   s     r    rj   rj   í   s.   € óñ
 �$˜Ñ"Ó#¡U¨4°)Ñ+;Ð>OÑ+OÓ%PÐQÐQr   c                 óp   — 	 ddl m}   | «       dz  dz  }|j                  «       r|S dS # t        $ r Y yw xY w)z>Return ``$HERMES_HOME/plugins/model-providers/`` if it exists.r   ©rf   r%   r&   N©rh   rf   Úis_dirr-   ©rf   Úds     r    Ú_user_plugins_dirr|   ÷   sB   € ðÝ4áÓ 	Ñ)Ð,=Ñ=ˆØ—H‘H”JˆqÐ( DÐ(øÜò Ùðús   ‚$) §) ©	5´5c                 ój   — 	 ddl m}   | «       dz  }|j                  «       r|S dS # t        $ r Y yw xY w)uï   Return ``$HERMES_HOME/plugins/`` if it exists.

    This is where ``hermes plugins install`` clones a plugin â€” flat, one
    directory per plugin, NOT under ``model-providers/``. See
    :func:`_discover_installed_provider_plugins`.
    r   rw   r%   Nrx   rz   s     r    Ú_installed_plugins_dirr~     s<   € ðÝ4áÓ 	Ñ)ˆØ—H‘H”JˆqÐ( DÐ(øÜò Ùðús   ‚!& ¤& ¦	2±2c                ód  — dD �]  }| |z  }|j                  «       sŒ	 |j                  dd¬«      }	 ddl}|j	                  |«      }t        |t        «      r.t        |j                  dd	«      «      j                  «       d
k(  c S 	 |j                  «       D ]v  }|j                  «       }|j                  d«      sd|vrŒ)|j                  d«      \  }}	}
|j                  «       dk(  sŒR|
j                  «       j                  d«      d
k(  c c S   y y# t        $ r Y  yw xY w# t        $ r Y Œ¨w xY w)uj  Whether ``plugin_dir``'s manifest declares ``kind: model-provider``.

    Only that kind is imported from the flat install directory â€” every other
    plugin there belongs to ``PluginManager``, which owns its lifecycle and
    consent flow. Parsed with PyYAML when available, falling back to a line
    scan so provider discovery never hard-depends on it.
    )zplugin.yamlz
plugin.ymlúutf-8Úreplace)ÚencodingÚerrorsFr   NÚkindrJ   zmodel-providerú#ú:z"')Úis_fileÚ	read_textr-   ÚyamlÚ	safe_loadrD   r   rE   r,   rM   Ú
splitlinesrG   rP   )Ú
plugin_dirÚfilenameÚmanifestÚtextr‰   ÚdataÚlineÚstrippedrm   rV   Úvalues              r    Ú_declares_model_provider_kindr”     s?  € ð 2ó ˆØ Ñ(ˆØ×ÑÔ!Øð	Ø×%Ñ%¨w¸yÐ%ÓIˆDð	Ûà—>‘> $Ó'ˆDÜ˜$¤Ô%Ü˜4Ÿ8™8 F¨BÓ/Ó0×6Ñ6Ó8Ð<LÑLÒLð &ð —O‘OÓ%ò 	FˆDØ—z‘z“|ˆHØ×"Ñ" 3Ô'¨3°hÑ+>ØØ$×.Ñ.¨sÓ3‰MˆC��EØ�y‰y‹{˜fÓ$Ø—{‘{“}×*Ñ*¨5Ó1Ð5EÑEÔEð	Fñ ð/ð0 øô% ò 	Úð	ûô ò 	Ùð	ús#   žD²AD#Ä	D ÄD Ä#	D/Ä.D/c                óž  — t         j                  | «      t        }}da	 t        «       }|�Yt	        |j                  «       «      D ]=  }|j                  «       sŒ|j                  j                  d«      rŒ0t        |d|¬«       Œ? t        «       }|�st	        |j                  «       «      D ]W  }|j                  «       r*|j                  j                  d«      s|j                  dk(  rŒ>t        |«      sŒJt        |d|¬«       ŒY t         j                  |«       |at        rt        st        «        yyy# t         j                  |«       |aw xY w)a¯  Import the bound home's not-yet-imported provider plugins into *layer*.

    ``$HERMES_HOME/plugins/model-providers/<name>/`` first, then plugins cloned flat by
    ``hermes plugins install`` into ``$HERMES_HOME/plugins/<name>/`` that declare
    ``kind: model-provider`` (PluginManager owns every other kind there). Per-home module names
    let two profiles carry the same plugin without aliasing each other's registrations.
    TN©rV   ú.r=   ©Úhome_keyr&   )r$   rZ   r7   r|   ÚsortedÚiterdirry   r5   rG   Ú_import_plugin_dirr~   r”   Úresetr6   r2   )r9   rm   ÚtokenÚprior_discoveringÚuser_dirÚchildÚinstalled_dirs          r    rk   rk   5  s   € ô  4×7Ñ7¸Ó>ÄÐ€EØ€Lð)Ü$Ó&ˆØÐÜ × 0Ñ 0Ó 2Ó3ò D�Ø—<‘<•>¨%¯*©*×*?Ñ*?À
Õ*KÜ& u¨f¸sÖCðDô /Ó0ˆØÐ$Ü × 5Ñ 5Ó 7Ó8ò D�Ø—|‘|”~¨¯©×)>Ñ)>¸zÔ)JÈeÏjÉjÐ\mÒNmØÜ0°Õ7Ü& u¨f¸sÖCð	Dô 	×"Ñ" 5Ô)Ø(ˆÝ�<ÜÕð (€{øô 	×"Ñ" 5Ô)Ø(‰ús   Ÿ8D3 ÁD3 Á4A>D3 Ã3D3 Ä3Ec                ó°   — t        j                  |j                  d«      «      j                  «       d d }d|› d| j                  j                  dd«      › �S )Nr€   é
   Ú_hermes_user_provider_rV   ú-)ÚhashlibÚsha1ÚencodeÚ	hexdigestr5   r�   )rŒ   r™   Údigests      r    Ú_user_module_namer¬   T  sN   € Ü�\‰\˜(Ÿ/™/¨'Ó2Ó3×=Ñ=Ó?ÀÀÐD€FØ# F 8¨1¨Z¯_©_×-DÑ-DÀSÈ#Ó-NÐ,OÐPÐPr   rJ   r˜   c               óš  — | dz  }|j                  «       sy|dk(  r d| j                  j                  dd«      › �}nt        | |«      }|t        j
                  v ry|a	 t        j                  j                  ||t        | «      g¬«      }|�|j                  €	 dayt        j                  j                  |«      }|t        j
                  |<   |j                  j                  |«       day# t        $ rN}t        j!                  d|| j                  |«       t        j
                  j#                  |d«       Y d}~dayd}~ww xY w# daw xY w)	z™Import a single plugin directory so it self-registers.

    ``source`` is "bundled" or "user"; it is recorded per registered profile (``_SOURCES``).
    z__init__.pyNÚbundledzplugins.model_providers.r¦   rV   )Úsubmodule_search_locationsz(Failed to load %s provider plugin %s: %s)Úexistsr5   r�   r¬   r*   r+   r   Ú	importlibÚutilÚspec_from_file_locationrE   ÚloaderÚmodule_from_specÚexec_moduler-   r.   ÚwarningÚpop)rŒ   Úsourcer™   Ú	init_fileÚmodule_nameÚspecÚmoduler1   s           r    rœ   rœ   Y  s8  € ð ˜]Ñ*€IØ×ÑÔØð �ÒØ0°·±×1HÑ1HÈÈcÓ1RÐ0SÐT‰ä'¨
°HÓ=ˆà”c—k‘kÑ!Øà€OðÜ�~‰~×5Ñ5Ø˜ÄÀJÃÐ?Pð 6ó 
ˆð ˆ<˜4Ÿ;™;Ð.Øð ‰ô —‘×0Ñ0°Ó6ˆØ#)Œ�‰�KÑ Ø�‰×Ñ Ô'ð ‰øô ò +Ü�‰Ø6¸À
ÇÁÐQTô	
ô 	�‰�‰˜ T×*Ð*à‰ûð+ûð ‰ús2   Á:C, ÂAC, Ã,	EÃ5AD>Ä7E Ä>EÅE ÅE
c                 óª  — 	 ddl m}  	 ddlm}m}  |«       } |«       }|syd}	 | j                  «       }t        |d«      rt        |j                  |¬«      «      }nt        |j                  |g «      «      }|D ]�  }	|	j                  |vs|	j                  |v r!t        j                  d|	j                  «       Œ@	 |	j                  «       }
t#        |
«      sŒ]t%        |
«      r!t        j                  d
|	j                  «       Œ‰	  |
«        Œ’ y# t        $ r Y yw xY w# t        $ r dt        «       }}Y �Œw xY w# t        $ r }t        j                  d|«       Y d}~yd}~ww xY w# t        $ r,}t        j!                  d	|	j                  |«       Y d}~�Œd}~ww xY w# t        $ r,}t        j!                  d|	j                  |«       Y d}~�ŒSd}~ww xY w)u*  Import pip-installed provider plugins via the ``hermes_agent.plugins``
    entry-point group so they self-register.

    A distribution ships::

        [project.entry-points."hermes_agent.plugins"]
        acme-inference = "acme_hermes_plugin:register"

    The target may be either a **callable** (``module:func`` â€” invoked with no
    args; typically calls ``register_provider(profile)``) or a **module**
    (``module`` â€” imported for its module-level ``register_provider`` side
    effect, mirroring the directory-plugin ``__init__.py`` contract).

    Gating and safety:

    * **Opt-in.** Entry-point plugins are subject to the same
      ``plugins.enabled`` allow-list (and ``plugins.disabled`` deny-list) the
      general PluginManager enforces â€” a pip package is never imported just
      because it is installed. An entry point whose name is not enabled is
      skipped without loading.
    * **Provider targets only.** The ``hermes_agent.plugins`` group is shared
      with general plugins whose target is ``register(ctx)``. Callables that
      require arguments are skipped here (the PluginManager owns them);
      provider registration hooks take no arguments by contract.

    Failures are swallowed per-entry (a broken third-party package must not
    break provider discovery) and logged at warning level. This scan runs
    first, so filesystem plugins (bundled + ``$HERMES_HOME``) keep their
    documented override precedence via last-writer-wins in
    ``register_provider()`` â€” a pip package cannot hijack a first-party
    provider name.
    r   N)Ú_get_disabled_pluginsÚ_get_enabled_pluginszhermes_agent.pluginsÚselect)Úgroupz%entry-point provider scan skipped: %sz6entry-point provider %r skipped: not enabled in configz1Failed to load entry-point provider plugin %r: %szjentry-point %r skipped by provider scan: target requires arguments (general plugin owned by PluginManager)z7Entry-point provider plugin %r raised on invocation: %s)Úimportlib.metadataÚmetadatar-   Úhermes_cli.pluginsr¿   rÀ   rZ   Úentry_pointsÚhasattrÚlistrÁ   r,   r.   r/   r5   Úloadr·   ÚcallableÚ_requires_arguments)Ú_mdr¿   rÀ   ÚenabledÚdisabledrÂ   ÚepsÚ	group_epsr1   ÚepÚloadeds              r    Ú_discover_entry_point_providersrÓ   ‚  s±  € ðBÝ(ð(ßRá&Ó(ˆÙ(Ó*ˆñ Øà"€Eð	Ø×ÑÓ ˆä�3˜Ô!Ü˜SŸZ™Z¨e˜ZÓ4Ó5‰Iä˜SŸW™W U¨BÓ/Ó0ˆIð
 ò !ˆØ�7‰7˜'Ñ! R§W¡W°Ñ%8Ü�L‰LØHÈ"Ï'É'ôð ð	Ø—W‘W“YˆFô �FÕÜ" 6Ô*Ü—‘ðHà—G‘Gôð
 ðÙ•ñ7!øô7 ò Ùðûô ò (Ø ¤#£%�‹ð(ûô ò Ü�‰Ð<¸cÔBÜûðûô ò 	Ü�N‰NØCÀRÇWÁWÈcôõ ûð		ûô( ò Ü—‘ØMØ—G‘GØ÷ò ûðúsj   ‚D ‰D ¥AD9 Â;E%ÄFÄ	DÄDÄD6Ä5D6Ä9	E"ÅEÅE"Å%	FÅ.!FÆFÆ	GÆ&!GÇGc                ó|  — ddl }	 |j                  | «      }|j                  j                  «       D ]t  }|j                  |j                  j                  |j                  j                  |j                  j                  fv sŒQ|j                  |j                  j                  u sŒt y y# t        t        f$ r Y yw xY w)aR  True when ``fn`` cannot be called with zero arguments.

    Used to distinguish provider registration hooks (zero-arg by contract)
    from general plugin hooks (``register(ctx)``) sharing the same entry-point
    group. Unintrospectable callables (C extensions) are treated as zero-arg
    and left to the per-entry exception guard.
    r   NFT)ÚinspectÚ	signatureÚ	TypeErrorÚ
ValueErrorÚ
parametersr[   r„   Ú	ParameterÚPOSITIONAL_ONLYÚPOSITIONAL_OR_KEYWORDÚKEYWORD_ONLYr#   Úempty)ÚfnrÕ   ÚsigÚparams       r    rË   rË   ä  s³   € ó ðØ×Ñ Ó#ˆð —‘×&Ñ&Ó(ò ˆØ�:‰:Ø×Ñ×-Ñ-Ø×Ñ×3Ñ3Ø×Ñ×*Ñ*ð
ò 
ð �m‰m˜w×0Ñ0×6Ñ6Ò6Ùðð øô ”zÐ"ò Ùðús   †B) Â)B;Â:B;c                 ój   — t         ryda da	 t        «        dat        «        y# dat        «        w xY w)aÎ  Populate the process-wide registry by importing every provider plugin.

    Order:
      1. Bundled plugins at ``<repo>/plugins/model-providers/<name>/``
      2. Legacy per-file modules at ``providers/<name>.py`` (back-compat)

    Each step imports its plugins, which call ``register_provider()`` at
    module-level. Later steps win on name collision. ``$HERMES_HOME`` plugins are
    per profile home and load through :func:`_home_layer` at lookup time.
    NTF)r6   r7   Ú_run_discovery_stepsr2   r   r   r    rC   rC   ü  s=   € õ ØØ€KØ€LðÜÔàˆô 	Õøð ˆô 	Õús   �
$ ¤2c                 ó&  — t        «        t        j                  «       rZt        t        j	                  «       «      D ]:  } | j                  «       r| j
                  j                  d«      rŒ/t        | d«       Œ< 	 ddl}ddl	}|j                  |j                  «      D ]6  \  }}}|j                  d«      s|dk(  rŒ	 t        j                  d|› �«       Œ8 y# t        $ r!}t        j!                  d||«       Y d}~Œ_d}~ww xY w# t"        $ r Y yw xY w)	zLThe discovery passes, in precedence order (see :func:`_discover_providers`).r–   r®   r   NrV   Úbasez
providers.z.Failed to import legacy provider module %s: %s)rÓ   Ú_BUNDLED_PLUGINS_DIRry   rš   r›   r5   rG   rœ   ÚpkgutilÚ	providersÚiter_modulesÚ__path__r±   Úimport_moduleÚImportErrorr.   r·   r-   )r¡   rç   Ú_pkgÚ	_importerÚmodnameÚ_ispkgr1   s          r    rã   rã     sü   € ô  $Ô%ô ×"Ñ"Ô$ÜÔ0×8Ñ8Ó:Ó;ò 	1ˆEØ—<‘<”> U§Z¡Z×%:Ñ%:¸:Ô%FØÜ˜u iÕ0ð	1ðÛã à*1×*>Ñ*>¸t¿}¹}Ó*Mò 	Ñ&ˆI�w Ø×!Ñ! #Ô&¨'°VÒ*;ØðÜ×'Ñ'¨*°W°IÐ(>Õ?ñ		øô
 ò Ü—‘ØDÀgÈs÷ñ ûðûô ò Ùðús=   Á:AD Â<CÃD Ã	DÃ C<Ã7D Ã<DÄD Ä	DÄDÚOMIT_TEMPERATURE)zproviders.baserñ   c                óÎ   — t         j                  | «      }|€t        dt        ›d| ›�«      ‚dd l}ddlm}  |t        | g|¢­Ž  t         |j                  |d   «      |d   «      S )Nzmodule z has no attribute r   )Ú	warn_onceé   )	Ú_PLUGIN_COMPAT_LAZYr,   ÚAttributeErrorr   r±   Úhermes_cli.plugin_compatró   r)   rë   )r5   Útargetr±   ró   s       r    Ú__getattr__rù   R  sh   € Ü ×$Ñ$ TÓ*€FØ€~Ü˜w¤x lÐ2DÀTÀHÐMÓNÐNÛÝ2ÙŒh˜Ð&˜vÓ&ÜÐ*�9×*Ñ*¨6°!©9Ó5°v¸a±yÓAÐAr   )ÚreturnÚNone)r8   r   rú   rû   )r5   rE   rú   r   )r5   rE   rú   zProviderProfile | None)rQ   rE   rR   rE   rú   Úbool)rú   zlist[ProviderProfile])rú   r   )rl   r   rú   r   )rú   zPath | None)rŒ   r   rú   rü   )r9   r   rm   rE   rú   rû   )rŒ   r   r™   rE   rú   rE   )rŒ   r   r¹   rE   r™   rE   rú   rû   )rú   rü   );r   Ú
__future__r   r§   r±   Úimportlib.utilÚloggingrp   r*   Ú	threadingÚcontextvarsr   Údataclassesr   r   Úpathlibr   Úproviders.baser   Ú	getLoggerr   r.   r
   r   r   r   r   r   r6   r7   r   r!   ÚLockri   r$   Ú__file__ÚresolveÚparentræ   r2   r;   r@   rH   rX   rd   r>   rj   r|   r~   r”   rk   r¬   rœ   rÓ   rË   rC   rã   rõ   rù   r   r   r    ú<module>r
     s€  ðò õD #ã Û Û Û Û 	Û 
Û Ý "ß (Ý å *à	ˆ×	Ñ	˜8Ó	$€ð )+€	Ð%Ó *Ø€ˆ.Ó ð €ˆ.Ó Ø"€�Ó "Ø59Ð Ð2Ó 9Ø€Ø€ð ÷ð ó ðð ')€Ð#Ó (Ø"�I—N‘NÓ$Ð ñ
 7AÐA`ÐjnÔ6oÐ Ð3Ó oñ 	ˆƒN×ÑÓ×#Ñ#×*Ñ*¨YÑ6Ð9JÑJð ó
<ó(ó0
#óó"`ó6ó*ó*Róóó  óFó>Qð
 JLõ &óR_óDó0ó2+ðr Ð>ðÐ ó
Br   