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

import datetime as dt
import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.delete_response import DeleteResponse
from ..types.event import Event
from ..types.handler_end_response import HandlerEndResponse
from ..types.migrate_tasks_response import MigrateTasksResponse
from ..types.presigned_url_request import PresignedUrlRequest
from ..types.presigned_url_response import PresignedUrlResponse
from ..types.system_folder_response import SystemFolderResponse
from ..types.system_folder_sync_complete_response import SystemFolderSyncCompleteResponse
from ..types.system_folder_type import SystemFolderType
from ..types.system_folder_type_response import SystemFolderTypeResponse
from ..types.task import Task
from ..types.task_relationships import TaskRelationships
from ..types.task_response import TaskResponse
from ..types.task_status import TaskStatus
from ..types.text_stream_part_wrapper import TextStreamPartWrapper
from .raw_client import AsyncRawTasksClient, RawTasksClient
from .types.create_task_event_request_content import CreateTaskEventRequestContent

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class TasksClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawTasksClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawTasksClient
        """
        return self._raw_client

    def list(
        self,
        *,
        agent_id: typing.Optional[str] = None,
        namespace_id: typing.Optional[str] = None,
        agent_name: typing.Optional[str] = None,
        status: typing.Optional[typing.Sequence[TaskStatus]] = None,
        created_after: typing.Optional[dt.datetime] = None,
        created_before: typing.Optional[dt.datetime] = None,
        include_total: typing.Optional[bool] = None,
        limit: typing.Optional[int] = None,
        page_number: typing.Optional[int] = None,
        order_by: typing.Optional[str] = None,
        order_direction: typing.Optional[str] = None,
        relationships: typing.Optional[typing.Union[TaskRelationships, typing.Sequence[TaskRelationships]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[TaskResponse]:
        """
        List all tasks.

        Parameters
        ----------
        agent_id : typing.Optional[str]
            Optional agent filter. When provided, we authorize it via direct OpenFGA Check and avoid ListObjects(agent) to prevent false 403s from transient/partial list results.

        namespace_id : typing.Optional[str]

        agent_name : typing.Optional[str]

        status : typing.Optional[typing.Sequence[TaskStatus]]

        created_after : typing.Optional[dt.datetime]

        created_before : typing.Optional[dt.datetime]

        include_total : typing.Optional[bool]

        limit : typing.Optional[int]

        page_number : typing.Optional[int]

        order_by : typing.Optional[str]

        order_direction : typing.Optional[str]

        relationships : typing.Optional[typing.Union[TaskRelationships, typing.Sequence[TaskRelationships]]]

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

        Returns
        -------
        typing.List[TaskResponse]
            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.tasks.list()
        """
        _response = self._raw_client.list(
            agent_id=agent_id,
            namespace_id=namespace_id,
            agent_name=agent_name,
            status=status,
            created_after=created_after,
            created_before=created_before,
            include_total=include_total,
            limit=limit,
            page_number=page_number,
            order_by=order_by,
            order_direction=order_direction,
            relationships=relationships,
            request_options=request_options,
        )
        return _response.data

    def create(
        self,
        *,
        agent_id: typing.Optional[str] = OMIT,
        agent_name: typing.Optional[str] = OMIT,
        branch: typing.Optional[str] = OMIT,
        filesystem_id: typing.Optional[str] = OMIT,
        name: typing.Optional[str] = OMIT,
        params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        project_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TaskResponse:
        """
        Create a new task for an agent.

        Parameters
        ----------
        agent_id : typing.Optional[str]
            Agent ID (provide this OR agent_name)

        agent_name : typing.Optional[str]
            Agent name as 'namespace/name' (provide this OR agent_id)

        branch : typing.Optional[str]
            Target branch for version routing

        filesystem_id : typing.Optional[str]
            Existing filesystem ID

        name : typing.Optional[str]
            Task name

        params : typing.Optional[typing.Dict[str, typing.Any]]
            Task parameters

        project_id : typing.Optional[str]
            Project ID for new filesystem

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

        Returns
        -------
        TaskResponse
            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.tasks.create()
        """
        _response = self._raw_client.create(
            agent_id=agent_id,
            agent_name=agent_name,
            branch=branch,
            filesystem_id=filesystem_id,
            name=name,
            params=params,
            project_id=project_id,
            request_options=request_options,
        )
        return _response.data

    def migrate(
        self,
        *,
        from_version_id: typing.Optional[str] = OMIT,
        task_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        to_latest: typing.Optional[bool] = OMIT,
        to_version_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MigrateTasksResponse:
        """
        Migrate tasks between versions within the same branch. Supports two modes: bulk migration by source version (from_version_id), or migration of specific tasks (task_ids). Target can be explicit (to_version_id) or latest active version (to_latest).

        Parameters
        ----------
        from_version_id : typing.Optional[str]
            Migrate ALL RUNNING tasks from this version

        task_ids : typing.Optional[typing.Sequence[str]]
            OR migrate specific task IDs

        to_latest : typing.Optional[bool]
            OR migrate to ACTIVE/DEPLOYING version on branch

        to_version_id : typing.Optional[str]
            Explicit target version ID

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

        Returns
        -------
        MigrateTasksResponse
            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.tasks.migrate()
        """
        _response = self._raw_client.migrate(
            from_version_id=from_version_id,
            task_ids=task_ids,
            to_latest=to_latest,
            to_version_id=to_version_id,
            request_options=request_options,
        )
        return _response.data

    def retrieve_by_name(
        self,
        task_name: str,
        *,
        relationships: typing.Optional[typing.Union[TaskRelationships, typing.Sequence[TaskRelationships]]] = None,
        agent_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TaskResponse:
        """
        Get a task by its unique name.

        Parameters
        ----------
        task_name : str

        relationships : typing.Optional[typing.Union[TaskRelationships, typing.Sequence[TaskRelationships]]]

        agent_id : typing.Optional[str]
            Optional agent filter. When provided, we authorize it via direct OpenFGA Check and avoid ListObjects(agent) to prevent false 403s from transient/partial list results.

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

        Returns
        -------
        TaskResponse
            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.tasks.retrieve_by_name(
            task_name="task_name",
        )
        """
        _response = self._raw_client.retrieve_by_name(
            task_name, relationships=relationships, agent_id=agent_id, request_options=request_options
        )
        return _response.data

    def update_by_name(
        self,
        task_name: str,
        *,
        agent_id: typing.Optional[str] = None,
        task_metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Task:
        """
        Update mutable fields for a task by its unique Name.

        Parameters
        ----------
        task_name : str

        agent_id : typing.Optional[str]
            Optional agent filter. When provided, we authorize it via direct OpenFGA Check and avoid ListObjects(agent) to prevent false 403s from transient/partial list results.

        task_metadata : typing.Optional[typing.Dict[str, typing.Any]]

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

        Returns
        -------
        Task
            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.tasks.update_by_name(
            task_name="task_name",
        )
        """
        _response = self._raw_client.update_by_name(
            task_name, agent_id=agent_id, task_metadata=task_metadata, request_options=request_options
        )
        return _response.data

    def delete_by_name(
        self,
        task_name: str,
        *,
        agent_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DeleteResponse:
        """
        Delete a task by its unique name.

        Parameters
        ----------
        task_name : str

        agent_id : typing.Optional[str]
            Optional agent filter. When provided, we authorize it via direct OpenFGA Check and avoid ListObjects(agent) to prevent false 403s from transient/partial list results.

        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.tasks.delete_by_name(
            task_name="task_name",
        )
        """
        _response = self._raw_client.delete_by_name(task_name, agent_id=agent_id, request_options=request_options)
        return _response.data

    def stream_by_name(
        self,
        task_name: str,
        *,
        agent_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Iterator[TextStreamPartWrapper]:
        """
        Stream events for a task by its unique name using Server-Sent Events (SSE).

            Supports automatic reconnection with Last-Event-ID header. When the client
            reconnects, it sends the Last-Event-ID header with the last received event ID,
            and the server resumes from that point.

            Returns TextStreamPart events (Vercel AI SDK compatible format).

        Parameters
        ----------
        task_name : str

        agent_id : typing.Optional[str]
            Optional agent filter. When provided, we authorize it via direct OpenFGA Check and avoid ListObjects(agent) to prevent false 403s from transient/partial list results.

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

        Yields
        ------
        typing.Iterator[TextStreamPartWrapper]
            SSE stream of TextStreamPart events

        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",
        )
        response = client.tasks.stream_by_name(
            task_name="task_name",
        )
        for chunk in response:
            yield chunk
        """
        with self._raw_client.stream_by_name(task_name, agent_id=agent_id, request_options=request_options) as r:
            yield from r.data

    def retrieve(
        self,
        task_id: str,
        *,
        relationships: typing.Optional[typing.Union[TaskRelationships, typing.Sequence[TaskRelationships]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TaskResponse:
        """
        Get a task by its unique ID.

        Parameters
        ----------
        task_id : str

        relationships : typing.Optional[typing.Union[TaskRelationships, typing.Sequence[TaskRelationships]]]

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

        Returns
        -------
        TaskResponse
            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.tasks.retrieve(
            task_id="task_id",
        )
        """
        _response = self._raw_client.retrieve(task_id, relationships=relationships, request_options=request_options)
        return _response.data

    def update(
        self,
        task_id: str,
        *,
        task_metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Task:
        """
        Update mutable fields for a task by its unique ID.

        Parameters
        ----------
        task_id : str

        task_metadata : typing.Optional[typing.Dict[str, typing.Any]]

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

        Returns
        -------
        Task
            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.tasks.update(
            task_id="task_id",
        )
        """
        _response = self._raw_client.update(task_id, task_metadata=task_metadata, request_options=request_options)
        return _response.data

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

        Parameters
        ----------
        task_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.tasks.delete(
            task_id="task_id",
        )
        """
        _response = self._raw_client.delete(task_id, request_options=request_options)
        return _response.data

    def cancel(self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> TaskResponse:
        """
        Cancel a running task.

        Parameters
        ----------
        task_id : str

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

        Returns
        -------
        TaskResponse
            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.tasks.cancel(
            task_id="task_id",
        )
        """
        _response = self._raw_client.cancel(task_id, request_options=request_options)
        return _response.data

    def send_event(
        self,
        task_id: str,
        *,
        content: typing.Optional[CreateTaskEventRequestContent] = OMIT,
        idempotency_key: typing.Optional[str] = OMIT,
        persist_message: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Event:
        """
        Send an event to a running task.

        Parameters
        ----------
        task_id : str

        content : typing.Optional[CreateTaskEventRequestContent]
            Event content

        idempotency_key : typing.Optional[str]
            Optional idempotency key for retry-safe event delivery.

        persist_message : typing.Optional[bool]
            Whether to also create a message record for this event. Defaults to True.

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

        Returns
        -------
        Event
            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.tasks.send_event(
            task_id="task_id",
        )
        """
        _response = self._raw_client.send_event(
            task_id,
            content=content,
            idempotency_key=idempotency_key,
            persist_message=persist_message,
            request_options=request_options,
        )
        return _response.data

    def handler_end(
        self,
        task_id: str,
        *,
        duration_ms: typing.Optional[int] = OMIT,
        error: typing.Optional[str] = OMIT,
        event_id: typing.Optional[str] = OMIT,
        pod_id: typing.Optional[str] = OMIT,
        success: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HandlerEndResponse:
        """
        Signal that an ACP handler has finished processing an event.

        Parameters
        ----------
        task_id : str

        duration_ms : typing.Optional[int]

        error : typing.Optional[str]

        event_id : typing.Optional[str]

        pod_id : typing.Optional[str]

        success : typing.Optional[bool]

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

        Returns
        -------
        HandlerEndResponse
            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.tasks.handler_end(
            task_id="task_id",
        )
        """
        _response = self._raw_client.handler_end(
            task_id,
            duration_ms=duration_ms,
            error=error,
            event_id=event_id,
            pod_id=pod_id,
            success=success,
            request_options=request_options,
        )
        return _response.data

    def stream(
        self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Iterator[TextStreamPartWrapper]:
        """
        Stream events for a task by its unique ID using Server-Sent Events (SSE).

            Supports automatic reconnection with Last-Event-ID header. When the client
            reconnects, it sends the Last-Event-ID header with the last received event ID,
            and the server resumes from that point.

            Returns TextStreamPart events (Vercel AI SDK compatible format).

        Parameters
        ----------
        task_id : str

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

        Yields
        ------
        typing.Iterator[TextStreamPartWrapper]
            SSE stream of TextStreamPart events

        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",
        )
        response = client.tasks.stream(
            task_id="task_id",
        )
        for chunk in response:
            yield chunk
        """
        with self._raw_client.stream(task_id, request_options=request_options) as r:
            yield from r.data

    def list_system_folder_types(
        self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[SystemFolderTypeResponse]:
        """
        Get all registered system folder types with their configurations for a task.

        Parameters
        ----------
        task_id : str

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

        Returns
        -------
        typing.List[SystemFolderTypeResponse]
            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.tasks.list_system_folder_types(
            task_id="task_id",
        )
        """
        _response = self._raw_client.list_system_folder_types(task_id, request_options=request_options)
        return _response.data

    def get_system_folder(
        self, task_id: str, folder_type: SystemFolderType, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[SystemFolderResponse]:
        """
        Get a task's system folder record by type.

        Parameters
        ----------
        task_id : str

        folder_type : SystemFolderType

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

        Returns
        -------
        typing.Optional[SystemFolderResponse]
            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.tasks.get_system_folder(
            task_id="task_id",
            folder_type="dot_claude",
        )
        """
        _response = self._raw_client.get_system_folder(task_id, folder_type, request_options=request_options)
        return _response.data

    def get_system_folder_download_url(
        self,
        task_id: str,
        folder_type: SystemFolderType,
        *,
        request: typing.Optional[PresignedUrlRequest] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[PresignedUrlResponse]:
        """
        Get a presigned URL for direct download of a system folder archive from GCS.

        Parameters
        ----------
        task_id : str

        folder_type : SystemFolderType

        request : typing.Optional[PresignedUrlRequest]

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

        Returns
        -------
        typing.Optional[PresignedUrlResponse]
            Successful Response

        Examples
        --------
        from terminaluse import PresignedUrlRequest, TerminalUseBase

        client = TerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.tasks.get_system_folder_download_url(
            task_id="task_id",
            folder_type="dot_claude",
            request=PresignedUrlRequest(),
        )
        """
        _response = self._raw_client.get_system_folder_download_url(
            task_id, folder_type, request=request, request_options=request_options
        )
        return _response.data

    def system_folder_sync_complete(
        self,
        task_id: str,
        folder_type: SystemFolderType,
        *,
        direction: str,
        status: str,
        sync_id: str,
        archive_checksum: typing.Optional[str] = OMIT,
        archive_size_bytes: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SystemFolderSyncCompleteResponse:
        """
        Complete a system folder sync operation and update metadata.

        Parameters
        ----------
        task_id : str

        folder_type : SystemFolderType

        direction : str
            Sync direction: 'UP' or 'DOWN'.

        status : str
            Sync status: 'SUCCESS' or 'FAILED'.

        sync_id : str
            Unique ID for this sync operation (idempotency key).

        archive_checksum : typing.Optional[str]
            SHA256 checksum of the archive.

        archive_size_bytes : typing.Optional[int]
            Size of the archive in bytes.

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

        Returns
        -------
        SystemFolderSyncCompleteResponse
            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.tasks.system_folder_sync_complete(
            task_id="task_id",
            folder_type="dot_claude",
            direction="direction",
            status="status",
            sync_id="sync_id",
        )
        """
        _response = self._raw_client.system_folder_sync_complete(
            task_id,
            folder_type,
            direction=direction,
            status=status,
            sync_id=sync_id,
            archive_checksum=archive_checksum,
            archive_size_bytes=archive_size_bytes,
            request_options=request_options,
        )
        return _response.data

    def get_system_folder_upload_url(
        self,
        task_id: str,
        folder_type: SystemFolderType,
        *,
        request: typing.Optional[PresignedUrlRequest] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PresignedUrlResponse:
        """
        Get a presigned URL for direct upload of a system folder archive to GCS.

        Parameters
        ----------
        task_id : str

        folder_type : SystemFolderType

        request : typing.Optional[PresignedUrlRequest]

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

        Returns
        -------
        PresignedUrlResponse
            Successful Response

        Examples
        --------
        from terminaluse import PresignedUrlRequest, TerminalUseBase

        client = TerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.tasks.get_system_folder_upload_url(
            task_id="task_id",
            folder_type="dot_claude",
            request=PresignedUrlRequest(),
        )
        """
        _response = self._raw_client.get_system_folder_upload_url(
            task_id, folder_type, request=request, request_options=request_options
        )
        return _response.data


class AsyncTasksClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawTasksClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawTasksClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        agent_id: typing.Optional[str] = None,
        namespace_id: typing.Optional[str] = None,
        agent_name: typing.Optional[str] = None,
        status: typing.Optional[typing.Sequence[TaskStatus]] = None,
        created_after: typing.Optional[dt.datetime] = None,
        created_before: typing.Optional[dt.datetime] = None,
        include_total: typing.Optional[bool] = None,
        limit: typing.Optional[int] = None,
        page_number: typing.Optional[int] = None,
        order_by: typing.Optional[str] = None,
        order_direction: typing.Optional[str] = None,
        relationships: typing.Optional[typing.Union[TaskRelationships, typing.Sequence[TaskRelationships]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[TaskResponse]:
        """
        List all tasks.

        Parameters
        ----------
        agent_id : typing.Optional[str]
            Optional agent filter. When provided, we authorize it via direct OpenFGA Check and avoid ListObjects(agent) to prevent false 403s from transient/partial list results.

        namespace_id : typing.Optional[str]

        agent_name : typing.Optional[str]

        status : typing.Optional[typing.Sequence[TaskStatus]]

        created_after : typing.Optional[dt.datetime]

        created_before : typing.Optional[dt.datetime]

        include_total : typing.Optional[bool]

        limit : typing.Optional[int]

        page_number : typing.Optional[int]

        order_by : typing.Optional[str]

        order_direction : typing.Optional[str]

        relationships : typing.Optional[typing.Union[TaskRelationships, typing.Sequence[TaskRelationships]]]

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

        Returns
        -------
        typing.List[TaskResponse]
            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.tasks.list()


        asyncio.run(main())
        """
        _response = await self._raw_client.list(
            agent_id=agent_id,
            namespace_id=namespace_id,
            agent_name=agent_name,
            status=status,
            created_after=created_after,
            created_before=created_before,
            include_total=include_total,
            limit=limit,
            page_number=page_number,
            order_by=order_by,
            order_direction=order_direction,
            relationships=relationships,
            request_options=request_options,
        )
        return _response.data

    async def create(
        self,
        *,
        agent_id: typing.Optional[str] = OMIT,
        agent_name: typing.Optional[str] = OMIT,
        branch: typing.Optional[str] = OMIT,
        filesystem_id: typing.Optional[str] = OMIT,
        name: typing.Optional[str] = OMIT,
        params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        project_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TaskResponse:
        """
        Create a new task for an agent.

        Parameters
        ----------
        agent_id : typing.Optional[str]
            Agent ID (provide this OR agent_name)

        agent_name : typing.Optional[str]
            Agent name as 'namespace/name' (provide this OR agent_id)

        branch : typing.Optional[str]
            Target branch for version routing

        filesystem_id : typing.Optional[str]
            Existing filesystem ID

        name : typing.Optional[str]
            Task name

        params : typing.Optional[typing.Dict[str, typing.Any]]
            Task parameters

        project_id : typing.Optional[str]
            Project ID for new filesystem

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

        Returns
        -------
        TaskResponse
            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.tasks.create()


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            agent_id=agent_id,
            agent_name=agent_name,
            branch=branch,
            filesystem_id=filesystem_id,
            name=name,
            params=params,
            project_id=project_id,
            request_options=request_options,
        )
        return _response.data

    async def migrate(
        self,
        *,
        from_version_id: typing.Optional[str] = OMIT,
        task_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        to_latest: typing.Optional[bool] = OMIT,
        to_version_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MigrateTasksResponse:
        """
        Migrate tasks between versions within the same branch. Supports two modes: bulk migration by source version (from_version_id), or migration of specific tasks (task_ids). Target can be explicit (to_version_id) or latest active version (to_latest).

        Parameters
        ----------
        from_version_id : typing.Optional[str]
            Migrate ALL RUNNING tasks from this version

        task_ids : typing.Optional[typing.Sequence[str]]
            OR migrate specific task IDs

        to_latest : typing.Optional[bool]
            OR migrate to ACTIVE/DEPLOYING version on branch

        to_version_id : typing.Optional[str]
            Explicit target version ID

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

        Returns
        -------
        MigrateTasksResponse
            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.tasks.migrate()


        asyncio.run(main())
        """
        _response = await self._raw_client.migrate(
            from_version_id=from_version_id,
            task_ids=task_ids,
            to_latest=to_latest,
            to_version_id=to_version_id,
            request_options=request_options,
        )
        return _response.data

    async def retrieve_by_name(
        self,
        task_name: str,
        *,
        relationships: typing.Optional[typing.Union[TaskRelationships, typing.Sequence[TaskRelationships]]] = None,
        agent_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TaskResponse:
        """
        Get a task by its unique name.

        Parameters
        ----------
        task_name : str

        relationships : typing.Optional[typing.Union[TaskRelationships, typing.Sequence[TaskRelationships]]]

        agent_id : typing.Optional[str]
            Optional agent filter. When provided, we authorize it via direct OpenFGA Check and avoid ListObjects(agent) to prevent false 403s from transient/partial list results.

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

        Returns
        -------
        TaskResponse
            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.tasks.retrieve_by_name(
                task_name="task_name",
            )


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

    async def update_by_name(
        self,
        task_name: str,
        *,
        agent_id: typing.Optional[str] = None,
        task_metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Task:
        """
        Update mutable fields for a task by its unique Name.

        Parameters
        ----------
        task_name : str

        agent_id : typing.Optional[str]
            Optional agent filter. When provided, we authorize it via direct OpenFGA Check and avoid ListObjects(agent) to prevent false 403s from transient/partial list results.

        task_metadata : typing.Optional[typing.Dict[str, typing.Any]]

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

        Returns
        -------
        Task
            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.tasks.update_by_name(
                task_name="task_name",
            )


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

    async def delete_by_name(
        self,
        task_name: str,
        *,
        agent_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DeleteResponse:
        """
        Delete a task by its unique name.

        Parameters
        ----------
        task_name : str

        agent_id : typing.Optional[str]
            Optional agent filter. When provided, we authorize it via direct OpenFGA Check and avoid ListObjects(agent) to prevent false 403s from transient/partial list results.

        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.tasks.delete_by_name(
                task_name="task_name",
            )


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

    async def stream_by_name(
        self,
        task_name: str,
        *,
        agent_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.AsyncIterator[TextStreamPartWrapper]:
        """
        Stream events for a task by its unique name using Server-Sent Events (SSE).

            Supports automatic reconnection with Last-Event-ID header. When the client
            reconnects, it sends the Last-Event-ID header with the last received event ID,
            and the server resumes from that point.

            Returns TextStreamPart events (Vercel AI SDK compatible format).

        Parameters
        ----------
        task_name : str

        agent_id : typing.Optional[str]
            Optional agent filter. When provided, we authorize it via direct OpenFGA Check and avoid ListObjects(agent) to prevent false 403s from transient/partial list results.

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

        Yields
        ------
        typing.AsyncIterator[TextStreamPartWrapper]
            SSE stream of TextStreamPart events

        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:
            response = await client.tasks.stream_by_name(
                task_name="task_name",
            )
            async for chunk in response:
                yield chunk


        asyncio.run(main())
        """
        async with self._raw_client.stream_by_name(task_name, agent_id=agent_id, request_options=request_options) as r:
            async for _chunk in r.data:
                yield _chunk

    async def retrieve(
        self,
        task_id: str,
        *,
        relationships: typing.Optional[typing.Union[TaskRelationships, typing.Sequence[TaskRelationships]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TaskResponse:
        """
        Get a task by its unique ID.

        Parameters
        ----------
        task_id : str

        relationships : typing.Optional[typing.Union[TaskRelationships, typing.Sequence[TaskRelationships]]]

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

        Returns
        -------
        TaskResponse
            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.tasks.retrieve(
                task_id="task_id",
            )


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

    async def update(
        self,
        task_id: str,
        *,
        task_metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Task:
        """
        Update mutable fields for a task by its unique ID.

        Parameters
        ----------
        task_id : str

        task_metadata : typing.Optional[typing.Dict[str, typing.Any]]

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

        Returns
        -------
        Task
            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.tasks.update(
                task_id="task_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update(task_id, task_metadata=task_metadata, request_options=request_options)
        return _response.data

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

        Parameters
        ----------
        task_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.tasks.delete(
                task_id="task_id",
            )


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

    async def cancel(self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> TaskResponse:
        """
        Cancel a running task.

        Parameters
        ----------
        task_id : str

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

        Returns
        -------
        TaskResponse
            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.tasks.cancel(
                task_id="task_id",
            )


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

    async def send_event(
        self,
        task_id: str,
        *,
        content: typing.Optional[CreateTaskEventRequestContent] = OMIT,
        idempotency_key: typing.Optional[str] = OMIT,
        persist_message: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Event:
        """
        Send an event to a running task.

        Parameters
        ----------
        task_id : str

        content : typing.Optional[CreateTaskEventRequestContent]
            Event content

        idempotency_key : typing.Optional[str]
            Optional idempotency key for retry-safe event delivery.

        persist_message : typing.Optional[bool]
            Whether to also create a message record for this event. Defaults to True.

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

        Returns
        -------
        Event
            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.tasks.send_event(
                task_id="task_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.send_event(
            task_id,
            content=content,
            idempotency_key=idempotency_key,
            persist_message=persist_message,
            request_options=request_options,
        )
        return _response.data

    async def handler_end(
        self,
        task_id: str,
        *,
        duration_ms: typing.Optional[int] = OMIT,
        error: typing.Optional[str] = OMIT,
        event_id: typing.Optional[str] = OMIT,
        pod_id: typing.Optional[str] = OMIT,
        success: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HandlerEndResponse:
        """
        Signal that an ACP handler has finished processing an event.

        Parameters
        ----------
        task_id : str

        duration_ms : typing.Optional[int]

        error : typing.Optional[str]

        event_id : typing.Optional[str]

        pod_id : typing.Optional[str]

        success : typing.Optional[bool]

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

        Returns
        -------
        HandlerEndResponse
            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.tasks.handler_end(
                task_id="task_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.handler_end(
            task_id,
            duration_ms=duration_ms,
            error=error,
            event_id=event_id,
            pod_id=pod_id,
            success=success,
            request_options=request_options,
        )
        return _response.data

    async def stream(
        self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.AsyncIterator[TextStreamPartWrapper]:
        """
        Stream events for a task by its unique ID using Server-Sent Events (SSE).

            Supports automatic reconnection with Last-Event-ID header. When the client
            reconnects, it sends the Last-Event-ID header with the last received event ID,
            and the server resumes from that point.

            Returns TextStreamPart events (Vercel AI SDK compatible format).

        Parameters
        ----------
        task_id : str

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

        Yields
        ------
        typing.AsyncIterator[TextStreamPartWrapper]
            SSE stream of TextStreamPart events

        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:
            response = await client.tasks.stream(
                task_id="task_id",
            )
            async for chunk in response:
                yield chunk


        asyncio.run(main())
        """
        async with self._raw_client.stream(task_id, request_options=request_options) as r:
            async for _chunk in r.data:
                yield _chunk

    async def list_system_folder_types(
        self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[SystemFolderTypeResponse]:
        """
        Get all registered system folder types with their configurations for a task.

        Parameters
        ----------
        task_id : str

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

        Returns
        -------
        typing.List[SystemFolderTypeResponse]
            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.tasks.list_system_folder_types(
                task_id="task_id",
            )


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

    async def get_system_folder(
        self, task_id: str, folder_type: SystemFolderType, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[SystemFolderResponse]:
        """
        Get a task's system folder record by type.

        Parameters
        ----------
        task_id : str

        folder_type : SystemFolderType

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

        Returns
        -------
        typing.Optional[SystemFolderResponse]
            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.tasks.get_system_folder(
                task_id="task_id",
                folder_type="dot_claude",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_system_folder(task_id, folder_type, request_options=request_options)
        return _response.data

    async def get_system_folder_download_url(
        self,
        task_id: str,
        folder_type: SystemFolderType,
        *,
        request: typing.Optional[PresignedUrlRequest] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[PresignedUrlResponse]:
        """
        Get a presigned URL for direct download of a system folder archive from GCS.

        Parameters
        ----------
        task_id : str

        folder_type : SystemFolderType

        request : typing.Optional[PresignedUrlRequest]

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

        Returns
        -------
        typing.Optional[PresignedUrlResponse]
            Successful Response

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminalUseBase, PresignedUrlRequest

        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.tasks.get_system_folder_download_url(
                task_id="task_id",
                folder_type="dot_claude",
                request=PresignedUrlRequest(),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_system_folder_download_url(
            task_id, folder_type, request=request, request_options=request_options
        )
        return _response.data

    async def system_folder_sync_complete(
        self,
        task_id: str,
        folder_type: SystemFolderType,
        *,
        direction: str,
        status: str,
        sync_id: str,
        archive_checksum: typing.Optional[str] = OMIT,
        archive_size_bytes: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SystemFolderSyncCompleteResponse:
        """
        Complete a system folder sync operation and update metadata.

        Parameters
        ----------
        task_id : str

        folder_type : SystemFolderType

        direction : str
            Sync direction: 'UP' or 'DOWN'.

        status : str
            Sync status: 'SUCCESS' or 'FAILED'.

        sync_id : str
            Unique ID for this sync operation (idempotency key).

        archive_checksum : typing.Optional[str]
            SHA256 checksum of the archive.

        archive_size_bytes : typing.Optional[int]
            Size of the archive in bytes.

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

        Returns
        -------
        SystemFolderSyncCompleteResponse
            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.tasks.system_folder_sync_complete(
                task_id="task_id",
                folder_type="dot_claude",
                direction="direction",
                status="status",
                sync_id="sync_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.system_folder_sync_complete(
            task_id,
            folder_type,
            direction=direction,
            status=status,
            sync_id=sync_id,
            archive_checksum=archive_checksum,
            archive_size_bytes=archive_size_bytes,
            request_options=request_options,
        )
        return _response.data

    async def get_system_folder_upload_url(
        self,
        task_id: str,
        folder_type: SystemFolderType,
        *,
        request: typing.Optional[PresignedUrlRequest] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PresignedUrlResponse:
        """
        Get a presigned URL for direct upload of a system folder archive to GCS.

        Parameters
        ----------
        task_id : str

        folder_type : SystemFolderType

        request : typing.Optional[PresignedUrlRequest]

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

        Returns
        -------
        PresignedUrlResponse
            Successful Response

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminalUseBase, PresignedUrlRequest

        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.tasks.get_system_folder_upload_url(
                task_id="task_id",
                folder_type="dot_claude",
                request=PresignedUrlRequest(),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_system_folder_upload_url(
            task_id, folder_type, request=request, request_options=request_options
        )
        return _response.data
