mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-08 13:12:08 +00:00
Move provider adapters (anthropic, bedrock, azure), platform adapters (telegram, slack, discord, feishu, dingtalk, matrix), and terminal backends (modal, daytona) out of core into plugins/ workspace members. Core references them via the plugin registries (get_provider_namespace / get_provider_service / get_tool_provider / get_credential_pool_hook) instead of direct imports. - Provider/platform/terminal adapters relocated under plugins/; pyproject extras reference workspace members; nix variants aggregate per-platform extras. - Anthropic credential discovery + OAuth-masquerade guard live in the plugin's credential_pool_hook; browser-open guarded by _can_open_graphical_browser. - Vercel AI Gateway + Vercel Sandbox removed (upstream deletion); get_bedrock_model_ids removed (replaced by bedrock_model_ids_or_none + discover_bedrock_models). - Terminal backends resolve ModalEnvironment / DaytonaEnvironment lazily from the plugin registry. - uv.lock regenerated against the pluginified workspace. Plugin test suites updated for the relocation: imports point at hermes_agent_<plat>.adapter, caplog logger-name filters and monkeypatch targets use the new module paths, and credential/rollback tests patch registries.get_provider_service rather than the removed agent.*_adapter modules. Verified: zero dead imports of relocated modules in core (import smoke test + rename-map grep); nix develop succeeds; targeted plugin suites green (bedrock, anthropic-auxiliary, matrix, dingtalk, feishu, credential_pool, switch_model_rollback). Remaining full-suite failures are pre-existing on the pre-merge tree (telegram setUpModule __code__) or environmental (voice/media/ PTY/network-dependent), not introduced here.
69 lines
2.6 KiB
Python
69 lines
2.6 KiB
Python
"""Shared fixtures for tests/tools/ web-provider tests.
|
|
|
|
Per-file subprocess isolation means each test file gets a fresh interpreter,
|
|
so module-level state (like the web-search-provider registry) is empty when
|
|
a file starts. The ``web_registry_populated`` fixture registers all bundled
|
|
providers before each test and resets the registry afterwards — tests that
|
|
depend on the registry being populated should use it explicitly or via
|
|
``@pytest.mark.usefixtures("web_registry_populated")``.
|
|
"""
|
|
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
|
|
def register_all_web_providers():
|
|
"""Register all bundled web-search providers into the global registry.
|
|
|
|
This is the single source of truth for the provider list used by
|
|
test classes that need the registry populated for dispatch checks.
|
|
"""
|
|
from agent.web_search_registry import register_provider, _reset_for_tests
|
|
from plugins.web.brave_free.provider import BraveFreeWebSearchProvider
|
|
from plugins.web.ddgs.provider import DDGSWebSearchProvider
|
|
from plugins.web.exa.provider import ExaWebSearchProvider
|
|
from plugins.web.firecrawl.provider import FirecrawlWebSearchProvider
|
|
from plugins.web.parallel.provider import ParallelWebSearchProvider
|
|
from plugins.web.searxng.provider import SearXNGWebSearchProvider
|
|
from plugins.web.tavily.provider import TavilyWebSearchProvider
|
|
from plugins.web.xai.provider import XAIWebSearchProvider
|
|
|
|
_reset_for_tests()
|
|
for cls in (
|
|
BraveFreeWebSearchProvider,
|
|
DDGSWebSearchProvider,
|
|
ExaWebSearchProvider,
|
|
FirecrawlWebSearchProvider,
|
|
ParallelWebSearchProvider,
|
|
SearXNGWebSearchProvider,
|
|
TavilyWebSearchProvider,
|
|
XAIWebSearchProvider,
|
|
):
|
|
register_provider(cls())
|
|
|
|
|
|
@pytest.fixture
|
|
def web_registry_populated():
|
|
"""Populate the web-search-provider registry for one test, then reset."""
|
|
register_all_web_providers()
|
|
yield
|
|
from agent.web_search_registry import _reset_for_tests
|
|
_reset_for_tests()
|
|
|
|
|
|
@pytest.fixture
|
|
def disable_lazy_stt_install():
|
|
"""Disarm the runtime lazy-install probe so static ``_HAS_FASTER_WHISPER``
|
|
patches accurately simulate 'faster-whisper not installed'.
|
|
|
|
Without this, ``_try_lazy_install_stt()`` calls
|
|
``importlib.util.find_spec("faster_whisper")``, which returns truthy
|
|
whenever the package is installed in the dev / CI environment —
|
|
defeating the test's ``_HAS_FASTER_WHISPER=False`` patch.
|
|
|
|
Opt in at module scope with
|
|
``pytestmark = pytest.mark.usefixtures("disable_lazy_stt_install")``.
|
|
"""
|
|
with patch("hermes_agent_stt.transcription_tools._try_lazy_install_stt", return_value=False):
|
|
yield
|