"""Auto-generated by adk-fluent generator. Manual edits will be overwritten."""

from __future__ import annotations

from collections import defaultdict
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, Self

from google.adk.artifacts.base_artifact_service import BaseArtifactService as _ADK_BaseArtifactService
from google.adk.artifacts.file_artifact_service import FileArtifactService as _ADK_FileArtifactService
from google.adk.artifacts.gcs_artifact_service import GcsArtifactService as _ADK_GcsArtifactService
from google.adk.artifacts.in_memory_artifact_service import InMemoryArtifactService as _ADK_InMemoryArtifactService
from google.adk.cli.utils.local_storage import PerAgentDatabaseSessionService as _ADK_PerAgentDatabaseSessionService
from google.adk.memory.base_memory_service import BaseMemoryService as _ADK_BaseMemoryService
from google.adk.memory.in_memory_memory_service import InMemoryMemoryService as _ADK_InMemoryMemoryService
from google.adk.memory.vertex_ai_memory_bank_service import VertexAiMemoryBankService as _ADK_VertexAiMemoryBankService
from google.adk.memory.vertex_ai_rag_memory_service import VertexAiRagMemoryService as _ADK_VertexAiRagMemoryService
from google.adk.sessions.base_session_service import BaseSessionService as _ADK_BaseSessionService
from google.adk.sessions.database_session_service import DatabaseSessionService as _ADK_DatabaseSessionService
from google.adk.sessions.in_memory_session_service import InMemorySessionService as _ADK_InMemorySessionService
from google.adk.sessions.sqlite_session_service import SqliteSessionService as _ADK_SqliteSessionService
from google.adk.sessions.vertex_ai_session_service import VertexAiSessionService as _ADK_VertexAiSessionService
from google.adk.tools._forwarding_artifact_service import ForwardingArtifactService as _ADK_ForwardingArtifactService

from adk_fluent._base import BuilderBase

if TYPE_CHECKING:
    from collections.abc import Mapping


class BaseArtifactService(BuilderBase):
    """Abstract base class for artifact services."""

    _ALIASES: dict[str, str] = {}
    _CALLBACK_ALIASES: dict[str, str] = {}
    _ADDITIVE_FIELDS: set[str] = set()
    _KNOWN_PARAMS: set[str] | None = set()

    def __init__(self, args: str, kwargs: str) -> None:
        self._config: dict[str, Any] = {"args": args, "kwargs": kwargs}
        self._callbacks: dict[str, list[Callable]] = defaultdict(list)
        self._lists: dict[str, list] = defaultdict(list)
        self._frozen = False

    def build(self) -> _ADK_BaseArtifactService:
        """Abstract base class for artifact services. Resolve into a native ADK _ADK_BaseArtifactService."""
        config = self._prepare_build_config()
        result = self._safe_build(_ADK_BaseArtifactService, config)
        return self._apply_native_hooks(result)


class FileArtifactService(BuilderBase):
    """Stores filesystem-backed artifacts beneath a configurable root directory."""

    _ALIASES: dict[str, str] = {}
    _CALLBACK_ALIASES: dict[str, str] = {}
    _ADDITIVE_FIELDS: set[str] = set()
    _KNOWN_PARAMS: set[str] | None = {"root_dir"}

    def __init__(self, root_dir: str) -> None:
        self._config: dict[str, Any] = {"root_dir": root_dir}
        self._callbacks: dict[str, list[Callable]] = defaultdict(list)
        self._lists: dict[str, list] = defaultdict(list)
        self._frozen = False

    def build(self) -> _ADK_FileArtifactService:
        """Stores filesystem-backed artifacts beneath a configurable root directory. Resolve into a native ADK _ADK_FileArtifactService."""
        config = self._prepare_build_config()
        result = self._safe_build(_ADK_FileArtifactService, config)
        return self._apply_native_hooks(result)


class GcsArtifactService(BuilderBase):
    """An artifact service implementation using Google Cloud Storage (GCS)."""

    _ALIASES: dict[str, str] = {}
    _CALLBACK_ALIASES: dict[str, str] = {}
    _ADDITIVE_FIELDS: set[str] = set()
    _KNOWN_PARAMS: set[str] | None = {"bucket_name"}

    def __init__(self, bucket_name: str, kwargs: str) -> None:
        self._config: dict[str, Any] = {"bucket_name": bucket_name, "kwargs": kwargs}
        self._callbacks: dict[str, list[Callable]] = defaultdict(list)
        self._lists: dict[str, list] = defaultdict(list)
        self._frozen = False

    def build(self) -> _ADK_GcsArtifactService:
        """An artifact service implementation using Google Cloud Storage (GCS). Resolve into a native ADK _ADK_GcsArtifactService."""
        config = self._prepare_build_config()
        result = self._safe_build(_ADK_GcsArtifactService, config)
        return self._apply_native_hooks(result)


