import django.db.models.deletion
import uuid
from django.conf import settings
from django.db import migrations, models

class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('accounts', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='AgentConfig',
            fields=[
                ('id', models.BigAutoField(primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, verbose_name='UUID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('name', models.CharField(max_length=255, verbose_name='Agent Name')),
                ('agent_type', models.CharField(choices=[('curriculum', 'Curriculum Agent (CA)'), ('knowledge', 'Knowledge Agent (KA)'), ('assessment', 'Assessment Agent (AA)'), ('monitor', 'Progress Monitor Agent (PMA)')], max_length=40, verbose_name='Agent Type')),
                ('llm_config', models.JSONField(blank=True, default=dict, null=True, verbose_name='LLM Configuration')),
                ('system_prompt', models.TextField(blank=True, default='', verbose_name='System Prompt')),
                ('tool_permissions', models.JSONField(blank=True, default=list, null=True, verbose_name='Tool Permissions')),
                ('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='agent_configs', to='accounts.organization', verbose_name='Organization')),
                ('role', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='agent_configs', to='accounts.role', verbose_name='Role')),
            ],
            options={
                'verbose_name': 'Agent Config',
                'verbose_name_plural': 'Agent Configs',
            },
        ),
        migrations.CreateModel(
            name='OnboardingFlow',
            fields=[
                ('id', models.BigAutoField(primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, verbose_name='UUID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('title', models.CharField(max_length=255, verbose_name='Flow Title')),
                ('structure', models.JSONField(blank=True, default=list, verbose_name='Flow Structure')),
                ('is_active', models.BooleanField(default=True, verbose_name='Is Active')),
                ('role', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='flows', to='accounts.role', verbose_name='Role')),
            ],
            options={
                'verbose_name': 'Onboarding Flow',
                'verbose_name_plural': 'Onboarding Flows',
            },
        ),
        migrations.CreateModel(
            name='OnboardingSession',
            fields=[
                ('id', models.BigAutoField(primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, verbose_name='UUID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('status', models.CharField(choices=[('active', 'Active'), ('completed', 'Completed'), ('paused', 'Paused')], default='active', max_length=20, verbose_name='Session Status')),
                ('state', models.JSONField(blank=True, default=dict, verbose_name='Session State')),
                ('active_configs', models.JSONField(default=dict, verbose_name='Active Configs')),
                ('completed_at', models.DateTimeField(blank=True, null=True, verbose_name='Completed At')),
                ('role', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='onboarding_sessions', to='accounts.role', verbose_name='Target Role')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='onboarding_sessions', to=settings.AUTH_USER_MODEL, verbose_name='User')),
            ],
            options={
                'verbose_name': 'Onboarding Session',
                'verbose_name_plural': 'Onboarding Sessions',
            },
        ),
        migrations.CreateModel(
            name='AgentInteractionLog',
            fields=[
                ('id', models.BigAutoField(primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, verbose_name='UUID')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('sender_type', models.CharField(choices=[('system', 'System'), ('ai', 'AI'), ('user', 'User'), ('tool', 'Tool Output')], max_length=20, verbose_name='Sender Type')),
                ('content', models.TextField(verbose_name='Message Content')),
                ('tool_call_metadata', models.JSONField(blank=True, default=dict, verbose_name='Tool Call Metadata')),
                ('agent_config', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='onboarding.agentconfig', verbose_name='Agent Config')),
                ('session', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='logs', to='onboarding.onboardingsession', verbose_name='Session')),
            ],
            options={
                'verbose_name': 'Interaction Log',
                'verbose_name_plural': 'Interaction Logs',
                'ordering': ['created_at'],
            },
        ),
    ]
