From 5d6c2616231c7ed9213ae80e9d2314e36d6d46a1 Mon Sep 17 00:00:00 2001 From: Mourad Farouk Date: Wed, 7 Oct 2026 12:26:06 +0300 Subject: [PATCH] fix(honcho): resolve externally installed Honcho provider --- dashboard/plugin_api.py | 14 ++++++++++++-- tests/test_plugin_api.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/dashboard/plugin_api.py b/dashboard/plugin_api.py index 1bb1b5c..5f4b366 100644 --- a/dashboard/plugin_api.py +++ b/dashboard/plugin_api.py @@ -896,7 +896,8 @@ def _honcho_config_payload(config: Optional[Dict[str, Any]] = None) -> Dict[str, "_import_error": None, } try: - from plugins.memory.honcho.client import HonchoClientConfig, resolve_config_path # type: ignore + _honcho_client = _honcho_client_module() + HonchoClientConfig, resolve_config_path = _honcho_client.HonchoClientConfig, _honcho_client.resolve_config_path cfg = HonchoClientConfig.from_global_config() path = resolve_config_path() @@ -1102,7 +1103,7 @@ def _honcho_payload( base["error"] = "Honcho API key or base URL is not configured. Run 'hermes honcho setup' or set HONCHO_API_KEY / HONCHO_BASE_URL." return base try: - from plugins.memory.honcho.client import get_honcho_client # type: ignore + get_honcho_client = _honcho_client_module().get_honcho_client client = get_honcho_client(cfg) user_peer_id = str(honcho_cfg["user_peer"] or "user") @@ -2009,6 +2010,15 @@ async def fetch_contents(client: Any) -> Dict[str, Any]: return base +def _honcho_client_module() -> Any: + """Honcho client module from whichever copy is installed (core or catalog plugin).""" + memory = importlib.import_module("plugins.memory") + resolver = getattr(memory, "import_provider_module", None) + if callable(resolver): + return resolver("honcho", "client") + return importlib.import_module("plugins.memory.honcho.client") + + def _make_hindsight_provider() -> Any: memory = importlib.import_module("plugins.memory") resolver = getattr(memory, "import_provider_module", None) diff --git a/tests/test_plugin_api.py b/tests/test_plugin_api.py index 6097d89..f44ee0e 100644 --- a/tests/test_plugin_api.py +++ b/tests/test_plugin_api.py @@ -494,6 +494,38 @@ def test_honcho_payload_hides_api_key_and_fetches_peer_context(monkeypatch, tmp_ assert ("context", "hermes", {"target": "hermes", "search_query": "xraysight", "search_top_k": 5}) in calls +def test_honcho_payload_resolves_externally_installed_provider(monkeypatch, tmp_path): + """Honcho installed as a catalog plugin is not importable as plugins.memory.honcho. + + Hermes loads it under a synthetic namespace and exposes it through + plugins.memory.import_provider_module, the same resolver used for Hindsight. + """ + (tmp_path / "config.yaml").write_text("memory:\n provider: honcho\n", encoding="utf-8") + (tmp_path / "honcho.json").write_text(json.dumps({"apiKey": "honcho-secret"}), encoding="utf-8") + calls = [] + install_fake_honcho_client(monkeypatch, tmp_path, calls) + external_client = sys.modules["plugins.memory.honcho.client"] + external_client.__name__ = "_hermes_user_memory.honcho__source_test.client" + monkeypatch.delitem(sys.modules, "plugins.memory.honcho") + monkeypatch.delitem(sys.modules, "plugins.memory.honcho.client") + resolved = [] + + def import_provider_module(name, submodule=None): + resolved.append((name, submodule)) + return external_client + + sys.modules["plugins.memory"].import_provider_module = import_provider_module + + module = load_plugin_api(monkeypatch, tmp_path) + payload = module._honcho_payload(limit=5) + + assert payload["error"] is None + assert payload["provider_configured"] is True + assert payload["user"]["card"] == ["Card fact for xraysight"] + assert ("honcho", "client") in resolved + assert "honcho-secret" not in json.dumps(payload) + + def test_honcho_snapshot_and_status_include_provider_without_secrets(monkeypatch, tmp_path): (tmp_path / "config.yaml").write_text("memory:\n provider: honcho\n", encoding="utf-8") (tmp_path / "honcho.json").write_text(json.dumps({"apiKey": "honcho-secret"}), encoding="utf-8")