| 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, get_adapter |
| 7 | |
| 8 | PLUGIN_NAME = "_orchestrator" |
| 9 | |
| 10 | |
| 11 | class Disconnect(ApiHandler): |
| 12 | async def process(self, input: dict, request: Request) -> dict: |
| 13 | agent_id = str(input.get("agent_id") or "codex") |
| 14 | try: |
| 15 | adapter = get_adapter(agent_id) |
| 16 | plugin_config = get_plugin_config(PLUGIN_NAME) or {} |
| 17 | cfg = adapter_config(adapter.id, plugin_config) |
| 18 | result = adapter.disconnect(cfg) |
| 19 | return {"ok": True, "agent_id": adapter.id, **result} |
| 20 | except Exception as exc: |
| 21 | return {"ok": False, "agent_id": agent_id, "error": str(exc)} |