from .clock import Clock
from .object_store import ObjectStore
from autogen import AssistantAgent

class App:
    clock: Clock
    store: ObjectStore
    def __init__(self, clock: Clock, store: ObjectStore):
        self.clock = clock
        self.store = store
        
    def train_agent(self, assistant: AssistantAgent):
        functions = self.get_functions()
        for function, description in functions:
            name = self.get_full_method_name(function.__name__)
            assistant.register_for_llm(name=name, description=description)(function)
    
    
    def has_trained(self, agent: AssistantAgent):
        functions = self.get_functions()
        for function, _ in functions:
            name = self.get_full_method_name(function.__name__)
            if name in agent.function_map:
                return True
        
    
    def get_functions(self):
        raise NotImplementedError()
    
    def get_full_method_name(self, method_name: str) -> str:
        return self.__class__.__name__ + "_" + method_name
    
    def register_executor(self, executor: AssistantAgent):
        functions = self.get_functions()
        for function, _ in functions:
            name = self.get_full_method_name(function.__name__)
            # Register the function to execute
            executor.register_for_execution(name=name)(function)
        
    
    
    