class InMemoryArtifactService(BuilderBase):
    """An in-memory implementation of the artifact service."""

    _ALIASES: dict[str, str] = {}
    _CALLBACK_ALIASES: dict[str, str] = {}
    _ADDITIVE_FIELDS: set[str] = set()
    _ADK_TARGET_CLASS = _ADK_InMemoryArtifactService

    def __init__(self) -> None:
        self._config: dict[str, Any] = {}
        self._callbacks: dict[str, list[Callable]] = defaultdict(list)
        self._lists: dict[str, list] = defaultdict(list)
        self._frozen = False

    def artifacts(self, value: dict[str, list[Any]]) -> Self:
        """Set the ``artifacts`` field."""
        self = self._maybe_fork_for_mutation()
        self._config["artifacts"] = value
        return self

    def build(self) -> _ADK_InMemoryArtifactService:
        """An in-memory implementation of the artifact service. Resolve into a native ADK _ADK_InMemoryArtifactService."""
        config = self._prepare_build_config()
        result = self._safe_build(_ADK_InMemoryArtifactService, config)
        return self._apply_native_hooks(result)


class PerAgentDatabaseSessionService(BuilderBase):
    """Routes session storage to per-agent `.adk/session.db` files."""

    _ALIASES: dict[str, str] = {}
    _CALLBACK_ALIASES: dict[str, str] = {}
    _ADDITIVE_FIELDS: set[str] = set()
    _KNOWN_PARAMS: set[str] | None = {"agents_root", "app_name_to_dir"}

    def __init__(self, agents_root: str) -> None:
        self._config: dict[str, Any] = {"agents_root": agents_root}
        self._callbacks: dict[str, list[Callable]] = defaultdict(list)
        self._lists: dict[str, list] = defaultdict(list)
        self._frozen = False

    def app_name_to_dir(self, value: Mapping[str, str] | None) -> Self:
        """Set the ``app_name_to_dir`` field."""
        self = self._maybe_fork_for_mutation()
        self._config["app_name_to_dir"] = value
        return self

    def build(self) -> _ADK_PerAgentDatabaseSessionService:
        """Routes session storage to per-agent `.adk/session.db` files. Resolve into a native ADK _ADK_PerAgentDatabaseSessionService."""
        config = self._prepare_build_config()
        result = self._safe_build(_ADK_PerAgentDatabaseSessionService, config)
        return self._apply_native_hooks(result)


class BaseMemoryService(BuilderBase):
    """Base class for memory services."""

    _ALIASES: dict[str, str] = {}
    _CALLBACK_ALIASES: dict[str, str] = {}
    _ADDITIVE_FIELDS: set[str] = set()
    _KNOWN_PARAMS: set[str] | None = set()

    def __init__(self, args: str, kwargs: str) -> None:
        self._config: dict[str, Any] = {"args": args, "kwargs": kwargs}
        self._callbacks: dict[str, list[Callable]] = defaultdict(list)
        self._lists: dict[str, list] = defaultdict(list)
        self._frozen = False

    def build(self) -> _ADK_BaseMemoryService:
        """Base class for memory services. Resolve into a native ADK _ADK_BaseMemoryService."""
        config = self._prepare_build_config()
        result = self._safe_build(_ADK_BaseMemoryService, config)
        return self._apply_native_hooks(result)


class InMemoryMemoryService(BuilderBase):
    """An in-memory memory service for prototyping purpose only."""

    _ALIASES: dict[str, str] = {}
    _CALLBACK_ALIASES: dict[str, str] = {}
    _ADDITIVE_FIELDS: set[str] = set()
    _KNOWN_PARAMS: set[str] | None = set()

    def __init__(self) -> None:
        self._config: dict[str, Any] = {}
        self._callbacks: dict[str, list[Callable]] = defaultdict(list)
        self._lists: dict[str, list] = defaultdict(list)
        self._frozen = False

    def build(self) -> _ADK_InMemoryMemoryService:
        """An in-memory memory service for prototyping purpose only. Resolve into a native ADK _ADK_InMemoryMemoryService."""
        config = self._prepare_build_config()
        result = self._safe_build(_ADK_InMemoryMemoryService, config)
        return self._apply_native_hooks(result)


