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.
72 lines
2.3 KiB
Python
72 lines
2.3 KiB
Python
"""Shared fixtures for azure-foundry plugin tests.
|
|
|
|
Registers the azure plugin in the singleton registry before each test.
|
|
"""
|
|
import pytest
|
|
|
|
|
|
class _FullCtx:
|
|
"""Plugin context that wires up all registry hooks."""
|
|
|
|
def register_provider_services(self, name, services):
|
|
from agent.plugin_registries import registries
|
|
registries.register_provider_services(name, services)
|
|
|
|
def register_provider_resolver(self, name, resolver):
|
|
from agent.plugin_registries import registries
|
|
registries.register_provider_resolver(name, resolver)
|
|
|
|
def register_credential_pool_hook(self, name, hook):
|
|
from agent.plugin_registries import registries
|
|
registries.register_credential_pool_hook(name, hook)
|
|
|
|
def register_transport(self, api_mode, transport_cls):
|
|
from agent.plugin_registries import registries
|
|
registries._transports[api_mode] = transport_cls
|
|
|
|
def register_pricing_provider(self, name, entries):
|
|
from agent.plugin_registries import registries
|
|
registries.register_pricing_provider(name, entries)
|
|
|
|
def register_provider_overlay(self, entry):
|
|
from agent.plugin_registries import registries
|
|
registries.register_provider_overlay(entry)
|
|
|
|
def __getattr__(self, name):
|
|
if name.startswith("register_"):
|
|
return lambda *a, **kw: None
|
|
raise AttributeError(name)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _register_azure_plugin():
|
|
"""Register the real azure plugin for the duration of each test."""
|
|
from agent.plugin_registries import registries
|
|
|
|
_prev_services = dict(registries._provider_services)
|
|
_prev_resolvers = dict(registries._provider_resolvers)
|
|
_prev_cph = dict(registries._credential_pool_hooks)
|
|
|
|
ctx = _FullCtx()
|
|
try:
|
|
from hermes_agent_azure import register as _reg
|
|
_reg(ctx)
|
|
except ImportError:
|
|
pass
|
|
# azure-foundry tests for Anthropic Messages mode need the anthropic plugin too
|
|
try:
|
|
from hermes_agent_anthropic import register as _anthro_reg
|
|
_anthro_reg(ctx)
|
|
except ImportError:
|
|
pass
|
|
|
|
yield
|
|
|
|
for d, prev in [
|
|
(registries._provider_services, _prev_services),
|
|
(registries._provider_resolvers, _prev_resolvers),
|
|
(registries._credential_pool_hooks, _prev_cph),
|
|
]:
|
|
d.clear()
|
|
d.update(prev)
|