| 1 | from __future__ import annotations |
| 2 | |
| 3 | from helpers.api import ApiHandler, Request |
| 4 | from helpers.plugins import get_plugin_config |
| 5 | |
| 6 | from plugins._orchestrator.helpers.registry import adapter_config, list_adapters |
| 7 | |
| 8 | PLUGIN_NAME = "_orchestrator" |
| 9 | |
| 10 | |
| 11 | class Status(ApiHandler): |
| 12 | async def process(self, input: dict, request: Request) -> dict: |
| 13 | plugin_config = get_plugin_config(PLUGIN_NAME) or {} |
| 14 | agents = [] |
| 15 | for adapter in list_adapters(): |
| 16 | cfg = adapter_config(adapter.id, plugin_config) |
| 17 | try: |
| 18 | auth = adapter.auth_status(cfg) |
| 19 | except Exception as exc: |
| 20 | auth = { |
| 21 | "connected": False, |
| 22 | "mode": "", |
| 23 | "auth_path": "", |
| 24 | "error": str(exc), |
| 25 | } |
| 26 | agents.append( |
| 27 | { |
| 28 | "id": adapter.id, |
| 29 | "title": adapter.title, |
| 30 | "description": adapter.description, |
| 31 | "binary": adapter.resolve_binary(cfg), |
| 32 | "installed": adapter.is_installed(cfg), |
| 33 | "install_hint": adapter.install_hint, |
| 34 | "supports_device_login": adapter.supports_device_login(), |
| 35 | "can_disconnect": adapter.can_disconnect(cfg), |
| 36 | "auth": auth, |
| 37 | } |
| 38 | ) |
| 39 | return {"ok": True, "agents": agents} |