class VertexAiMemoryBankService(BuilderBase):
    """Implementation of the BaseMemoryService using Vertex AI Memory Bank."""

    _ALIASES: dict[str, str] = {}
    _CALLBACK_ALIASES: dict[str, str] = {}
    _ADDITIVE_FIELDS: set[str] = set()
    _KNOWN_PARAMS: set[str] | None = {"agent_engine_id", "express_mode_api_key", "location", "project"}

    def __init__(self) -> None:
        self._config: dict[str, Any] = {}
        self._callbacks: dict[str, list[Callable]] = defaultdict(list)
        self._lists: dict[str, list] = defaultdict(list)
        self._frozen = False

    def project(self, value: str | None) -> Self:
        """Set the ``project`` field."""
        self = self._maybe_fork_for_mutation()
        self._config["project"] = value
        return self

    def location(self, value: str | None) -> Self:
        """Set the ``location`` field."""
        self = self._maybe_fork_for_mutation()
        self._config["location"] = value
        return self

    def agent_engine_id(self, value: str | None) -> Self:
        """Set the ``agent_engine_id`` field."""
        self = self._maybe_fork_for_mutation()
        self._config["agent_engine_id"] = value
        return self

    def express_mode_api_key(self, value: str | None) -> Self:
        """Set the ``express_mode_api_key`` field."""
        self = self._maybe_fork_for_mutation()
        self._config["express_mode_api_key"] = value
        return self

    def build(self) -> _ADK_VertexAiMemoryBankService:
        """Implementation of the BaseMemoryService using Vertex AI Memory Bank. Resolve into a native ADK _ADK_VertexAiMemoryBankService."""
        config = self._prepare_build_config()
        result = self._safe_build(_ADK_VertexAiMemoryBankService, config)
        return self._apply_native_hooks(result)


class VertexAiRagMemoryService(BuilderBase):
    """A memory service that uses Vertex AI RAG for storage and retrieval."""

    _ALIASES: dict[str, str] = {}
    _CALLBACK_ALIASES: dict[str, str] = {}
    _ADDITIVE_FIELDS: set[str] = set()
    _KNOWN_PARAMS: set[str] | None = {"rag_corpus", "similarity_top_k", "vector_distance_threshold"}

    def __init__(self) -> None:
        self._config: dict[str, Any] = {}
        self._callbacks: dict[str, list[Callable]] = defaultdict(list)
        self._lists: dict[str, list] = defaultdict(list)
        self._frozen = False

    def rag_corpus(self, value: str | None) -> Self:
        """Set the ``rag_corpus`` field."""
        self = self._maybe_fork_for_mutation()
        self._config["rag_corpus"] = value
        return self

    def similarity_top_k(self, value: int | None) -> Self:
        """Set the ``similarity_top_k`` field."""
        self = self._maybe_fork_for_mutation()
        self._config["similarity_top_k"] = value
        return self

    def vector_distance_threshold(self, value: float) -> Self:
        """Set the ``vector_distance_threshold`` field."""
        self = self._maybe_fork_for_mutation()
        self._config["vector_distance_threshold"] = value
        return self

    def build(self) -> _ADK_VertexAiRagMemoryService:
        """A memory service that uses Vertex AI RAG for storage and retrieval. Resolve into a native ADK _ADK_VertexAiRagMemoryService."""
        config = self._prepare_build_config()
        result = self._safe_build(_ADK_VertexAiRagMemoryService, config)
        return self._apply_native_hooks(result)


class BaseSessionService(BuilderBase):
    """Base class for session services."""

    _ALIASES: dict[str, str] = {}
    _CALLBACK_ALIASES: dict[str, str] = {}
    _ADDITIVE_FIELDS: set[str] = set()
    _KNOWN_PARAMS: set[str] | None = set()

    def __init__(self, args: str, kwargs: str) -> None:
        self._config: dict[str, Any] = {"args": args, "kwargs": kwargs}
        self._callbacks: dict[str, list[Callable]] = defaultdict(list)
        self._lists: dict[str, list] = defaultdict(list)
        self._frozen = False

    def build(self) -> _ADK_BaseSessionService:
        """Base class for session services. Resolve into a native ADK _ADK_BaseSessionService."""
        config = self._prepare_build_config()
        result = self._safe_build(_ADK_BaseSessionService, config)
        return self._apply_native_hooks(result)


class DatabaseSessionService(BuilderBase):
    """A session service that uses a database for storage."""

    _ALIASES: dict[str, str] = {}
    _CALLBACK_ALIASES: dict[str, str] = {}
    _ADDITIVE_FIELDS: set[str] = set()
    _KNOWN_PARAMS: set[str] | None = {"db_url"}

    def __init__(self, db_url: str, kwargs: str) -> None:
        self._config: dict[str, Any] = {"db_url": db_url, "kwargs": kwargs}
        self._callbacks: dict[str, list[Callable]] = defaultdict(list)
        self._lists: dict[str, list] = defaultdict(list)
        self._frozen = False

    def build(self) -> _ADK_DatabaseSessionService:
        """A session service that uses a database for storage. Resolve into a native ADK _ADK_DatabaseSessionService."""
        config = self._prepare_build_config()
        result = self._safe_build(_ADK_DatabaseSessionService, config)
        return self._apply_native_hooks(result)


