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

from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
from truffle.hyphae import context_pb2 as truffle_dot_hyphae_dot_context__pb2
from truffle.hyphae import contextmgmt_pb2 as truffle_dot_hyphae_dot_contextmgmt__pb2
from truffle.hyphae import hooks_pb2 as truffle_dot_hyphae_dot_hooks__pb2
from truffle.hyphae import serializestate_pb2 as truffle_dot_hyphae_dot_serializestate__pb2

GRPC_GENERATED_VERSION = '1.72.0'
GRPC_VERSION = grpc.__version__
_version_not_supported = False

try:
    from grpc._utilities import first_version_is_lower
    _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
except ImportError:
    _version_not_supported = True

if _version_not_supported:
    raise RuntimeError(
        f'The grpc package installed is at version {GRPC_VERSION},'
        + f' but the generated code in truffle/hyphae/runtime_svc_pb2_grpc.py depends on'
        + f' grpcio>={GRPC_GENERATED_VERSION}.'
        + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
        + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
    )


class HyphaeRuntimeStub(object):
    """
    The `HyphaeRuntime` service defines the standard set of hooks that an
    application must implement. The Truffle agent calls these methods to
    manage the app's lifecycle, build model contexts, and handle state,
    allowing for deep customization of the agentic process, which can be leveraged by using Hyphae (our SDK).
    """

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

        Args:
            channel: A grpc.Channel.
        """
        self.OnAppStart = channel.unary_unary(
                '/truffle.hyphae.HyphaeRuntime/OnAppStart',
                request_serializer=truffle_dot_hyphae_dot_hooks__pb2.OnAppStartRequest.SerializeToString,
                response_deserializer=truffle_dot_hyphae_dot_hooks__pb2.OnAppStartResponse.FromString,
                _registered_method=True)
        self.OnLoopStart = channel.unary_unary(
                '/truffle.hyphae.HyphaeRuntime/OnLoopStart',
                request_serializer=truffle_dot_hyphae_dot_hooks__pb2.OnLoopStartRequest.SerializeToString,
                response_deserializer=truffle_dot_hyphae_dot_hooks__pb2.OnLoopStartResponse.FromString,
                _registered_method=True)
        self.BuildContext = channel.unary_unary(
                '/truffle.hyphae.HyphaeRuntime/BuildContext',
                request_serializer=truffle_dot_hyphae_dot_contextmgmt__pb2.BuildContextRequest.SerializeToString,
                response_deserializer=truffle_dot_hyphae_dot_contextmgmt__pb2.BuildContextResponse.FromString,
                _registered_method=True)
        self.OnCtxManage = channel.unary_unary(
                '/truffle.hyphae.HyphaeRuntime/OnCtxManage',
                request_serializer=truffle_dot_hyphae_dot_contextmgmt__pb2.ManageContextRequest.SerializeToString,
                response_deserializer=truffle_dot_hyphae_dot_context__pb2.Context.FromString,
                _registered_method=True)
        self.LoadState = channel.unary_unary(
                '/truffle.hyphae.HyphaeRuntime/LoadState',
                request_serializer=truffle_dot_hyphae_dot_serializestate__pb2.LoadStateRequest.SerializeToString,
                response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
                _registered_method=True)
        self.SaveState = channel.unary_unary(
                '/truffle.hyphae.HyphaeRuntime/SaveState',
                request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
                response_deserializer=truffle_dot_hyphae_dot_serializestate__pb2.SaveStateResponse.FromString,
                _registered_method=True)
        self.SetTaskFlags = channel.unary_unary(
                '/truffle.hyphae.HyphaeRuntime/SetTaskFlags',
                request_serializer=truffle_dot_hyphae_dot_hooks__pb2.SetTaskFlagsRequest.SerializeToString,
                response_deserializer=truffle_dot_hyphae_dot_hooks__pb2.SetTaskFlagsResponse.FromString,
                _registered_method=True)
        self.GetAppInfo = channel.unary_unary(
                '/truffle.hyphae.HyphaeRuntime/GetAppInfo',
                request_serializer=truffle_dot_hyphae_dot_hooks__pb2.AppInfoRequest.SerializeToString,
                response_deserializer=truffle_dot_hyphae_dot_hooks__pb2.AppInfoResponse.FromString,
                _registered_method=True)


class HyphaeRuntimeServicer(object):
    """
    The `HyphaeRuntime` service defines the standard set of hooks that an
    application must implement. The Truffle agent calls these methods to
    manage the app's lifecycle, build model contexts, and handle state,
    allowing for deep customization of the agentic process, which can be leveraged by using Hyphae (our SDK).
    """

    def OnAppStart(self, request, context):
        """Called once when the application is first started to perform initialization.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def OnLoopStart(self, request, context):
        """Called at the beginning of each agentic loop iteration, allowing the app
        to dynamically adjust the context or available tools.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def BuildContext(self, request, context):
        """Called to construct the final prompt. The app can modify the context,
        or build a raw string or conversation object from it.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def OnCtxManage(self, request, context):
        """Called when the context size exceeds the model's limit, delegating the
        context truncation logic to the app.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def LoadState(self, request, context):
        """Called to instruct the app to restore its state from the provided data.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def SaveState(self, request, context):
        """Called to request that the app serialize and return its current state for persistence.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def SetTaskFlags(self, request, context):
        """Informs the app about changes to the task's flags, allowing it to
        adapt its behavior accordingly.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def GetAppInfo(self, request, context):
        """Retrieves the application's metadata.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_HyphaeRuntimeServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'OnAppStart': grpc.unary_unary_rpc_method_handler(
                    servicer.OnAppStart,
                    request_deserializer=truffle_dot_hyphae_dot_hooks__pb2.OnAppStartRequest.FromString,
                    response_serializer=truffle_dot_hyphae_dot_hooks__pb2.OnAppStartResponse.SerializeToString,
            ),
            'OnLoopStart': grpc.unary_unary_rpc_method_handler(
                    servicer.OnLoopStart,
                    request_deserializer=truffle_dot_hyphae_dot_hooks__pb2.OnLoopStartRequest.FromString,
                    response_serializer=truffle_dot_hyphae_dot_hooks__pb2.OnLoopStartResponse.SerializeToString,
            ),
            'BuildContext': grpc.unary_unary_rpc_method_handler(
                    servicer.BuildContext,
                    request_deserializer=truffle_dot_hyphae_dot_contextmgmt__pb2.BuildContextRequest.FromString,
                    response_serializer=truffle_dot_hyphae_dot_contextmgmt__pb2.BuildContextResponse.SerializeToString,
            ),
            'OnCtxManage': grpc.unary_unary_rpc_method_handler(
                    servicer.OnCtxManage,
                    request_deserializer=truffle_dot_hyphae_dot_contextmgmt__pb2.ManageContextRequest.FromString,
                    response_serializer=truffle_dot_hyphae_dot_context__pb2.Context.SerializeToString,
            ),
            'LoadState': grpc.unary_unary_rpc_method_handler(
                    servicer.LoadState,
                    request_deserializer=truffle_dot_hyphae_dot_serializestate__pb2.LoadStateRequest.FromString,
                    response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
            ),
            'SaveState': grpc.unary_unary_rpc_method_handler(
                    servicer.SaveState,
                    request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
                    response_serializer=truffle_dot_hyphae_dot_serializestate__pb2.SaveStateResponse.SerializeToString,
            ),
            'SetTaskFlags': grpc.unary_unary_rpc_method_handler(
                    servicer.SetTaskFlags,
                    request_deserializer=truffle_dot_hyphae_dot_hooks__pb2.SetTaskFlagsRequest.FromString,
                    response_serializer=truffle_dot_hyphae_dot_hooks__pb2.SetTaskFlagsResponse.SerializeToString,
            ),
            'GetAppInfo': grpc.unary_unary_rpc_method_handler(
                    servicer.GetAppInfo,
                    request_deserializer=truffle_dot_hyphae_dot_hooks__pb2.AppInfoRequest.FromString,
                    response_serializer=truffle_dot_hyphae_dot_hooks__pb2.AppInfoResponse.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'truffle.hyphae.HyphaeRuntime', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('truffle.hyphae.HyphaeRuntime', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class HyphaeRuntime(object):
    """
    The `HyphaeRuntime` service defines the standard set of hooks that an
    application must implement. The Truffle agent calls these methods to
    manage the app's lifecycle, build model contexts, and handle state,
    allowing for deep customization of the agentic process, which can be leveraged by using Hyphae (our SDK).
    """

    @staticmethod
    def OnAppStart(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,
            '/truffle.hyphae.HyphaeRuntime/OnAppStart',
            truffle_dot_hyphae_dot_hooks__pb2.OnAppStartRequest.SerializeToString,
            truffle_dot_hyphae_dot_hooks__pb2.OnAppStartResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def OnLoopStart(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,
            '/truffle.hyphae.HyphaeRuntime/OnLoopStart',
            truffle_dot_hyphae_dot_hooks__pb2.OnLoopStartRequest.SerializeToString,
            truffle_dot_hyphae_dot_hooks__pb2.OnLoopStartResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def BuildContext(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,
            '/truffle.hyphae.HyphaeRuntime/BuildContext',
            truffle_dot_hyphae_dot_contextmgmt__pb2.BuildContextRequest.SerializeToString,
            truffle_dot_hyphae_dot_contextmgmt__pb2.BuildContextResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def OnCtxManage(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,
            '/truffle.hyphae.HyphaeRuntime/OnCtxManage',
            truffle_dot_hyphae_dot_contextmgmt__pb2.ManageContextRequest.SerializeToString,
            truffle_dot_hyphae_dot_context__pb2.Context.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def LoadState(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,
            '/truffle.hyphae.HyphaeRuntime/LoadState',
            truffle_dot_hyphae_dot_serializestate__pb2.LoadStateRequest.SerializeToString,
            google_dot_protobuf_dot_empty__pb2.Empty.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def SaveState(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,
            '/truffle.hyphae.HyphaeRuntime/SaveState',
            google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
            truffle_dot_hyphae_dot_serializestate__pb2.SaveStateResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def SetTaskFlags(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,
            '/truffle.hyphae.HyphaeRuntime/SetTaskFlags',
            truffle_dot_hyphae_dot_hooks__pb2.SetTaskFlagsRequest.SerializeToString,
            truffle_dot_hyphae_dot_hooks__pb2.SetTaskFlagsResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def GetAppInfo(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,
            '/truffle.hyphae.HyphaeRuntime/GetAppInfo',
            truffle_dot_hyphae_dot_hooks__pb2.AppInfoRequest.SerializeToString,
            truffle_dot_hyphae_dot_hooks__pb2.AppInfoResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)
