from __future__ import annotations

import logging

from app.core.postgres.erp_client import ErpDatabaseClient
from app.core.settings import get_settings
from app.modules.financial.application.four_pillars_service import FourPillarsService
from app.modules.agents.application.llm_client import LLMClient

from .history import DeepSeekHistoryMixin
from .mission_runner import DeepSeekMissionRunnerMixin
from .tools_audit import DeepSeekToolsAuditMixin
from .tools_data import DeepSeekToolsDataMixin

logger = logging.getLogger("dscons.deepseek_harness")


class DeepSeekHarnessService(
    DeepSeekToolsAuditMixin,
    DeepSeekToolsDataMixin,
    DeepSeekMissionRunnerMixin,
    DeepSeekHistoryMixin,
):
    """Core Agentic Harness Engine leveraging DeepSeek-R1 / Stealth OX for Multi-Agent Task Orchestration."""

    def __init__(
        self,
        postgres_client: ErpDatabaseClient | None = None,
        four_pillars_service: FourPillarsService | None = None,
        llm_client: LLMClient | None = None,
    ) -> None:
        self.settings = get_settings()
        self.postgres_client = postgres_client or ErpDatabaseClient()
        self.four_pillars_service = four_pillars_service or FourPillarsService(
            self.postgres_client
        )
        self.llm_client = llm_client or LLMClient(self.settings)
