from __future__ import annotations

from dataclasses import dataclass, field
from typing import Callable, Dict, List


@dataclass
class ToolSpec:
    name: str
    description: str
    handler: Callable[..., dict]


@dataclass
class SubagentSpec:
    name: str
    role: str
    tools: List[ToolSpec] = field(default_factory=list)


def _todo_handler(**kwargs) -> dict:
    return {
        "status": "todo",
        "message": "Replace scaffold handler with real model/tool integration",
        "input": kwargs,
    }


def build_subagent_registry() -> Dict[str, SubagentSpec]:
    """
    LangChain-ready registry for AURORA internal subagents.
    This module intentionally keeps handlers as stubs so deployments remain safe
    until concrete model adapters are wired.
    """

    return {
        "clarity": SubagentSpec(
            name="Clarity",
            role="Video Enhancement Agent",
            tools=[
                ToolSpec("denoise_video", "Denoise video frames (FastDVDnet)", _todo_handler),
                ToolSpec("upscale_video", "Super-resolution (Real-ESRGAN)", _todo_handler),
                ToolSpec("interpolate_frames", "Frame interpolation (RIFE)", _todo_handler),
                ToolSpec("stabilize_video", "Video stabilization", _todo_handler),
            ],
        ),
        "vera": SubagentSpec(
            name="Vera",
            role="Face Restoration Agent",
            tools=[
                ToolSpec("detect_faces", "Face detection and quality checks", _todo_handler),
                ToolSpec("enhance_face", "Restore faces with GFPGAN", _todo_handler),
                ToolSpec("enhance_face_codeformer", "Alternative face restoration", _todo_handler),
            ],
        ),
        "echo": SubagentSpec(
            name="Echo",
            role="Audio Forensics Agent",
            tools=[
                ToolSpec("extract_audio_from_video", "Extract audio track", _todo_handler),
                ToolSpec("denoise_audio", "Audio denoise pipeline", _todo_handler),
                ToolSpec("enhance_speech", "Improve speech intelligibility", _todo_handler),
                ToolSpec("detect_deepfake_audio", "Deepfake audio heuristics", _todo_handler),
            ],
        ),
        "pixis": SubagentSpec(
            name="Pixis",
            role="Photo Analysis Agent",
            tools=[
                ToolSpec("denoise_photo", "Photo denoise", _todo_handler),
                ToolSpec("upscale_photo", "Photo super-resolution", _todo_handler),
                ToolSpec("restore_old_photo", "Legacy photo restoration", _todo_handler),
                ToolSpec("analyze_exif", "EXIF integrity analysis", _todo_handler),
            ],
        ),
        "plate_detect": SubagentSpec(
            name="PlateDetect",
            role="License Plate Detection & OCR Agent",
            tools=[
                ToolSpec("detect_plates", "YOLO-v9 license plate detection", _todo_handler),
                ToolSpec("ocr_plates", "OCR plate text (fast-plate-ocr)", _todo_handler),
                ToolSpec("enhance_plate_roi", "Real-ESRGAN plate region upscale", _todo_handler),
                ToolSpec("export_plate_report", "Export plate detections JSON", _todo_handler),
            ],
        ),
        "kore": SubagentSpec(
            name="Kore",
            role="Forensic Verifier Agent",
            tools=[
                ToolSpec("generate_chain_of_custody", "Generate forensic custody JSON", _todo_handler),
                ToolSpec("sign_document", "Apply cryptographic signature", _todo_handler),
                ToolSpec("integrate_with_amped", "Amped FIVE integration point", _todo_handler),
                ToolSpec("integrate_with_cognitech", "Cognitech integration point", _todo_handler),
            ],
        ),
    }
