# #region AssistantApi [C:5] [TYPE Module] [SEMANTICS assistant, api, package, llm, execution]
# @BRIEF API routes for LLM assistant command parsing and safe execution orchestration.
# @LAYER API
# @RELATION DEPENDS_ON -> [TaskManager]
# @RELATION DEPENDS_ON -> [AssistantMessageRecord]
# @RELATION DEPENDS_ON -> [AssistantConfirmationRecord]
# @RELATION DEPENDS_ON -> [AssistantAuditRecord]
# @INVARIANT  Risky operations are never executed without valid confirmation token.

# ── Tool registry must be imported first to register all @assistant_tool decorators ──
from ._tool_registry import (
    _check_any_permission,
    _has_any_permission,
    assistant_tool,
    dispatch,
    get_catalog,
    get_safe_ops,
    _tools as _registered_tools,
)

# ── Import all tool modules so their @assistant_tool decorators register ──
from . import _tool_capabilities
from . import _tool_task_status
from . import _tool_create_branch
from . import _tool_commit
from . import _tool_deploy
from . import _tool_migration
from . import _tool_backup
from . import _tool_llm_validation
from . import _tool_llm_documentation
from . import _tool_health_summary
from . import _tool_search_dashboards
from . import _tool_list_environments
from . import _tool_maintenance
from . import _tool_llm

# Re-export public API for backward compatibility.
from ._admin_routes import delete_conversation, get_assistant_audit, get_history, list_conversations
from ._command_parser import _parse_command
from ._dataset_review import (
    _load_dataset_review_context,
    _plan_dataset_review_intent,
)
from ._dataset_review_dispatch import _dispatch_dataset_review_intent
from ._dispatch import _async_confirmation_summary, _clarification_text_for_intent, _dispatch_intent
from ._history import (
    _append_history,
    _audit,
    _cleanup_history_ttl,
    _coerce_query_bool,
    _is_conversation_archived,
    _load_confirmation_from_db,
    _persist_audit,
    _persist_confirmation,
    _persist_message,
    _resolve_or_create_conversation,
    _update_confirmation_state,
)
from ._llm_planner import _build_tool_catalog
from ._llm_planner_intent import _authorize_intent, _plan_intent_with_llm
from ._resolvers import (
    _build_task_observability_summary,
    _extract_id,
    _extract_result_deep_links,
    _get_default_environment_id,
    _get_environment_name_by_id,
    _is_production_env,
    _resolve_dashboard_id_by_ref,
    _resolve_dashboard_id_entity,
    _resolve_env_id,
    _resolve_provider_id,
)
from ._routes import cancel_operation, confirm_operation, router, send_message
from ._schemas import (
    _DATASET_REVIEW_OPS,
    ASSISTANT_AUDIT,
    CONFIRMATIONS,
    CONVERSATIONS,
    INTENT_PERMISSION_CHECKS,
    USER_ACTIVE_CONVERSATION,
    AssistantAction,
    AssistantMessageRequest,
    AssistantMessageResponse,
    ConfirmationRecord,
)

# _SAFE_OPS is now derived from the tool registry.
_SAFE_OPS = get_safe_ops()

__all__ = [
    "ASSISTANT_AUDIT",
    "CONFIRMATIONS",
    "CONVERSATIONS",
    "INTENT_PERMISSION_CHECKS",
    "USER_ACTIVE_CONVERSATION",
    "_DATASET_REVIEW_OPS",
    "_SAFE_OPS",
    "_registered_tools",
    "assistant_tool",
    "dispatch",
    "get_catalog",
    "get_safe_ops",
    "AssistantAction",
    "AssistantMessageRequest",
    "AssistantMessageResponse",
    "ConfirmationRecord",
    "_append_history",
    "_async_confirmation_summary",
    "_audit",
    "_authorize_intent",
    "_build_task_observability_summary",
    "_build_tool_catalog",
    "_check_any_permission",
    "_clarification_text_for_intent",
    "_cleanup_history_ttl",
    "_coerce_query_bool",
    "_dispatch_dataset_review_intent",
    "_dispatch_intent",
    "_extract_id",
    "_extract_result_deep_links",
    "_get_default_environment_id",
    "_get_environment_name_by_id",
    "_has_any_permission",
    "_is_conversation_archived",
    "_is_production_env",
    "_load_confirmation_from_db",
    "_load_dataset_review_context",
    "_parse_command",
    "_persist_audit",
    "_persist_confirmation",
    "_persist_message",
    "_plan_dataset_review_intent",
    "_plan_intent_with_llm",
    "_resolve_dashboard_id_by_ref",
    "_resolve_dashboard_id_entity",
    "_resolve_env_id",
    "_resolve_or_create_conversation",
    "_resolve_provider_id",
    "_update_confirmation_state",
    "cancel_operation",
    "confirm_operation",
    "delete_conversation",
    "get_assistant_audit",
    "get_history",
    "list_conversations",
    "router",
    "send_message",
]

# #endregion AssistantApi
