import asyncio

from terminaluse.lib.core.temporal.activities import get_all_activities
from terminaluse.lib.core.temporal.workers.worker import TerminalUseWorker
from terminaluse.lib.utils.logging import make_logger
from terminaluse.lib.utils.debug import setup_debug_if_enabled
from terminaluse.lib.environment_variables import EnvironmentVariables

from project.workflow import {{ workflow_class }}


environment_variables = EnvironmentVariables.refresh()

logger = make_logger(__name__)


async def main():
    # Setup debug mode if enabled
    setup_debug_if_enabled()

    task_queue_name = environment_variables.TERMINALUSE_WORKFLOW_TASK_QUEUE
    if task_queue_name is None:
        raise ValueError("TERMINALUSE_WORKFLOW_TASK_QUEUE is not set")

    all_activities = get_all_activities() + []  # add your own activities here
    
    # Create a worker with automatic tracing
    worker = TerminalUseWorker(
        task_queue=task_queue_name,
    )

    await worker.run(
        activities=all_activities,
        workflow={{ workflow_class }},
    )

if __name__ == "__main__":
    asyncio.run(main()) 