# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

from ai.stigmer.agentic.agentexecution.v1 import api_pb2 as ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_api__pb2
from ai.stigmer.agentic.agentexecution.v1 import io_pb2 as ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2


class AgentExecutionQueryControllerStub(object):
    """AgentExecutionQueryController handles read operations for agent executions.
    """

    def __init__(self, channel):
        """Constructor.

        Args:
            channel: A grpc.Channel.
        """
        self.get = channel.unary_unary(
                '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/get',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.AgentExecutionId.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_api__pb2.AgentExecution.FromString,
                _registered_method=True)
        self.list = channel.unary_unary(
                '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/list',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.ListAgentExecutionsRequest.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.AgentExecutionList.FromString,
                _registered_method=True)
        self.listBySession = channel.unary_unary(
                '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/listBySession',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.ListAgentExecutionsBySessionRequest.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.AgentExecutionList.FromString,
                _registered_method=True)
        self.subscribe = channel.unary_stream(
                '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/subscribe',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.AgentExecutionId.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_api__pb2.AgentExecution.FromString,
                _registered_method=True)
        self.getArtifactDownloadUrl = channel.unary_unary(
                '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/getArtifactDownloadUrl',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetArtifactDownloadUrlRequest.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetArtifactDownloadUrlResponse.FromString,
                _registered_method=True)
        self.getArtifactContent = channel.unary_unary(
                '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/getArtifactContent',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetArtifactContentRequest.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetArtifactContentResponse.FromString,
                _registered_method=True)
        self.getSessionUsageReport = channel.unary_unary(
                '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/getSessionUsageReport',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetSessionUsageReportInput.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetSessionUsageReportOutput.FromString,
                _registered_method=True)
        self.getAgentUsageReport = channel.unary_unary(
                '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/getAgentUsageReport',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetAgentUsageReportInput.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetAgentUsageReportOutput.FromString,
                _registered_method=True)
        self.getOrgUsageReport = channel.unary_unary(
                '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/getOrgUsageReport',
                request_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetOrgUsageReportInput.SerializeToString,
                response_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetOrgUsageReportOutput.FromString,
                _registered_method=True)


