# Generated by Django 6.0 on 2026-03-13 13:02

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


class Migration(migrations.Migration):

    dependencies = [
        ('api', '0318_merge_20260312_1408'),
    ]

    operations = [
        migrations.CreateModel(
            name='PersistentAgentHumanInputRequest',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('question', models.TextField()),
                ('options_json', models.JSONField(blank=True, default=list)),
                ('input_mode', models.CharField(choices=[('options_plus_text', 'Options plus text'), ('free_text_only', 'Free text only')], default='free_text_only', max_length=32)),
                ('recipient_channel', models.CharField(blank=True, choices=[('email', 'Email'), ('sms', 'SMS'), ('slack', 'Slack'), ('discord', 'Discord'), ('web', 'Web Chat'), ('other', 'Other')], help_text='Explicit recipient channel when the request targets a specific identity.', max_length=32)),
                ('recipient_address', models.CharField(blank=True, help_text='Normalized explicit recipient address when set.', max_length=512)),
                ('status', models.CharField(choices=[('pending', 'Pending'), ('answered', 'Answered'), ('cancelled', 'Cancelled'), ('expired', 'Expired')], db_index=True, default='pending', max_length=16)),
                ('requested_via_channel', models.CharField(choices=[('email', 'Email'), ('sms', 'SMS'), ('slack', 'Slack'), ('discord', 'Discord'), ('web', 'Web Chat'), ('other', 'Other')], max_length=32)),
                ('selected_option_key', models.CharField(blank=True, max_length=128)),
                ('selected_option_title', models.CharField(blank=True, max_length=255)),
                ('free_text', models.TextField(blank=True)),
                ('raw_reply_text', models.TextField(blank=True)),
                ('resolution_source', models.CharField(blank=True, choices=[('option_number', 'Option number'), ('option_title', 'Option title'), ('free_text', 'Free text'), ('direct', 'Direct'), ('llm_extraction', 'LLM extraction')], max_length=32)),
                ('resolved_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.RenameIndex(
            model_name='persistentagenttemplatelike',
            new_name='api_persist_templat_d6c788_idx',
            old_name='api_persist_template_2e8e2c_idx',
        ),
        migrations.RenameIndex(
            model_name='persistentagenttemplatelike',
            new_name='api_persist_created_617110_idx',
            old_name='api_persist_created_9fc412_idx',
        ),
        migrations.AddField(
            model_name='persistentagenthumaninputrequest',
            name='agent',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='human_input_requests', to='api.persistentagent'),
        ),
        migrations.AddField(
            model_name='persistentagenthumaninputrequest',
            name='conversation',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='human_input_requests', to='api.persistentagentconversation'),
        ),
        migrations.AddField(
            model_name='persistentagenthumaninputrequest',
            name='originating_step',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='human_input_requests', to='api.persistentagentstep'),
        ),
        migrations.AddField(
            model_name='persistentagenthumaninputrequest',
            name='raw_reply_message',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='human_input_requests_resolved', to='api.persistentagentmessage'),
        ),
        migrations.AddField(
            model_name='persistentagenthumaninputrequest',
            name='requested_message',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='human_input_requests_sent', to='api.persistentagentmessage'),
        ),
        migrations.AddIndex(
            model_name='persistentagenthumaninputrequest',
            index=models.Index(fields=['agent', 'status', '-created_at'], name='pa_hir_agent_status_idx'),
        ),
        migrations.AddIndex(
            model_name='persistentagenthumaninputrequest',
            index=models.Index(fields=['conversation', 'status', '-created_at'], name='pa_hir_conv_status_idx'),
        ),
    ]
