diff --git a/plugins/platforms/whatsapp/adapter.py b/plugins/platforms/whatsapp/adapter.py index 56ce666b70..7f16158d4c 100644 --- a/plugins/platforms/whatsapp/adapter.py +++ b/plugins/platforms/whatsapp/adapter.py @@ -600,6 +600,11 @@ class WhatsAppAdapter(WhatsAppBehaviorMixin, BasePlatformAdapter): ) if install_result.returncode != 0: print(f"[{self.name}] npm install failed: {install_result.stderr}") + self._set_fatal_error( + "whatsapp_npm_install_failed", + f"WhatsApp bridge npm install failed. Run `cd {bridge_dir} && {_npm_bin} install` manually, then restart `hermes gateway`.", + retryable=False, + ) return False print(f"[{self.name}] Dependencies installed") if _pkg_hash: @@ -609,6 +614,11 @@ class WhatsAppAdapter(WhatsAppBehaviorMixin, BasePlatformAdapter): pass # Stamp is an optimization; install still succeeded except Exception as e: print(f"[{self.name}] Failed to install dependencies: {e}") + self._set_fatal_error( + "whatsapp_npm_install_failed", + f"WhatsApp bridge npm install failed ({e}). Run `cd {bridge_dir} && {_npm_bin} install` manually, then restart `hermes gateway`.", + retryable=False, + ) return False # Ensure session directory exists diff --git a/tests/gateway/test_whatsapp_connect.py b/tests/gateway/test_whatsapp_connect.py index 12ee1e00c2..8ce6687b81 100644 --- a/tests/gateway/test_whatsapp_connect.py +++ b/tests/gateway/test_whatsapp_connect.py @@ -216,6 +216,9 @@ class TestConnectCleanup: result = await adapter.connect() assert result is False + assert adapter.fatal_error_code == "whatsapp_npm_install_failed" + assert adapter.fatal_error_retryable is False + assert "npm install failed" in (adapter.fatal_error_message or "") mock_release.assert_called_once_with("whatsapp-session", str(adapter._session_path)) assert adapter._platform_lock_identity is None