diff --git a/python/.gitignore b/python/.gitignore index 65be202c2..186e847cc 100644 --- a/python/.gitignore +++ b/python/.gitignore @@ -164,10 +164,6 @@ cython_debug/ /docs/src/reference .DS_Store -# Generated proto files -src/agnext/worker/protos/agent* -src/agnext/application/protos/agent* - # Generated log files log.jsonl diff --git a/python/src/agnext/application/protos/agent_worker_pb2.py b/python/src/agnext/application/protos/agent_worker_pb2.py new file mode 100644 index 000000000..075028366 --- /dev/null +++ b/python/src/agnext/application/protos/agent_worker_pb2.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: agent_worker.proto +# Protobuf Python Version: 5.26.1 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12\x61gent_worker.proto\x12\x06\x61gents\"*\n\x07\x41gentId\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x11\n\tnamespace\x18\x02 \x01(\t\"\xe5\x01\n\nRpcRequest\x12\x12\n\nrequest_id\x18\x01 \x01(\t\x12\x1f\n\x06source\x18\x02 \x01(\x0b\x32\x0f.agents.AgentId\x12\x1f\n\x06target\x18\x03 \x01(\x0b\x32\x0f.agents.AgentId\x12\x0e\n\x06method\x18\x04 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x05 \x01(\t\x12\x32\n\x08metadata\x18\x06 \x03(\x0b\x32 .agents.RpcRequest.MetadataEntry\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xa6\x01\n\x0bRpcResponse\x12\x12\n\nrequest_id\x18\x01 \x01(\t\x12\x0e\n\x06result\x18\x02 \x01(\t\x12\r\n\x05\x65rror\x18\x03 \x01(\t\x12\x33\n\x08metadata\x18\x04 \x03(\x0b\x32!.agents.RpcResponse.MetadataEntry\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x96\x01\n\x05\x45vent\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x0c\n\x04type\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\t\x12-\n\x08metadata\x18\x04 \x03(\x0b\x32\x1b.agents.Event.MetadataEntry\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"!\n\x11RegisterAgentType\x12\x0c\n\x04type\x18\x01 \x01(\t\"\xbc\x01\n\x07Message\x12%\n\x07request\x18\x01 \x01(\x0b\x32\x12.agents.RpcRequestH\x00\x12\'\n\x08response\x18\x02 \x01(\x0b\x32\x13.agents.RpcResponseH\x00\x12\x1e\n\x05\x65vent\x18\x03 \x01(\x0b\x32\r.agents.EventH\x00\x12\x36\n\x11registerAgentType\x18\x04 \x01(\x0b\x32\x19.agents.RegisterAgentTypeH\x00\x42\t\n\x07message2?\n\x08\x41gentRpc\x12\x33\n\x0bOpenChannel\x12\x0f.agents.Message\x1a\x0f.agents.Message(\x01\x30\x01\x62\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'agent_worker_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + DESCRIPTOR._loaded_options = None + _globals['_RPCREQUEST_METADATAENTRY']._loaded_options = None + _globals['_RPCREQUEST_METADATAENTRY']._serialized_options = b'8\001' + _globals['_RPCRESPONSE_METADATAENTRY']._loaded_options = None + _globals['_RPCRESPONSE_METADATAENTRY']._serialized_options = b'8\001' + _globals['_EVENT_METADATAENTRY']._loaded_options = None + _globals['_EVENT_METADATAENTRY']._serialized_options = b'8\001' + _globals['_AGENTID']._serialized_start=30 + _globals['_AGENTID']._serialized_end=72 + _globals['_RPCREQUEST']._serialized_start=75 + _globals['_RPCREQUEST']._serialized_end=304 + _globals['_RPCREQUEST_METADATAENTRY']._serialized_start=257 + _globals['_RPCREQUEST_METADATAENTRY']._serialized_end=304 + _globals['_RPCRESPONSE']._serialized_start=307 + _globals['_RPCRESPONSE']._serialized_end=473 + _globals['_RPCRESPONSE_METADATAENTRY']._serialized_start=257 + _globals['_RPCRESPONSE_METADATAENTRY']._serialized_end=304 + _globals['_EVENT']._serialized_start=476 + _globals['_EVENT']._serialized_end=626 + _globals['_EVENT_METADATAENTRY']._serialized_start=257 + _globals['_EVENT_METADATAENTRY']._serialized_end=304 + _globals['_REGISTERAGENTTYPE']._serialized_start=628 + _globals['_REGISTERAGENTTYPE']._serialized_end=661 + _globals['_MESSAGE']._serialized_start=664 + _globals['_MESSAGE']._serialized_end=852 + _globals['_AGENTRPC']._serialized_start=854 + _globals['_AGENTRPC']._serialized_end=917 +# @@protoc_insertion_point(module_scope) diff --git a/python/src/agnext/application/protos/agent_worker_pb2.pyi b/python/src/agnext/application/protos/agent_worker_pb2.pyi new file mode 100644 index 000000000..b7dc151ba --- /dev/null +++ b/python/src/agnext/application/protos/agent_worker_pb2.pyi @@ -0,0 +1,210 @@ +""" +@generated by mypy-protobuf. Do not edit manually! +isort:skip_file +""" + +import builtins +import collections.abc +import google.protobuf.descriptor +import google.protobuf.internal.containers +import google.protobuf.message +import typing + +DESCRIPTOR: google.protobuf.descriptor.FileDescriptor + +@typing.final +class AgentId(google.protobuf.message.Message): + """TODO: update""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + NAME_FIELD_NUMBER: builtins.int + NAMESPACE_FIELD_NUMBER: builtins.int + name: builtins.str + namespace: builtins.str + def __init__( + self, + *, + name: builtins.str = ..., + namespace: builtins.str = ..., + ) -> None: ... + def ClearField(self, field_name: typing.Literal["name", b"name", "namespace", b"namespace"]) -> None: ... + +global___AgentId = AgentId + +@typing.final +class RpcRequest(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + @typing.final + class MetadataEntry(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + KEY_FIELD_NUMBER: builtins.int + VALUE_FIELD_NUMBER: builtins.int + key: builtins.str + value: builtins.str + def __init__( + self, + *, + key: builtins.str = ..., + value: builtins.str = ..., + ) -> None: ... + def ClearField(self, field_name: typing.Literal["key", b"key", "value", b"value"]) -> None: ... + + REQUEST_ID_FIELD_NUMBER: builtins.int + SOURCE_FIELD_NUMBER: builtins.int + TARGET_FIELD_NUMBER: builtins.int + METHOD_FIELD_NUMBER: builtins.int + DATA_FIELD_NUMBER: builtins.int + METADATA_FIELD_NUMBER: builtins.int + request_id: builtins.str + method: builtins.str + data: builtins.str + @property + def source(self) -> global___AgentId: ... + @property + def target(self) -> global___AgentId: ... + @property + def metadata(self) -> google.protobuf.internal.containers.ScalarMap[builtins.str, builtins.str]: ... + def __init__( + self, + *, + request_id: builtins.str = ..., + source: global___AgentId | None = ..., + target: global___AgentId | None = ..., + method: builtins.str = ..., + data: builtins.str = ..., + metadata: collections.abc.Mapping[builtins.str, builtins.str] | None = ..., + ) -> None: ... + def HasField(self, field_name: typing.Literal["source", b"source", "target", b"target"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["data", b"data", "metadata", b"metadata", "method", b"method", "request_id", b"request_id", "source", b"source", "target", b"target"]) -> None: ... + +global___RpcRequest = RpcRequest + +@typing.final +class RpcResponse(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + @typing.final + class MetadataEntry(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + KEY_FIELD_NUMBER: builtins.int + VALUE_FIELD_NUMBER: builtins.int + key: builtins.str + value: builtins.str + def __init__( + self, + *, + key: builtins.str = ..., + value: builtins.str = ..., + ) -> None: ... + def ClearField(self, field_name: typing.Literal["key", b"key", "value", b"value"]) -> None: ... + + REQUEST_ID_FIELD_NUMBER: builtins.int + RESULT_FIELD_NUMBER: builtins.int + ERROR_FIELD_NUMBER: builtins.int + METADATA_FIELD_NUMBER: builtins.int + request_id: builtins.str + result: builtins.str + error: builtins.str + @property + def metadata(self) -> google.protobuf.internal.containers.ScalarMap[builtins.str, builtins.str]: ... + def __init__( + self, + *, + request_id: builtins.str = ..., + result: builtins.str = ..., + error: builtins.str = ..., + metadata: collections.abc.Mapping[builtins.str, builtins.str] | None = ..., + ) -> None: ... + def ClearField(self, field_name: typing.Literal["error", b"error", "metadata", b"metadata", "request_id", b"request_id", "result", b"result"]) -> None: ... + +global___RpcResponse = RpcResponse + +@typing.final +class Event(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + @typing.final + class MetadataEntry(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + KEY_FIELD_NUMBER: builtins.int + VALUE_FIELD_NUMBER: builtins.int + key: builtins.str + value: builtins.str + def __init__( + self, + *, + key: builtins.str = ..., + value: builtins.str = ..., + ) -> None: ... + def ClearField(self, field_name: typing.Literal["key", b"key", "value", b"value"]) -> None: ... + + NAMESPACE_FIELD_NUMBER: builtins.int + TYPE_FIELD_NUMBER: builtins.int + DATA_FIELD_NUMBER: builtins.int + METADATA_FIELD_NUMBER: builtins.int + namespace: builtins.str + type: builtins.str + data: builtins.str + @property + def metadata(self) -> google.protobuf.internal.containers.ScalarMap[builtins.str, builtins.str]: ... + def __init__( + self, + *, + namespace: builtins.str = ..., + type: builtins.str = ..., + data: builtins.str = ..., + metadata: collections.abc.Mapping[builtins.str, builtins.str] | None = ..., + ) -> None: ... + def ClearField(self, field_name: typing.Literal["data", b"data", "metadata", b"metadata", "namespace", b"namespace", "type", b"type"]) -> None: ... + +global___Event = Event + +@typing.final +class RegisterAgentType(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + TYPE_FIELD_NUMBER: builtins.int + type: builtins.str + def __init__( + self, + *, + type: builtins.str = ..., + ) -> None: ... + def ClearField(self, field_name: typing.Literal["type", b"type"]) -> None: ... + +global___RegisterAgentType = RegisterAgentType + +@typing.final +class Message(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + REQUEST_FIELD_NUMBER: builtins.int + RESPONSE_FIELD_NUMBER: builtins.int + EVENT_FIELD_NUMBER: builtins.int + REGISTERAGENTTYPE_FIELD_NUMBER: builtins.int + @property + def request(self) -> global___RpcRequest: ... + @property + def response(self) -> global___RpcResponse: ... + @property + def event(self) -> global___Event: ... + @property + def registerAgentType(self) -> global___RegisterAgentType: ... + def __init__( + self, + *, + request: global___RpcRequest | None = ..., + response: global___RpcResponse | None = ..., + event: global___Event | None = ..., + registerAgentType: global___RegisterAgentType | None = ..., + ) -> None: ... + def HasField(self, field_name: typing.Literal["event", b"event", "message", b"message", "registerAgentType", b"registerAgentType", "request", b"request", "response", b"response"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["event", b"event", "message", b"message", "registerAgentType", b"registerAgentType", "request", b"request", "response", b"response"]) -> None: ... + def WhichOneof(self, oneof_group: typing.Literal["message", b"message"]) -> typing.Literal["request", "response", "event", "registerAgentType"] | None: ... + +global___Message = Message diff --git a/python/src/agnext/application/protos/agent_worker_pb2_grpc.py b/python/src/agnext/application/protos/agent_worker_pb2_grpc.py new file mode 100644 index 000000000..5a458aea2 --- /dev/null +++ b/python/src/agnext/application/protos/agent_worker_pb2_grpc.py @@ -0,0 +1,102 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc +import warnings + +import agent_worker_pb2 as agent__worker__pb2 + +GRPC_GENERATED_VERSION = '1.65.5' +GRPC_VERSION = grpc.__version__ +EXPECTED_ERROR_RELEASE = '1.66.0' +SCHEDULED_RELEASE_DATE = 'August 6, 2024' +_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: + warnings.warn( + f'The grpc package installed is at version {GRPC_VERSION},' + + f' but the generated code in agent_worker_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}.' + + f' This warning will become an error in {EXPECTED_ERROR_RELEASE},' + + f' scheduled for release on {SCHEDULED_RELEASE_DATE}.', + RuntimeWarning + ) + + +class AgentRpcStub(object): + """Missing associated documentation comment in .proto file.""" + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.OpenChannel = channel.stream_stream( + '/agents.AgentRpc/OpenChannel', + request_serializer=agent__worker__pb2.Message.SerializeToString, + response_deserializer=agent__worker__pb2.Message.FromString, + _registered_method=True) + + +class AgentRpcServicer(object): + """Missing associated documentation comment in .proto file.""" + + def OpenChannel(self, request_iterator, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_AgentRpcServicer_to_server(servicer, server): + rpc_method_handlers = { + 'OpenChannel': grpc.stream_stream_rpc_method_handler( + servicer.OpenChannel, + request_deserializer=agent__worker__pb2.Message.FromString, + response_serializer=agent__worker__pb2.Message.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'agents.AgentRpc', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + server.add_registered_method_handlers('agents.AgentRpc', rpc_method_handlers) + + + # This class is part of an EXPERIMENTAL API. +class AgentRpc(object): + """Missing associated documentation comment in .proto file.""" + + @staticmethod + def OpenChannel(request_iterator, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.stream_stream( + request_iterator, + target, + '/agents.AgentRpc/OpenChannel', + agent__worker__pb2.Message.SerializeToString, + agent__worker__pb2.Message.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) diff --git a/python/src/agnext/application/protos/agent_worker_pb2_grpc.pyi b/python/src/agnext/application/protos/agent_worker_pb2_grpc.pyi new file mode 100644 index 000000000..1642ca2af --- /dev/null +++ b/python/src/agnext/application/protos/agent_worker_pb2_grpc.pyi @@ -0,0 +1,41 @@ +""" +@generated by mypy-protobuf. Do not edit manually! +isort:skip_file +""" + +import abc +import agent_worker_pb2 +import collections.abc +import grpc +import grpc.aio +import typing + +_T = typing.TypeVar("_T") + +class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): ... + +class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore[misc, type-arg] + ... + +class AgentRpcStub: + def __init__(self, channel: typing.Union[grpc.Channel, grpc.aio.Channel]) -> None: ... + OpenChannel: grpc.StreamStreamMultiCallable[ + agent_worker_pb2.Message, + agent_worker_pb2.Message, + ] + +class AgentRpcAsyncStub: + OpenChannel: grpc.aio.StreamStreamMultiCallable[ + agent_worker_pb2.Message, + agent_worker_pb2.Message, + ] + +class AgentRpcServicer(metaclass=abc.ABCMeta): + @abc.abstractmethod + def OpenChannel( + self, + request_iterator: _MaybeAsyncIterator[agent_worker_pb2.Message], + context: _ServicerContext, + ) -> typing.Union[collections.abc.Iterator[agent_worker_pb2.Message], collections.abc.AsyncIterator[agent_worker_pb2.Message]]: ... + +def add_AgentRpcServicer_to_server(servicer: AgentRpcServicer, server: typing.Union[grpc.Server, grpc.aio.Server]) -> None: ...