class AgentExecutionQueryControllerServicer(object):
    """AgentExecutionQueryController handles read operations for agent executions.
    """

    def get(self, request, context):
        """Get a single agent execution by ID.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def list(self, request, context):
        """List all agent executions with pagination and optional filtering.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def listBySession(self, request, context):
        """List all executions in a specific session.
        Authorization is handled in handler via FGA query for authorized agent_execution_ids,
        then filtered by session_id. This ensures consistent authorization pattern across all list operations.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def subscribe(self, request, context):
        """Subscribe to real-time execution updates (streaming).
        Authorization is handled by the FJ model via proto configuration.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def getArtifactDownloadUrl(self, request, context):
        """─────────────────────────────────────────────────────────────────────────────
        Artifact Lifecycle Operations

        These RPCs support downloading artifacts created by agent executions.
        ─────────────────────────────────────────────────────────────────────────────

        Get a presigned download URL for an execution artifact.

        Returns a time-limited URL for downloading an artifact published by
        an agent during execution. The URL can be used with a simple HTTP GET
        request without authentication.

        ## Authorization

        Requires can_view permission on the execution. This ensures users can
        only download artifacts from executions they have access to.

        ## Security

        The storage_key is validated to ensure it belongs to the specified
        execution. Keys must start with "artifacts/{execution_id}/" to prevent
        path traversal attacks.

        ## URL Expiration

        Download URLs expire after 7 days (configurable). After expiration,
        call this endpoint again to get a fresh URL.

        ## Use Cases

        - CLI downloading agent-created files
        - Web UI providing download links for artifacts
        - Refreshing expired download URLs

        ## Example Flow

        1. Get execution via AgentExecutionQueryController.get
        2. Find artifact in status.artifacts[]
        3. Call getArtifactDownloadUrl with execution_id and storage_key
        4. Use returned download_url for HTTP GET

        @since Artifact Lifecycle (Attachments & Artifacts)
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def getArtifactContent(self, request, context):
        """Read the raw content of an execution artifact.

        Returns artifact bytes through the Stigmer API, eliminating CORS
        concerns for SDK consumers who need to read content programmatically
        (e.g., YAML parsing for resource detection, in-app preview rendering).

        For direct file downloads, use getArtifactDownloadUrl instead — it
        returns a presigned R2 URL that avoids proxying bytes through the server.

        ## Authorization

        Requires can_view permission on the execution. This ensures users can
        only read artifacts from executions they have access to.

        ## Security

        The storage_key is validated to ensure it belongs to the specified
        execution. Keys must start with "artifacts/{execution_id}/" to prevent
        path traversal attacks.

        ## Size Limit

        Content is truncated to max_bytes (default: 512 KB). The response
        includes total_size_bytes and a truncated flag so callers can decide
        whether to offer a full download via getArtifactDownloadUrl.

        ## Example Flow

        1. Get execution via AgentExecutionQueryController.get
        2. Find artifact in status.artifacts[]
        3. Call getArtifactContent with execution_id and storage_key
        4. Decode content bytes as UTF-8 for text artifacts
        5. Parse YAML to detect Stigmer resource kind (Agent, McpServer, etc.)

        @since Artifact Lifecycle (Attachments & Artifacts)
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def getSessionUsageReport(self, request, context):
        """─────────────────────────────────────────────────────────────────────────────
        Usage Report Operations

        These RPCs provide cost and token consumption visibility at session,
        agent, and organization levels. All data is derived from AgentExecution
        records with different aggregation scopes.
        ─────────────────────────────────────────────────────────────────────────────

        Get usage report for a session (all executions in a session).
        Returns aggregated tokens, cost, cache hit rate, and per-execution breakdown.

        Authorization is handled in handler — caller must have can_view on
        all executions in the session (same pattern as listBySession).
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def getAgentUsageReport(self, request, context):
        """Get usage report for an agent (all sessions for an agent in a time range).
        Returns aggregated tokens, cost, and per-session breakdown with pagination.

        Authorization is handled in handler — caller must have can_view on the agent.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def getOrgUsageReport(self, request, context):
        """Get usage report for an organization (all agents in a time range).
        Returns org-wide totals, top agents by cost, model breakdown, and daily trend.

        Authorization is handled in handler — caller must be org member.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_AgentExecutionQueryControllerServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'get': grpc.unary_unary_rpc_method_handler(
                    servicer.get,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.AgentExecutionId.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_api__pb2.AgentExecution.SerializeToString,
            ),
            'list': grpc.unary_unary_rpc_method_handler(
                    servicer.list,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.ListAgentExecutionsRequest.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.AgentExecutionList.SerializeToString,
            ),
            'listBySession': grpc.unary_unary_rpc_method_handler(
                    servicer.listBySession,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.ListAgentExecutionsBySessionRequest.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.AgentExecutionList.SerializeToString,
            ),
            'subscribe': grpc.unary_stream_rpc_method_handler(
                    servicer.subscribe,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.AgentExecutionId.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_api__pb2.AgentExecution.SerializeToString,
            ),
            'getArtifactDownloadUrl': grpc.unary_unary_rpc_method_handler(
                    servicer.getArtifactDownloadUrl,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetArtifactDownloadUrlRequest.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetArtifactDownloadUrlResponse.SerializeToString,
            ),
            'getArtifactContent': grpc.unary_unary_rpc_method_handler(
                    servicer.getArtifactContent,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetArtifactContentRequest.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetArtifactContentResponse.SerializeToString,
            ),
            'getSessionUsageReport': grpc.unary_unary_rpc_method_handler(
                    servicer.getSessionUsageReport,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetSessionUsageReportInput.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetSessionUsageReportOutput.SerializeToString,
            ),
            'getAgentUsageReport': grpc.unary_unary_rpc_method_handler(
                    servicer.getAgentUsageReport,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetAgentUsageReportInput.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetAgentUsageReportOutput.SerializeToString,
            ),
            'getOrgUsageReport': grpc.unary_unary_rpc_method_handler(
                    servicer.getOrgUsageReport,
                    request_deserializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetOrgUsageReportInput.FromString,
                    response_serializer=ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetOrgUsageReportOutput.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class AgentExecutionQueryController(object):
    """AgentExecutionQueryController handles read operations for agent executions.
    """

    @staticmethod
    def get(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/get',
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.AgentExecutionId.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_api__pb2.AgentExecution.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def list(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/list',
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.ListAgentExecutionsRequest.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.AgentExecutionList.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def listBySession(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/listBySession',
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.ListAgentExecutionsBySessionRequest.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.AgentExecutionList.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def subscribe(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_stream(
            request,
            target,
            '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/subscribe',
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.AgentExecutionId.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_api__pb2.AgentExecution.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def getArtifactDownloadUrl(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/getArtifactDownloadUrl',
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetArtifactDownloadUrlRequest.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetArtifactDownloadUrlResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def getArtifactContent(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/getArtifactContent',
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetArtifactContentRequest.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetArtifactContentResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def getSessionUsageReport(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/getSessionUsageReport',
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetSessionUsageReportInput.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetSessionUsageReportOutput.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def getAgentUsageReport(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/getAgentUsageReport',
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetAgentUsageReportInput.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetAgentUsageReportOutput.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def getOrgUsageReport(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/ai.stigmer.agentic.agentexecution.v1.AgentExecutionQueryController/getOrgUsageReport',
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetOrgUsageReportInput.SerializeToString,
            ai_dot_stigmer_dot_agentic_dot_agentexecution_dot_v1_dot_io__pb2.GetOrgUsageReportOutput.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)
