import asyncio import os import sys import logging from temporalio.client import Client from temporalio.worker import Worker # Configure basic logging so we can see output in Kubernetes logs logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") logger = logging.getLogger(__name__) from curaflow_agent.workflows import ClinicalIntakeWorkflow, LabResultWatcherWorkflow, AppointmentBookingWorkflow from curaflow_agent.activities import ( structure_note_activity, generate_billing_codes_activity, analyze_lab_anomaly_activity, send_alert_activity, save_clinical_record_activity, parse_booking_intent_activity, send_whatsapp_reply_activity, save_appointment_activity ) async def main(): temporal_url = os.environ.get("TEMPORAL_URL", "temporal-frontend.ai-core.svc.cluster.local:7233") temporal_namespace = os.environ.get("TEMPORAL_NAMESPACE", "default") task_queue = os.environ.get("CURAFLOW_TASK_QUEUE", "curaflow-tasks") logger.info(f"Connecting to Temporal cluster at {temporal_url} (Namespace: {temporal_namespace})") try: client = await Client.connect(temporal_url, namespace=temporal_namespace) logger.info("Successfully connected to Temporal!") except Exception as e: logger.error(f"Failed to connect to Temporal: {e}") sys.exit(1) worker = Worker( client, task_queue=task_queue, workflows=[ClinicalIntakeWorkflow, LabResultWatcherWorkflow, AppointmentBookingWorkflow], activities=[ structure_note_activity, generate_billing_codes_activity, analyze_lab_anomaly_activity, send_alert_activity, save_clinical_record_activity, parse_booking_intent_activity, send_whatsapp_reply_activity, save_appointment_activity ], ) logger.info(f"Starting CuraFlow agent worker on queue '{task_queue}'...") await worker.run() if __name__ == "__main__": asyncio.run(main()) # Trigger CI/CD # Trigger CI/CD again