from __future__ import annotations

from typing import Protocol

from .models import TaskState, TaskSummary


class ControlBackend(Protocol):
    def get_state(self) -> TaskState: ...
    def get_task_state(self, task_ref: str) -> TaskState: ...
    def list_task_summaries(self) -> list[TaskSummary]: ...
    def list_tasks(self) -> str: ...
    def create_task(self, title: str) -> TaskState: ...
    def switch_task(self, task_id: str) -> TaskState: ...
    def continue_task(self, instruction: str | None = None) -> TaskState: ...
    def pause_task(self) -> TaskState: ...
    def add_note(self, text: str, author: str = "telegram") -> TaskState: ...
    def append_chat_entry(self, author: str, text: str) -> TaskState: ...
    def get_desktop_bridge_status(self) -> dict: ...
    def get_desktop_usage(self) -> dict: ...
    def get_desktop_runtime(self, thread_id: str | None = None) -> dict: ...
    def get_desktop_bridge_messages(self, limit: int = 500) -> dict: ...
    def get_desktop_bridge_snapshot(self, limit: int = 500) -> dict: ...
    def get_desktop_thread_snapshot(self, thread_id: str, limit: int = 500) -> dict: ...
    def read_desktop_file(self, path: str, encoding: str | None = None) -> dict: ...
    def list_desktop_threads(self) -> dict: ...
    def list_desktop_projects(self, *, force: bool = False) -> dict: ...
    def select_desktop_thread(self, thread_id: str) -> dict: ...
    def open_desktop_thread(self, thread_id: str) -> dict: ...
    def create_desktop_thread(
        self,
        cwd: str | None = None,
        model: str | None = None,
        effort: str | None = None,
        permission: str | None = None,
    ) -> dict: ...
    def rename_desktop_thread(self, thread_id: str, title: str) -> dict: ...
    def archive_desktop_thread(self, thread_id: str) -> dict: ...
    def unarchive_desktop_thread(self, thread_id: str) -> dict: ...
    def pin_desktop_thread(self, thread_id: str) -> dict: ...
    def unpin_desktop_thread(self, thread_id: str) -> dict: ...
    def fork_desktop_thread(self, thread_id: str, cwd: str | None = None) -> dict: ...
    def open_desktop_project(self, project_id: str) -> dict: ...
    def create_desktop_project(self, cwd: str) -> dict: ...
    def rename_desktop_project(self, cwd: str, title: str) -> dict: ...
    def remove_desktop_project(self, cwd: str) -> dict: ...
    def capture_desktop_screenshot(self) -> dict: ...
    def build_ios_adhoc(
        self,
        thread_id: str | None = None,
        project_id: str | None = None,
        cwd: str | None = None,
        scheme: str | None = None,
        async_mode: bool = False,
    ) -> dict: ...
    def get_ios_adhoc_build_status(self, request_id: str) -> dict: ...
    def restart_desktop_codex(self, thread_id: str | None = None) -> dict: ...
    def restart_desktop_connection(self) -> dict: ...
    def interrupt_desktop_turn(
        self,
        thread_id: str | None = None,
        request_id: str | None = None,
        async_mode: bool = False,
    ) -> dict: ...
    def rollback_desktop_turns(self, thread_id: str | None = None, num_turns: int = 1, async_mode: bool = False) -> dict: ...
    def inject_desktop_items(self, items: list[dict], thread_id: str | None = None) -> dict: ...
    def analyze_desktop_attachment(
        self,
        *,
        filename: str,
        mime_type: str,
        file_base64: str,
        thread_id: str | None = None,
    ) -> dict: ...
    def send_desktop_bridge_message(
        self,
        text: str,
        author: str = "mobile",
        mirrored_to_project: bool = False,
        thread_id: str | None = None,
        model: str | None = None,
        effort: str | None = None,
        permission: str | None = None,
        image_data_urls: list[str] | None = None,
        local_image_paths: list[str] | None = None,
        async_mode: bool = False,
    ) -> dict: ...
    def reply_desktop_bridge_message(self, text: str) -> dict: ...
    def mark_desktop_bridge_message_done(self, message_id: str) -> dict: ...
    def run_command(self, command: str) -> TaskState: ...
    def set_workdir(self, workdir: str) -> TaskState: ...
    def set_title(self, title: str) -> TaskState: ...
    def set_agent_enabled(self, enabled: bool) -> TaskState: ...
    def reject_pending_command(self) -> TaskState: ...
    def confirm_voice_command(self) -> TaskState: ...
    def cancel_voice_command(self) -> TaskState: ...
    def reset_state(self) -> TaskState: ...
    def format_recent_notes(self, limit: int = 5) -> str: ...
    def format_queue(self, limit: int = 10) -> str: ...
    def progress_summary(self) -> str: ...
    def format_command_history(self, limit: int = 5) -> str: ...
    def pending_count(self) -> int: ...
    def approve(self) -> TaskState: ...
