from pathlib import Path
from typing import Literal

from pydantic import BaseModel

from deeppresenter.agents.agent import Agent, AgentEnv
from deeppresenter.utils.config import DeepPresenterConfig
from deeppresenter.utils.constants import MAX_SUBAGENT_TURNS
from deeppresenter.utils.typings import InputRequest


class SubTask(BaseModel):
    short: str
    task: str
    context: str
    handsoff: str


class SubAgent(Agent):
    def __init__(
        self,
        *args,
        **kwargs,
    ):
        super().__init__(*args, **kwargs)
        self.turns = 0

    @classmethod
    def delegate(cls, agent_env: AgentEnv):
        async def delegate(short: str, task: str, context: str, handsoff: str):
            # agent = cls(name=)
            # await agent.loop(short, task, context, handsoff)
            return

        return delegate

    async def loop(self, short: str, task: str, context: str, handsoff: str):
        (self.workspace / "slides").mkdir(exist_ok=True)
        while True:
            agent_message = await self.action(
                markdown_file=markdown_file, prompt=req.designagent_prompt
            )
            yield agent_message
            outcome = await self.execute(self.chat_history[-1].tool_calls)
            if isinstance(outcome, list):
                for item in outcome:
                    yield item
            else:
                break

        yield outcome