class InMemorySessionService(BuilderBase):
    """An in-memory implementation of the session service."""

    _ALIASES: dict[str, str] = {}
    _CALLBACK_ALIASES: dict[str, str] = {}
    _ADDITIVE_FIELDS: set[str] = set()
    _KNOWN_PARAMS: set[str] | None = set()

    def __init__(self) -> None:
        self._config: dict[str, Any] = {}
        self._callbacks: dict[str, list[Callable]] = defaultdict(list)
        self._lists: dict[str, list] = defaultdict(list)
        self._frozen = False

    def build(self) -> _ADK_InMemorySessionService:
        """An in-memory implementation of the session service. Resolve into a native ADK _ADK_InMemorySessionService."""
        config = self._prepare_build_config()
        result = self._safe_build(_ADK_InMemorySessionService, config)
        return self._apply_native_hooks(result)


class SqliteSessionService(BuilderBase):
    """A session service that uses an SQLite database for storage via aiosqlite."""

    _ALIASES: dict[str, str] = {}
    _CALLBACK_ALIASES: dict[str, str] = {}
    _ADDITIVE_FIELDS: set[str] = set()
    _KNOWN_PARAMS: set[str] | None = {"db_path"}

    def __init__(self, db_path: str) -> None:
        self._config: dict[str, Any] = {"db_path": db_path}
        self._callbacks: dict[str, list[Callable]] = defaultdict(list)
        self._lists: dict[str, list] = defaultdict(list)
        self._frozen = False

    def build(self) -> _ADK_SqliteSessionService:
        """A session service that uses an SQLite database for storage via aiosqlite. Resolve into a native ADK _ADK_SqliteSessionService."""
        config = self._prepare_build_config()
        result = self._safe_build(_ADK_SqliteSessionService, config)
        return self._apply_native_hooks(result)


class VertexAiSessionService(BuilderBase):
    """Connects to the Vertex AI Agent Engine Session Service using Agent Engine SDK."""

    _ALIASES: dict[str, str] = {}
    _CALLBACK_ALIASES: dict[str, str] = {}
    _ADDITIVE_FIELDS: set[str] = set()
    _KNOWN_PARAMS: set[str] | None = {"agent_engine_id", "express_mode_api_key", "location", "project"}

    def __init__(self) -> None:
        self._config: dict[str, Any] = {}
        self._callbacks: dict[str, list[Callable]] = defaultdict(list)
        self._lists: dict[str, list] = defaultdict(list)
        self._frozen = False

    def project(self, value: str | None) -> Self:
        """Set the ``project`` field."""
        self = self._maybe_fork_for_mutation()
        self._config["project"] = value
        return self

    def location(self, value: str | None) -> Self:
        """Set the ``location`` field."""
        self = self._maybe_fork_for_mutation()
        self._config["location"] = value
        return self

    def agent_engine_id(self, value: str | None) -> Self:
        """Set the ``agent_engine_id`` field."""
        self = self._maybe_fork_for_mutation()
        self._config["agent_engine_id"] = value
        return self

    def express_mode_api_key(self, value: str | None) -> Self:
        """Set the ``express_mode_api_key`` field."""
        self = self._maybe_fork_for_mutation()
        self._config["express_mode_api_key"] = value
        return self

    def build(self) -> _ADK_VertexAiSessionService:
        """Connects to the Vertex AI Agent Engine Session Service using Agent Engine SDK. Resolve into a native ADK _ADK_VertexAiSessionService."""
        config = self._prepare_build_config()
        result = self._safe_build(_ADK_VertexAiSessionService, config)
        return self._apply_native_hooks(result)


class ForwardingArtifactService(BuilderBase):
    """Artifact service that forwards to the parent tool context."""

    _ALIASES: dict[str, str] = {}
    _CALLBACK_ALIASES: dict[str, str] = {}
    _ADDITIVE_FIELDS: set[str] = set()
    _KNOWN_PARAMS: set[str] | None = {"tool_context"}

    def __init__(self, tool_context: str) -> None:
        self._config: dict[str, Any] = {"tool_context": tool_context}
        self._callbacks: dict[str, list[Callable]] = defaultdict(list)
        self._lists: dict[str, list] = defaultdict(list)
        self._frozen = False

    def build(self) -> _ADK_ForwardingArtifactService:
        """Artifact service that forwards to the parent tool context. Resolve into a native ADK _ADK_ForwardingArtifactService."""
        config = self._prepare_build_config()
        result = self._safe_build(_ADK_ForwardingArtifactService, config)
        return self._apply_native_hooks(result)
