# Generated by Django 4.2.24 on 2025-12-14 18:08

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


class Migration(migrations.Migration):

    dependencies = [
        ("agents", "0006_agent_corpus_actions"),
        ("corpuses", "0028_fix_grant_permission_to_corpus_creators"),
    ]

    operations = [
        migrations.RemoveConstraint(
            model_name="corpusaction",
            name="exactly_one_of_fieldset_or_analyzer",
        ),
        migrations.AddField(
            model_name="corpusaction",
            name="agent_config",
            field=models.ForeignKey(
                blank=True,
                help_text="Agent configuration to use for this action",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="corpus_actions",
                to="agents.agentconfiguration",
            ),
        ),
        migrations.AddField(
            model_name="corpusaction",
            name="agent_prompt",
            field=models.TextField(
                blank=True,
                default="",
                help_text="Task-specific prompt for the agent (e.g., 'Summarize this document')",
            ),
        ),
        migrations.AddField(
            model_name="corpusaction",
            name="pre_authorized_tools",
            field=models.JSONField(
                blank=True,
                default=list,
                help_text="Tools pre-authorized to run without approval. If empty, uses agent_config.available_tools",
            ),
        ),
        migrations.AddConstraint(
            model_name="corpusaction",
            constraint=models.CheckConstraint(
                check=models.Q(
                    models.Q(
                        ("agent_config__isnull", True),
                        ("analyzer__isnull", True),
                        ("fieldset__isnull", False),
                    ),
                    models.Q(
                        ("agent_config__isnull", True),
                        ("analyzer__isnull", False),
                        ("fieldset__isnull", True),
                    ),
                    models.Q(
                        ("agent_config__isnull", False),
                        ("analyzer__isnull", True),
                        ("fieldset__isnull", True),
                    ),
                    _connector="OR",
                ),
                name="exactly_one_of_fieldset_analyzer_or_agent",
            ),
        ),
    ]
