"""Project ownership, knowledge validation and server-controlled run policy.""" from __future__ import annotations import asyncio import json import re from copy import deepcopy from fastapi import HTTPException, Request from app.gateway.auth.disabled_mode import is_auth_disabled from app.gateway.deps import get_agent_store, get_checkpointer, get_optional_user_from_request from deerflow.agents.analysis_project import ( SOLUTION_INTENT_BLOCK_LABEL, SOLUTION_REQUIREMENTS_CONFIRMATION_TOKEN, SOLUTION_REQUIREMENTS_FORCE_TOKEN, SOLUTION_REQUIREMENTS_READY_MARKER, SOLUTION_TEMPLATE_ID, ) from deerflow.config.agents_config import load_agent_config, validate_agent_id from deerflow.runtime import serialize_channel_values from deerflow.runtime.user_context import get_effective_user_id _SOLUTION_INTENT_BLOCK_PATTERN = re.compile( rf"", ) _SOLUTION_INTENT_BLOCK_OPEN_PATTERN = re.compile(rf"