"""Backend interface used by compactor.py.""" from __future__ import annotations from typing import Protocol class CompressionBackend(Protocol): def summarise(self, system_prompt: str, conversation_text: str) -> str: ... def build_backend(cfg: dict) -> CompressionBackend: backend_cfg = cfg.get("backend") or {} btype = backend_cfg.get("type", "openai_compat") if btype == "openai_compat": from .openai_compat import OpenAICompatibleBackend return OpenAICompatibleBackend(backend_cfg) if btype == "anthropic_native": from .anthropic_native import AnthropicNativeBackend return AnthropicNativeBackend(backend_cfg) raise ValueError(f"Unsupported backend.type: {btype!r}")