# This file was auto-generated by Fern from our API Definition.

from __future__ import annotations

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.acp_type import AcpType
from ..types.agent import Agent
from ..types.agent_metrics_response import AgentMetricsResponse
from ..types.delete_response import DeleteResponse
from ..types.deploy_response import DeployResponse
from ..types.sdk_type import SdkType
from .raw_client import AsyncRawAgentsClient, RawAgentsClient

if typing.TYPE_CHECKING:
    from .branches.client import AsyncBranchesClient, BranchesClient
    from .environments.client import AsyncEnvironmentsClient, EnvironmentsClient
    from .secrets.client import AsyncSecretsClient, SecretsClient
    from .versions.client import AsyncVersionsClient, VersionsClient
# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class AgentsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawAgentsClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._branches: typing.Optional[BranchesClient] = None
        self._environments: typing.Optional[EnvironmentsClient] = None
        self._secrets: typing.Optional[SecretsClient] = None
        self._versions: typing.Optional[VersionsClient] = None

    @property
    def with_raw_response(self) -> RawAgentsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawAgentsClient
        """
        return self._raw_client

    def list(
        self,
        *,
        task_id: typing.Optional[str] = None,
        namespace_id: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        page_number: typing.Optional[int] = None,
        order_by: typing.Optional[str] = None,
        order_direction: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[Agent]:
        """
        List all registered agents, optionally filtered by query parameters.

        Parameters
        ----------
        task_id : typing.Optional[str]
            Task ID

        namespace_id : typing.Optional[str]
            Filter by namespace (currently accepts slug)

        limit : typing.Optional[int]
            Limit

        page_number : typing.Optional[int]
            Page number

        order_by : typing.Optional[str]
            Field to order by

        order_direction : typing.Optional[str]
            Order direction (asc or desc)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[Agent]
            Successful Response

        Examples
        --------
        from terminaluse import TerminalUseBase

        client = TerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.agents.list()
        """
        _response = self._raw_client.list(
            task_id=task_id,
            namespace_id=namespace_id,
            limit=limit,
            page_number=page_number,
            order_by=order_by,
            order_direction=order_direction,
            request_options=request_options,
        )
        return _response.data

    def deploy(
        self,
        *,
        agent_name: str,
        author_email: str,
        author_name: str,
        branch: str,
        git_hash: str,
        image_url: str,
        acp_type: typing.Optional[AcpType] = OMIT,
        are_tasks_sticky: typing.Optional[bool] = OMIT,
        description: typing.Optional[str] = OMIT,
        git_message: typing.Optional[str] = OMIT,
        is_dirty: typing.Optional[bool] = OMIT,
        replicas: typing.Optional[int] = OMIT,
        resources: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        sdk_type: typing.Optional[SdkType] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DeployResponse:
        """
        Deploy an agent to the platform.

            Called by CLI after pushing the container image to the registry.
            Creates or updates agent, branch, and version records.

            The deployment is asynchronous - poll GET /branches/{branch_id}
            for status updates until status is READY or FAILED.

            **Flow:**
            1. CLI builds and pushes image to registry (using /registry/auth)
            2. CLI calls POST /agents/deploy with image details
            3. Platform creates records and triggers K8s deployment
            4. Container starts and calls POST /versions/register
            5. CLI polls GET /branches/{id} for status

        Parameters
        ----------
        agent_name : str
            Agent name in 'namespace_slug/agent_name' format (lowercase alphanumeric, hyphens, underscores)

        author_email : str
            Git commit author email

        author_name : str
            Git commit author name

        branch : str
            Git branch name (e.g., 'main', 'feature/new-tool')

        git_hash : str
            Git commit hash (short or full)

        image_url : str
            Full container image URL (e.g., 'us-east4-docker.pkg.dev/proj/repo/agent:hash')

        acp_type : typing.Optional[AcpType]
            ACP server type (sync or async)

        are_tasks_sticky : typing.Optional[bool]
            If true, running tasks stay on their original version until completion during this deploy. If false or None, tasks are migrated to the new version immediately.

        description : typing.Optional[str]
            Agent description (used when creating new agent)

        git_message : typing.Optional[str]
            Git commit message (truncated if too long)

        is_dirty : typing.Optional[bool]
            Whether the working directory had uncommitted changes at deploy time

        replicas : typing.Optional[int]
            Desired replica count (1-10)

        resources : typing.Optional[typing.Dict[str, typing.Any]]
            Resource requests and limits (e.g., {'requests': {'cpu': '100m', 'memory': '256Mi'}, 'limits': {'cpu': '1000m', 'memory': '1Gi'}})

        sdk_type : typing.Optional[SdkType]
            SDK type for agent runtime

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DeployResponse
            Successful Response

        Examples
        --------
        from terminaluse import TerminalUseBase

        client = TerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.agents.deploy(
            agent_name="agent_name",
            author_email="author_email",
            author_name="author_name",
            branch="branch",
            git_hash="git_hash",
            image_url="image_url",
        )
        """
        _response = self._raw_client.deploy(
            agent_name=agent_name,
            author_email=author_email,
            author_name=author_name,
            branch=branch,
            git_hash=git_hash,
            image_url=image_url,
            acp_type=acp_type,
            are_tasks_sticky=are_tasks_sticky,
            description=description,
            git_message=git_message,
            is_dirty=is_dirty,
            replicas=replicas,
            resources=resources,
            sdk_type=sdk_type,
            request_options=request_options,
        )
        return _response.data

    def forward_get_by_name(
        self,
        namespace_slug: str,
        agent_name: str,
        path: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Forward a GET request to an agent by namespace and name.

        Parameters
        ----------
        namespace_slug : str

        agent_name : str

        path : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from terminaluse import TerminalUseBase

        client = TerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.agents.forward_get_by_name(
            namespace_slug="namespace_slug",
            agent_name="agent_name",
            path="path",
        )
        """
        _response = self._raw_client.forward_get_by_name(
            namespace_slug, agent_name, path, request_options=request_options
        )
        return _response.data

    def rpc_by_name(
        self,
        namespace_slug: str,
        agent_name: str,
        path: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Forward a POST request to an agent by namespace and name.

        Parameters
        ----------
        namespace_slug : str

        agent_name : str

        path : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from terminaluse import TerminalUseBase

        client = TerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.agents.rpc_by_name(
            namespace_slug="namespace_slug",
            agent_name="agent_name",
            path="path",
        )
        """
        _response = self._raw_client.rpc_by_name(namespace_slug, agent_name, path, request_options=request_options)
        return _response.data

    def retrieve_by_name(
        self, namespace_slug: str, agent_name: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> Agent:
        """
        Get an agent by namespace slug and agent name.

        Parameters
        ----------
        namespace_slug : str

        agent_name : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        Agent
            Successful Response

        Examples
        --------
        from terminaluse import TerminalUseBase

        client = TerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.agents.retrieve_by_name(
            namespace_slug="namespace_slug",
            agent_name="agent_name",
        )
        """
        _response = self._raw_client.retrieve_by_name(namespace_slug, agent_name, request_options=request_options)
        return _response.data

    def delete_by_name(
        self, namespace_slug: str, agent_name: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteResponse:
        """
        Delete an agent by namespace slug and agent name.

        Parameters
        ----------
        namespace_slug : str

        agent_name : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DeleteResponse
            Successful Response

        Examples
        --------
        from terminaluse import TerminalUseBase

        client = TerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.agents.delete_by_name(
            namespace_slug="namespace_slug",
            agent_name="agent_name",
        )
        """
        _response = self._raw_client.delete_by_name(namespace_slug, agent_name, request_options=request_options)
        return _response.data

    def retrieve(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Agent:
        """
        Get an agent by its unique ID.

        Parameters
        ----------
        agent_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        Agent
            Successful Response

        Examples
        --------
        from terminaluse import TerminalUseBase

        client = TerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.agents.retrieve(
            agent_id="agent_id",
        )
        """
        _response = self._raw_client.retrieve(agent_id, request_options=request_options)
        return _response.data

    def delete(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DeleteResponse:
        """
        Delete an agent by its unique ID.

        Parameters
        ----------
        agent_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DeleteResponse
            Successful Response

        Examples
        --------
        from terminaluse import TerminalUseBase

        client = TerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.agents.delete(
            agent_id="agent_id",
        )
        """
        _response = self._raw_client.delete(agent_id, request_options=request_options)
        return _response.data

    def retrieve_metrics(
        self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AgentMetricsResponse:
        """
        Get aggregated metrics for an agent over the last 24 hours. Includes task success rate, task count, error log count, and average task duration.

        Parameters
        ----------
        agent_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AgentMetricsResponse
            Successful Response

        Examples
        --------
        from terminaluse import TerminalUseBase

        client = TerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.agents.retrieve_metrics(
            agent_id="agent_id",
        )
        """
        _response = self._raw_client.retrieve_metrics(agent_id, request_options=request_options)
        return _response.data

    @property
    def branches(self):
        if self._branches is None:
            from .branches.client import BranchesClient  # noqa: E402

            self._branches = BranchesClient(client_wrapper=self._client_wrapper)
        return self._branches

    @property
    def environments(self):
        if self._environments is None:
            from .environments.client import EnvironmentsClient  # noqa: E402

            self._environments = EnvironmentsClient(client_wrapper=self._client_wrapper)
        return self._environments

    @property
    def secrets(self):
        if self._secrets is None:
            from .secrets.client import SecretsClient  # noqa: E402

            self._secrets = SecretsClient(client_wrapper=self._client_wrapper)
        return self._secrets

    @property
    def versions(self):
        if self._versions is None:
            from .versions.client import VersionsClient  # noqa: E402

            self._versions = VersionsClient(client_wrapper=self._client_wrapper)
        return self._versions


class AsyncAgentsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawAgentsClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._branches: typing.Optional[AsyncBranchesClient] = None
        self._environments: typing.Optional[AsyncEnvironmentsClient] = None
        self._secrets: typing.Optional[AsyncSecretsClient] = None
        self._versions: typing.Optional[AsyncVersionsClient] = None

    @property
    def with_raw_response(self) -> AsyncRawAgentsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawAgentsClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        task_id: typing.Optional[str] = None,
        namespace_id: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        page_number: typing.Optional[int] = None,
        order_by: typing.Optional[str] = None,
        order_direction: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[Agent]:
        """
        List all registered agents, optionally filtered by query parameters.

        Parameters
        ----------
        task_id : typing.Optional[str]
            Task ID

        namespace_id : typing.Optional[str]
            Filter by namespace (currently accepts slug)

        limit : typing.Optional[int]
            Limit

        page_number : typing.Optional[int]
            Page number

        order_by : typing.Optional[str]
            Field to order by

        order_direction : typing.Optional[str]
            Order direction (asc or desc)

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[Agent]
            Successful Response

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminalUseBase

        client = AsyncTerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.agents.list()


        asyncio.run(main())
        """
        _response = await self._raw_client.list(
            task_id=task_id,
            namespace_id=namespace_id,
            limit=limit,
            page_number=page_number,
            order_by=order_by,
            order_direction=order_direction,
            request_options=request_options,
        )
        return _response.data

    async def deploy(
        self,
        *,
        agent_name: str,
        author_email: str,
        author_name: str,
        branch: str,
        git_hash: str,
        image_url: str,
        acp_type: typing.Optional[AcpType] = OMIT,
        are_tasks_sticky: typing.Optional[bool] = OMIT,
        description: typing.Optional[str] = OMIT,
        git_message: typing.Optional[str] = OMIT,
        is_dirty: typing.Optional[bool] = OMIT,
        replicas: typing.Optional[int] = OMIT,
        resources: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        sdk_type: typing.Optional[SdkType] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DeployResponse:
        """
        Deploy an agent to the platform.

            Called by CLI after pushing the container image to the registry.
            Creates or updates agent, branch, and version records.

            The deployment is asynchronous - poll GET /branches/{branch_id}
            for status updates until status is READY or FAILED.

            **Flow:**
            1. CLI builds and pushes image to registry (using /registry/auth)
            2. CLI calls POST /agents/deploy with image details
            3. Platform creates records and triggers K8s deployment
            4. Container starts and calls POST /versions/register
            5. CLI polls GET /branches/{id} for status

        Parameters
        ----------
        agent_name : str
            Agent name in 'namespace_slug/agent_name' format (lowercase alphanumeric, hyphens, underscores)

        author_email : str
            Git commit author email

        author_name : str
            Git commit author name

        branch : str
            Git branch name (e.g., 'main', 'feature/new-tool')

        git_hash : str
            Git commit hash (short or full)

        image_url : str
            Full container image URL (e.g., 'us-east4-docker.pkg.dev/proj/repo/agent:hash')

        acp_type : typing.Optional[AcpType]
            ACP server type (sync or async)

        are_tasks_sticky : typing.Optional[bool]
            If true, running tasks stay on their original version until completion during this deploy. If false or None, tasks are migrated to the new version immediately.

        description : typing.Optional[str]
            Agent description (used when creating new agent)

        git_message : typing.Optional[str]
            Git commit message (truncated if too long)

        is_dirty : typing.Optional[bool]
            Whether the working directory had uncommitted changes at deploy time

        replicas : typing.Optional[int]
            Desired replica count (1-10)

        resources : typing.Optional[typing.Dict[str, typing.Any]]
            Resource requests and limits (e.g., {'requests': {'cpu': '100m', 'memory': '256Mi'}, 'limits': {'cpu': '1000m', 'memory': '1Gi'}})

        sdk_type : typing.Optional[SdkType]
            SDK type for agent runtime

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DeployResponse
            Successful Response

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminalUseBase

        client = AsyncTerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.agents.deploy(
                agent_name="agent_name",
                author_email="author_email",
                author_name="author_name",
                branch="branch",
                git_hash="git_hash",
                image_url="image_url",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.deploy(
            agent_name=agent_name,
            author_email=author_email,
            author_name=author_name,
            branch=branch,
            git_hash=git_hash,
            image_url=image_url,
            acp_type=acp_type,
            are_tasks_sticky=are_tasks_sticky,
            description=description,
            git_message=git_message,
            is_dirty=is_dirty,
            replicas=replicas,
            resources=resources,
            sdk_type=sdk_type,
            request_options=request_options,
        )
        return _response.data

    async def forward_get_by_name(
        self,
        namespace_slug: str,
        agent_name: str,
        path: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Forward a GET request to an agent by namespace and name.

        Parameters
        ----------
        namespace_slug : str

        agent_name : str

        path : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminalUseBase

        client = AsyncTerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.agents.forward_get_by_name(
                namespace_slug="namespace_slug",
                agent_name="agent_name",
                path="path",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.forward_get_by_name(
            namespace_slug, agent_name, path, request_options=request_options
        )
        return _response.data

    async def rpc_by_name(
        self,
        namespace_slug: str,
        agent_name: str,
        path: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Forward a POST request to an agent by namespace and name.

        Parameters
        ----------
        namespace_slug : str

        agent_name : str

        path : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminalUseBase

        client = AsyncTerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.agents.rpc_by_name(
                namespace_slug="namespace_slug",
                agent_name="agent_name",
                path="path",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.rpc_by_name(
            namespace_slug, agent_name, path, request_options=request_options
        )
        return _response.data

    async def retrieve_by_name(
        self, namespace_slug: str, agent_name: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> Agent:
        """
        Get an agent by namespace slug and agent name.

        Parameters
        ----------
        namespace_slug : str

        agent_name : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        Agent
            Successful Response

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminalUseBase

        client = AsyncTerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.agents.retrieve_by_name(
                namespace_slug="namespace_slug",
                agent_name="agent_name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.retrieve_by_name(namespace_slug, agent_name, request_options=request_options)
        return _response.data

    async def delete_by_name(
        self, namespace_slug: str, agent_name: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteResponse:
        """
        Delete an agent by namespace slug and agent name.

        Parameters
        ----------
        namespace_slug : str

        agent_name : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DeleteResponse
            Successful Response

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminalUseBase

        client = AsyncTerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.agents.delete_by_name(
                namespace_slug="namespace_slug",
                agent_name="agent_name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete_by_name(namespace_slug, agent_name, request_options=request_options)
        return _response.data

    async def retrieve(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Agent:
        """
        Get an agent by its unique ID.

        Parameters
        ----------
        agent_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        Agent
            Successful Response

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminalUseBase

        client = AsyncTerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.agents.retrieve(
                agent_id="agent_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.retrieve(agent_id, request_options=request_options)
        return _response.data

    async def delete(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DeleteResponse:
        """
        Delete an agent by its unique ID.

        Parameters
        ----------
        agent_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        DeleteResponse
            Successful Response

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminalUseBase

        client = AsyncTerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.agents.delete(
                agent_id="agent_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete(agent_id, request_options=request_options)
        return _response.data

    async def retrieve_metrics(
        self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AgentMetricsResponse:
        """
        Get aggregated metrics for an agent over the last 24 hours. Includes task success rate, task count, error log count, and average task duration.

        Parameters
        ----------
        agent_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AgentMetricsResponse
            Successful Response

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminalUseBase

        client = AsyncTerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.agents.retrieve_metrics(
                agent_id="agent_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.retrieve_metrics(agent_id, request_options=request_options)
        return _response.data

    @property
    def branches(self):
        if self._branches is None:
            from .branches.client import AsyncBranchesClient  # noqa: E402

            self._branches = AsyncBranchesClient(client_wrapper=self._client_wrapper)
        return self._branches

    @property
    def environments(self):
        if self._environments is None:
            from .environments.client import AsyncEnvironmentsClient  # noqa: E402

            self._environments = AsyncEnvironmentsClient(client_wrapper=self._client_wrapper)
        return self._environments

    @property
    def secrets(self):
        if self._secrets is None:
            from .secrets.client import AsyncSecretsClient  # noqa: E402

            self._secrets = AsyncSecretsClient(client_wrapper=self._client_wrapper)
        return self._secrets

    @property
    def versions(self):
        if self._versions is None:
            from .versions.client import AsyncVersionsClient  # noqa: E402

            self._versions = AsyncVersionsClient(client_wrapper=self._client_wrapper)
        return self._versions
