Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
fix(plugins): break import cycle + correct google_apis.json path post-migration
trohitg92740720631e
diff --git a/server/nodes/android/_router.py b/server/nodes/android/_router.pyindex 0452f327..ba39d300 100644--- a/server/nodes/android/_router.py+++ b/server/nodes/android/_router.py@@ -4,7 +4,6 @@ from fastapi import APIRouter, Dependsfrom pydantic import BaseModel, Fieldfrom typing import Dict, Any-from core.container import containerfrom ._dispatcher import AndroidServicefrom core.logging import get_logger@@ -12,6 +11,15 @@ logger = get_logger(__name__)router = APIRouter(prefix="/api/android", tags=["android"])+def get_android_service() -> AndroidService:+ """FastAPI dependency: imports lazily to avoid the+ nodes/android/__init__ -> core.container -> nodes.android._dispatcher+ -> nodes.android.__init__ -> _router import cycle.+ """+ from core.container import container+ return container.android_service()++class AndroidServiceRequest(BaseModel):"""Request model for Android service execution."""service_id: str = Field(..., description="Android service ID (e.g., 'battery', 'network', 'app_launcher')")@@ -24,7 +32,7 @@ class AndroidServiceRequest(BaseModel):@router.post("/execute")async def execute_android_service(request: AndroidServiceRequest,- android_service: AndroidService = Depends(lambda: container.android_service())+ android_service: AndroidService = Depends(get_android_service)):"""Execute an Android system service action.@@ -57,7 +65,7 @@ async def execute_android_service(async def check_device_status(android_host: str = "localhost",android_port: int = 8888,- android_service: AndroidService = Depends(lambda: container.android_service())+ android_service: AndroidService = Depends(get_android_service)):"""Check if Android device API is reachable."""logger.info(@@ -77,7 +85,7 @@ async def check_device_status(@router.get("/services/{service_id}/actions")async def get_service_actions(service_id: str,- android_service: AndroidService = Depends(lambda: container.android_service())+ android_service: AndroidService = Depends(get_android_service)):"""Get available actions for a specific Android service.@@ -105,7 +113,7 @@ async def get_service_actions(async def get_action_parameters(service_id: str,action: str,- android_service: AndroidService = Depends(lambda: container.android_service())+ android_service: AndroidService = Depends(get_android_service)):"""Get default parameters for a specific service action.diff --git a/server/nodes/google/_oauth.py b/server/nodes/google/_oauth.pyindex da8174c3..caa90b15 100644--- a/server/nodes/google/_oauth.py+++ b/server/nodes/google/_oauth.py@@ -53,8 +53,12 @@ from core.logging import get_loggerlogger = get_logger(__name__)-# Load Google API config from JSON-_config_path = Path(__file__).parent.parent / "config" / "google_apis.json"+# Load Google API config from JSON.+# Walk up two parents from server/nodes/google/_oauth.py -> server/, then+# into config/google_apis.json. (Pre-D commit this file lived at+# services/google_oauth.py and used .parent.parent; the migration into+# nodes/google/ shifts the directory depth, so we use parents[2].)+_config_path = Path(__file__).resolve().parents[2] / "config" / "google_apis.json"_google_config: Dict[str, Any] = {}def _load_config() -> Dict[str, Any]:diff --git a/server/nodes/google/_router.py b/server/nodes/google/_router.pyindex 0b22f265..1caeaf93 100644--- a/server/nodes/google/_router.py+++ b/server/nodes/google/_router.py@@ -22,7 +22,6 @@ from typing import Optionalfrom fastapi import APIRouter, Query, Requestfrom fastapi.responses import HTMLResponse, RedirectResponse-from core.container import containerfrom core.logging import get_loggerfrom nodes.google._oauth import GoogleOAuth, get_pending_state@@ -31,12 +30,16 @@ router = APIRouter(prefix="/api/google", tags=["google"])def get_auth_service():- """Get auth service for API key storage."""+ """Get auth service for API key storage. Imports lazily to avoid the+ nodes/<plugin>/__init__ -> core.container -> nodes.android._dispatcher+ -> nodes.android.__init__ -> _router import cycle."""+ from core.container import containerreturn container.auth_service()def get_database():"""Get database for customer connections (non-sensitive data only)."""+ from core.container import containerreturn container.database()diff --git a/server/nodes/twitter/_router.py b/server/nodes/twitter/_router.pyindex 97ced511..9569fafb 100644--- a/server/nodes/twitter/_router.py+++ b/server/nodes/twitter/_router.py@@ -19,7 +19,6 @@ from typing import Optionalfrom fastapi import APIRouter, Query, Requestfrom fastapi.responses import HTMLResponse-from core.container import containerfrom core.logging import get_loggerfrom nodes.twitter._oauth import TwitterOAuth, get_pending_state@@ -28,7 +27,10 @@ router = APIRouter(prefix="/api/twitter", tags=["twitter"])def get_auth_service():- """Get auth service for API key storage."""+ """Get auth service for API key storage. Imports lazily to avoid the+ nodes/<plugin>/__init__ -> core.container -> nodes.android._dispatcher+ -> nodes.android.__init__ -> _router import cycle."""+ from core.container import containerreturn container.auth_service()