diff --git a/livekit-protocol/generate_proto.sh b/livekit-protocol/generate_proto.sh index 003850a6..f1794004 100755 --- a/livekit-protocol/generate_proto.sh +++ b/livekit-protocol/generate_proto.sh @@ -18,6 +18,7 @@ set -e + API_PROTOCOL=./protocol/protobufs API_OUT_PYTHON=./livekit/protocol @@ -37,6 +38,7 @@ protoc \ $API_PROTOCOL/livekit_analytics.proto \ $API_PROTOCOL/livekit_rtc.proto \ $API_PROTOCOL/agent/livekit_agent_session.proto \ + $API_PROTOCOL/agent/livekit_agent_text.proto \ $API_PROTOCOL/logger/options.proto \ $API_PROTOCOL/livekit_connector_whatsapp.proto \ $API_PROTOCOL/livekit_connector_twilio.proto \ @@ -86,6 +88,8 @@ mv "$API_OUT_PYTHON/livekit_connector_pb2.pyi" "$API_OUT_PYTHON/connector.pyi" mkdir -p "$API_OUT_PYTHON/agent_pb" mv "$API_OUT_PYTHON/agent/livekit_agent_session_pb2.py" "$API_OUT_PYTHON/agent_pb/agent_session.py" mv "$API_OUT_PYTHON/agent/livekit_agent_session_pb2.pyi" "$API_OUT_PYTHON/agent_pb/agent_session.pyi" +mv "$API_OUT_PYTHON/agent/livekit_agent_text_pb2.py" "$API_OUT_PYTHON/agent_pb/agent_text.py" +mv "$API_OUT_PYTHON/agent/livekit_agent_text_pb2.pyi" "$API_OUT_PYTHON/agent_pb/agent_text.pyi" mkdir -p "$API_OUT_PYTHON/logger_pb" mv "$API_OUT_PYTHON/logger/options_pb2.py" "$API_OUT_PYTHON/logger_pb/options.py" @@ -101,5 +105,8 @@ find "$API_OUT_PYTHON" -maxdepth 1 -name '*.py' -o -name '*.pyi' | xargs perl -i # fix logger imports for files in subdirectories (need parent-relative import) find "$API_OUT_PYTHON" -mindepth 2 -name '*.py' -o -name '*.pyi' | xargs perl -i -pe 's|from logger import options_pb2 as ([^ ]+)|from ..logger_pb import options as $1|g' +# fix `from agent import agent_xxx as xxx` to `from . import agent_xxx as xxx` +find "$API_OUT_PYTHON"/agent_pb -name '*.py' -o -name '*.pyi' | xargs perl -i -pe 's|from agent import (agent_\w+) as ([^ ]+)|from . import $1 as $2|g' + # fixes - error: ClassVar can only be used for assignments in class body [misc] perl -i -pe 's|^(\w+_FIELD_NUMBER): _ClassVar\[int\]|$1: int|g' "$API_OUT_PYTHON/logger_pb/options.pyi" \ No newline at end of file diff --git a/livekit-protocol/livekit/protocol/agent_pb/__init__.py b/livekit-protocol/livekit/protocol/agent_pb/__init__.py index 8947d3e4..39847bf8 100644 --- a/livekit-protocol/livekit/protocol/agent_pb/__init__.py +++ b/livekit-protocol/livekit/protocol/agent_pb/__init__.py @@ -1 +1 @@ -from . import agent_session +from . import agent_session, agent_text \ No newline at end of file diff --git a/livekit-protocol/livekit/protocol/agent_pb/agent_text.py b/livekit-protocol/livekit/protocol/agent_pb/agent_text.py new file mode 100644 index 00000000..4f569b84 --- /dev/null +++ b/livekit-protocol/livekit/protocol/agent_pb/agent_text.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: agent/livekit_agent_text.proto +# Protobuf Python Version: 4.25.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() + + +from . import agent_session as agent_dot__agent__session_ +from ..logger_pb import options as logger_dot_options__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1e\x61gent/livekit_agent_text.proto\x12\rlivekit.agent\x1a!agent/livekit_agent_session.proto\x1a\x14logger/options.proto\"\xde\x01\n\x12TextMessageRequest\x12\x0c\n\x04text\x18\x01 \x01(\t\x12!\n\nmessage_id\x18\x02 \x01(\tB\r\x9a\xec,\tmessageID\x12!\n\nsession_id\x18\x03 \x01(\tB\r\x9a\xec,\tsessionID\x12\x12\n\nagent_name\x18\x04 \x01(\t\x12\x10\n\x08metadata\x18\x05 \x01(\t\x12<\n\rsession_state\x18\x06 \x01(\x0b\x32 .livekit.agent.AgentSessionStateH\x00\x88\x01\x01\x42\x10\n\x0e_session_state\"\xfa\x02\n\x13TextMessageResponse\x12!\n\nmessage_id\x18\x01 \x01(\tB\r\x9a\xec,\tmessageID\x12!\n\nsession_id\x18\x02 \x01(\tB\r\x9a\xec,\tsessionID\x12-\n\x07message\x18\x03 \x01(\x0b\x32\x1a.livekit.agent.ChatMessageH\x00\x12\x34\n\rfunction_call\x18\x04 \x01(\x0b\x32\x1b.livekit.agent.FunctionCallH\x00\x12\x41\n\x14\x66unction_call_output\x18\x05 \x01(\x0b\x32!.livekit.agent.FunctionCallOutputH\x00\x12\x34\n\ragent_handoff\x18\x06 \x01(\x0b\x32\x1b.livekit.agent.AgentHandoffH\x00\x12\x36\n\x08\x63omplete\x18\x07 \x01(\x0b\x32\".livekit.agent.TextMessageCompleteH\x00\x42\x07\n\x05\x65vent\"\x8c\x01\n\x13TextMessageComplete\x12\x39\n\rsession_state\x18\x01 \x01(\x0b\x32 .livekit.agent.AgentSessionStateH\x00\x12\x30\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x1f.livekit.agent.TextMessageErrorH\x00\x42\x08\n\x06result\"Q\n\x11\x41gentSessionState\x12\x0f\n\x07version\x18\x01 \x01(\x04\x12\x12\n\x08snapshot\x18\x02 \x01(\x0cH\x00\x12\x0f\n\x05\x64\x65lta\x18\x03 \x01(\x0cH\x00\x42\x06\n\x04\x64\x61ta\"V\n\x10TextMessageError\x12\x0f\n\x07message\x18\x01 \x01(\t\x12\x31\n\x04\x63ode\x18\x02 \x01(\x0e\x32#.livekit.agent.TextMessageErrorCode*s\n\x14TextMessageErrorCode\x12\x12\n\x0eINTERNAL_ERROR\x10\x00\x12\x1b\n\x17SESSION_STATE_NOT_FOUND\x10\x01\x12\x16\n\x12TEXT_HANDLER_ERROR\x10\x02\x12\x12\n\x0ePROCESS_CLOSED\x10\x03\x42LZ)github.com/livekit/protocol/livekit/agent\xaa\x02\rLiveKit.Proto\xea\x02\x0eLiveKit::Protob\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'agent.agent_text', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + _globals['DESCRIPTOR']._options = None + _globals['DESCRIPTOR']._serialized_options = b'Z)github.com/livekit/protocol/livekit/agent\252\002\rLiveKit.Proto\352\002\016LiveKit::Proto' + _globals['_TEXTMESSAGEREQUEST'].fields_by_name['message_id']._options = None + _globals['_TEXTMESSAGEREQUEST'].fields_by_name['message_id']._serialized_options = b'\232\354,\tmessageID' + _globals['_TEXTMESSAGEREQUEST'].fields_by_name['session_id']._options = None + _globals['_TEXTMESSAGEREQUEST'].fields_by_name['session_id']._serialized_options = b'\232\354,\tsessionID' + _globals['_TEXTMESSAGERESPONSE'].fields_by_name['message_id']._options = None + _globals['_TEXTMESSAGERESPONSE'].fields_by_name['message_id']._serialized_options = b'\232\354,\tmessageID' + _globals['_TEXTMESSAGERESPONSE'].fields_by_name['session_id']._options = None + _globals['_TEXTMESSAGERESPONSE'].fields_by_name['session_id']._serialized_options = b'\232\354,\tsessionID' + _globals['_TEXTMESSAGEERRORCODE']._serialized_start=1026 + _globals['_TEXTMESSAGEERRORCODE']._serialized_end=1141 + _globals['_TEXTMESSAGEREQUEST']._serialized_start=107 + _globals['_TEXTMESSAGEREQUEST']._serialized_end=329 + _globals['_TEXTMESSAGERESPONSE']._serialized_start=332 + _globals['_TEXTMESSAGERESPONSE']._serialized_end=710 + _globals['_TEXTMESSAGECOMPLETE']._serialized_start=713 + _globals['_TEXTMESSAGECOMPLETE']._serialized_end=853 + _globals['_AGENTSESSIONSTATE']._serialized_start=855 + _globals['_AGENTSESSIONSTATE']._serialized_end=936 + _globals['_TEXTMESSAGEERROR']._serialized_start=938 + _globals['_TEXTMESSAGEERROR']._serialized_end=1024 +# @@protoc_insertion_point(module_scope) diff --git a/livekit-protocol/livekit/protocol/agent_pb/agent_text.pyi b/livekit-protocol/livekit/protocol/agent_pb/agent_text.pyi new file mode 100644 index 00000000..2f2199f0 --- /dev/null +++ b/livekit-protocol/livekit/protocol/agent_pb/agent_text.pyi @@ -0,0 +1,79 @@ +from . import agent_session as _agent_session +from ..logger_pb import options as _options_pb2 +from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Mapping as _Mapping, Optional as _Optional, Union as _Union + +DESCRIPTOR: _descriptor.FileDescriptor + +class TextMessageErrorCode(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + INTERNAL_ERROR: _ClassVar[TextMessageErrorCode] + SESSION_STATE_NOT_FOUND: _ClassVar[TextMessageErrorCode] + TEXT_HANDLER_ERROR: _ClassVar[TextMessageErrorCode] + PROCESS_CLOSED: _ClassVar[TextMessageErrorCode] +INTERNAL_ERROR: TextMessageErrorCode +SESSION_STATE_NOT_FOUND: TextMessageErrorCode +TEXT_HANDLER_ERROR: TextMessageErrorCode +PROCESS_CLOSED: TextMessageErrorCode + +class TextMessageRequest(_message.Message): + __slots__ = ("text", "message_id", "session_id", "agent_name", "metadata", "session_state") + TEXT_FIELD_NUMBER: _ClassVar[int] + MESSAGE_ID_FIELD_NUMBER: _ClassVar[int] + SESSION_ID_FIELD_NUMBER: _ClassVar[int] + AGENT_NAME_FIELD_NUMBER: _ClassVar[int] + METADATA_FIELD_NUMBER: _ClassVar[int] + SESSION_STATE_FIELD_NUMBER: _ClassVar[int] + text: str + message_id: str + session_id: str + agent_name: str + metadata: str + session_state: AgentSessionState + def __init__(self, text: _Optional[str] = ..., message_id: _Optional[str] = ..., session_id: _Optional[str] = ..., agent_name: _Optional[str] = ..., metadata: _Optional[str] = ..., session_state: _Optional[_Union[AgentSessionState, _Mapping]] = ...) -> None: ... + +class TextMessageResponse(_message.Message): + __slots__ = ("message_id", "session_id", "message", "function_call", "function_call_output", "agent_handoff", "complete") + MESSAGE_ID_FIELD_NUMBER: _ClassVar[int] + SESSION_ID_FIELD_NUMBER: _ClassVar[int] + MESSAGE_FIELD_NUMBER: _ClassVar[int] + FUNCTION_CALL_FIELD_NUMBER: _ClassVar[int] + FUNCTION_CALL_OUTPUT_FIELD_NUMBER: _ClassVar[int] + AGENT_HANDOFF_FIELD_NUMBER: _ClassVar[int] + COMPLETE_FIELD_NUMBER: _ClassVar[int] + message_id: str + session_id: str + message: _agent_session.ChatMessage + function_call: _agent_session.FunctionCall + function_call_output: _agent_session.FunctionCallOutput + agent_handoff: _agent_session.AgentHandoff + complete: TextMessageComplete + def __init__(self, message_id: _Optional[str] = ..., session_id: _Optional[str] = ..., message: _Optional[_Union[_agent_session.ChatMessage, _Mapping]] = ..., function_call: _Optional[_Union[_agent_session.FunctionCall, _Mapping]] = ..., function_call_output: _Optional[_Union[_agent_session.FunctionCallOutput, _Mapping]] = ..., agent_handoff: _Optional[_Union[_agent_session.AgentHandoff, _Mapping]] = ..., complete: _Optional[_Union[TextMessageComplete, _Mapping]] = ...) -> None: ... + +class TextMessageComplete(_message.Message): + __slots__ = ("session_state", "error") + SESSION_STATE_FIELD_NUMBER: _ClassVar[int] + ERROR_FIELD_NUMBER: _ClassVar[int] + session_state: AgentSessionState + error: TextMessageError + def __init__(self, session_state: _Optional[_Union[AgentSessionState, _Mapping]] = ..., error: _Optional[_Union[TextMessageError, _Mapping]] = ...) -> None: ... + +class AgentSessionState(_message.Message): + __slots__ = ("version", "snapshot", "delta") + VERSION_FIELD_NUMBER: _ClassVar[int] + SNAPSHOT_FIELD_NUMBER: _ClassVar[int] + DELTA_FIELD_NUMBER: _ClassVar[int] + version: int + snapshot: bytes + delta: bytes + def __init__(self, version: _Optional[int] = ..., snapshot: _Optional[bytes] = ..., delta: _Optional[bytes] = ...) -> None: ... + +class TextMessageError(_message.Message): + __slots__ = ("message", "code") + MESSAGE_FIELD_NUMBER: _ClassVar[int] + CODE_FIELD_NUMBER: _ClassVar[int] + message: str + code: TextMessageErrorCode + def __init__(self, message: _Optional[str] = ..., code: _Optional[_Union[TextMessageErrorCode, str]] = ...) -> None: ... diff --git a/livekit-protocol/livekit/protocol/version.py b/livekit-protocol/livekit/protocol/version.py index 0b2f79db..c72e3798 100644 --- a/livekit-protocol/livekit/protocol/version.py +++ b/livekit-protocol/livekit/protocol/version.py @@ -1 +1 @@ -__version__ = "1.1.3" +__version__ = "1.1.4"