From 30c039479ec239d72cf0f90e0833cd1d5c12172e Mon Sep 17 00:00:00 2001 From: Axel Suarez Date: Wed, 19 Mar 2025 17:31:51 -0700 Subject: [PATCH 1/5] WIP - Renaming bot references --- .azdo/ci-pr.yaml | 2 +- .github/workflows/python-package.yml | 2 +- .../msal/msal_auth_configuration.py | 4 +- .../microsoft/agents/builder}/__init__.py | 4 +- .../agents/builder}/activity_handler.py | 84 +++++++++---------- .../microsoft/agents/builder/agent.py} | 2 +- .../agents/builder}/channel_adapter.py | 44 +++++----- .../builder}/channel_api_handler_protocol.py | 2 +- .../builder}/channel_service_adapter.py | 58 ++++++------- .../channel_service_client_factory_base.py | 0 .../agents/builder}/message_factory.py | 4 +- .../agents/builder}/middleware_set.py | 4 +- .../rest_channel_service_client_factory.py | 4 +- .../microsoft/agents/builder}/turn_context.py | 2 +- .../microsoft-agents-builder}/pyproject.toml | 2 +- .../tests/test_activity_handler.py | 2 +- .../microsoft/agents/client/__init__.py | 12 +-- ...nce.py => agent_conversation_reference.py} | 2 +- .../agents/client/channel_protocol.py | 4 +- .../client/configuration_channel_host.py | 10 +-- .../agents/client/conversation_id_factory.py | 30 +++---- .../client/conversation_id_factory_options.py | 8 +- .../conversation_id_factory_protocol.py | 22 ++--- ...p_bot_channel.py => http_agent_channel.py} | 16 ++-- ...ctory.py => http_agent_channel_factory.py} | 6 +- .../agents/copilotstudio/client/__init__.py | 4 +- .../client/{bot_type.py => agent_type.py} | 2 +- .../client/connection_settings.py | 6 +- ..._to_engine_connection_settings_protocol.py | 6 +- .../client/power_platform_environment.py | 14 ++-- .../agents/authentication/__init__.py | 4 +- ...uration.py => agent_auth_configuration.py} | 4 +- .../authentication_constants.py | 6 +- .../agents/authentication/claims_identity.py | 8 +- .../agents/authentication/connections.py | 6 +- .../authentication/jwt_token_validator.py | 4 +- .../agents/core/channel_adapter_protocol.py | 4 +- .../microsoft/agents/core/models/activity.py | 6 +- .../core/models/adaptive_card_invoke_value.py | 4 +- .../agents/core/models/caller_id_constants.py | 2 +- .../agents/core/models/sign_in_constants.py | 2 +- .../core/models/token_exchange_state.py | 2 +- .../agents/hosting/aiohttp/__init__.py | 4 +- ..._http_adapter.py => agent_http_adapter.py} | 6 +- .../aiohttp/channel_service_route_table.py | 2 +- .../agents/hosting/aiohttp/cloud_adapter.py | 14 ++-- .../aiohttp/jwt_authorization_middleware.py | 4 +- .../pyproject.toml | 2 +- test_samples/bot_to_bot/bot_1/app.py | 6 +- test_samples/bot_to_bot/bot_1/bot1.py | 10 +-- test_samples/bot_to_bot/bot_2/app.py | 2 +- test_samples/bot_to_bot/bot_2/bot2.py | 2 +- .../chat_console_service.py | 2 +- .../copilot_studio_client_sample/config.py | 10 +-- test_samples/echo_bot/app.py | 2 +- test_samples/echo_bot/echo_bot.py | 2 +- 56 files changed, 242 insertions(+), 240 deletions(-) rename libraries/{Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder => Builder/microsoft-agents-builder/microsoft/agents/builder}/__init__.py (95%) rename libraries/{Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder => Builder/microsoft-agents-builder/microsoft/agents/builder}/activity_handler.py (88%) rename libraries/{Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/bot.py => Builder/microsoft-agents-builder/microsoft/agents/builder/agent.py} (95%) rename libraries/{Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder => Builder/microsoft-agents-builder/microsoft/agents/builder}/channel_adapter.py (82%) rename libraries/{Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder => Builder/microsoft-agents-builder/microsoft/agents/builder}/channel_api_handler_protocol.py (98%) rename libraries/{Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder => Builder/microsoft-agents-builder/microsoft/agents/builder}/channel_service_adapter.py (88%) rename libraries/{Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder => Builder/microsoft-agents-builder/microsoft/agents/builder}/channel_service_client_factory_base.py (100%) rename libraries/{Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder => Builder/microsoft-agents-builder/microsoft/agents/builder}/message_factory.py (99%) rename libraries/{Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder => Builder/microsoft-agents-builder/microsoft/agents/builder}/middleware_set.py (93%) rename libraries/{Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder => Builder/microsoft-agents-builder/microsoft/agents/builder}/rest_channel_service_client_factory.py (92%) rename libraries/{Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder => Builder/microsoft-agents-builder/microsoft/agents/builder}/turn_context.py (99%) rename libraries/{Botbuilder/microsoft-agents-botbuilder => Builder/microsoft-agents-builder}/pyproject.toml (93%) rename libraries/{Botbuilder/microsoft-agents-botbuilder => Builder/microsoft-agents-builder}/tests/test_activity_handler.py (98%) rename libraries/Client/microsoft-agents-client/microsoft/agents/client/{bot_conversation_reference.py => agent_conversation_reference.py} (76%) rename libraries/Client/microsoft-agents-client/microsoft/agents/client/{http_bot_channel.py => http_agent_channel.py} (86%) rename libraries/Client/microsoft-agents-client/microsoft/agents/client/{http_bot_channel_factory.py => http_agent_channel_factory.py} (63%) rename libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/{bot_type.py => agent_type.py} (73%) rename libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/{bot_auth_configuration.py => agent_auth_configuration.py} (83%) rename libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/{bot_http_adapter.py => agent_http_adapter.py} (63%) diff --git a/.azdo/ci-pr.yaml b/.azdo/ci-pr.yaml index 64d19eb9..1eeb7e11 100644 --- a/.azdo/ci-pr.yaml +++ b/.azdo/ci-pr.yaml @@ -52,7 +52,7 @@ steps: python -m pip install ./dist/microsoft_agents_authentication*.whl python -m pip install ./dist/microsoft_agents_connector*.whl python -m pip install ./dist/microsoft_agents_client*.whl - python -m pip install ./dist/microsoft_agents_botbuilder*.whl + python -m pip install ./dist/microsoft_agents_builder*.whl python -m pip install ./dist/microsoft_agents_authorization_msal*.whl python -m pip install ./dist/microsoft_agents_copilotstudio_client*.whl python -m pip install ./dist/microsoft_agents_hosting_aiohttp*.whl diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index bd0b37bc..7ff20433 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -55,7 +55,7 @@ jobs: python -m pip install ./dist/microsoft_agents_authentication*.whl python -m pip install ./dist/microsoft_agents_connector*.whl python -m pip install ./dist/microsoft_agents_client*.whl - python -m pip install ./dist/microsoft_agents_botbuilder*.whl + python -m pip install ./dist/microsoft_agents_builder*.whl python -m pip install ./dist/microsoft_agents_authorization_msal*.whl python -m pip install ./dist/microsoft_agents_copilotstudio_client*.whl python -m pip install ./dist/microsoft_agents_hosting_aiohttp*.whl diff --git a/libraries/Authentication/microsoft-agents-authorization-msal/microsoft/agents/authorization/msal/msal_auth_configuration.py b/libraries/Authentication/microsoft-agents-authorization-msal/microsoft/agents/authorization/msal/msal_auth_configuration.py index 4aec6db8..042a9674 100644 --- a/libraries/Authentication/microsoft-agents-authorization-msal/microsoft/agents/authorization/msal/msal_auth_configuration.py +++ b/libraries/Authentication/microsoft-agents-authorization-msal/microsoft/agents/authorization/msal/msal_auth_configuration.py @@ -1,11 +1,11 @@ from typing import Protocol, Optional -from microsoft.agents.authentication import BotAuthConfiguration +from microsoft.agents.authentication import AgentAuthConfiguration from .auth_types import AuthTypes -class MsalAuthConfiguration(BotAuthConfiguration, Protocol): +class MsalAuthConfiguration(AgentAuthConfiguration, Protocol): """ Configuration for MSAL authentication. """ diff --git a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/__init__.py b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/__init__.py similarity index 95% rename from libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/__init__.py rename to libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/__init__.py index e9ffa8dc..e16c1d34 100644 --- a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/__init__.py +++ b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/__init__.py @@ -1,6 +1,6 @@ # Import necessary modules from .activity_handler import ActivityHandler -from .bot import Bot +from .agent import Agent from .channel_adapter import ChannelAdapter from .channel_api_handler_protocol import ChannelApiHandlerProtocol from .channel_service_adapter import ChannelServiceAdapter @@ -13,7 +13,7 @@ # Define the package's public interface __all__ = [ "ActivityHandler", - "Bot", + "Agent", "ChannelAdapter", "ChannelApiHandlerProtocol", "ChannelServiceAdapter", diff --git a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/activity_handler.py b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/activity_handler.py similarity index 88% rename from libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/activity_handler.py rename to libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/activity_handler.py index b28053a8..af53ba10 100644 --- a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/activity_handler.py +++ b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/activity_handler.py @@ -16,10 +16,10 @@ SignInConstants, ) -from .bot import Bot +from .agent import Agent -class ActivityHandler(Bot): +class ActivityHandler(Agent): """ Handles activities and should be subclassed. @@ -33,11 +33,11 @@ async def on_turn( self, turn_context: TurnContextProtocol ): # pylint: disable=arguments-differ """ - Called by the adapter (for example, :class:`BotFrameworkAdapter`) at runtime - in order to process an inbound :class:`botbuilder.schema.Activity`. + Called by the adapter (for example, :class:`ChannelAdapter`) at runtime + in order to process an inbound :class:`builder.schema.Activity`. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute @@ -104,7 +104,7 @@ async def on_message_activity( # pylint: disable=unused-argument such as the conversational logic. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute """ @@ -118,7 +118,7 @@ async def on_message_update_activity( # pylint: disable=unused-argument such as the conversational logic. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute """ @@ -132,7 +132,7 @@ async def on_message_delete_activity( # pylint: disable=unused-argument such as the conversational logic. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute """ @@ -144,7 +144,7 @@ async def on_conversation_update_activity(self, turn_context: TurnContextProtoco :meth:`on_turn()` is used. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute @@ -152,9 +152,9 @@ async def on_conversation_update_activity(self, turn_context: TurnContextProtoco When the :meth:`on_turn()` method receives a conversation update activity, it calls this method. Also - - If the conversation update activity indicates that members other than the bot joined the conversation, + - If the conversation update activity indicates that members other than the agent joined the conversation, it calls the :meth:`on_members_added_activity()` method. - - If the conversation update activity indicates that members other than the bot left the conversation, + - If the conversation update activity indicates that members other than the agent left the conversation, it calls the :meth:`on_members_removed_activity()` method. - In a derived class, override this method to add logic that applies to all conversation update activities. Add logic to apply before the member added or removed logic before the call to this base class method. @@ -173,21 +173,21 @@ async def on_members_added_activity( self, members_added: list[ChannelAccount], turn_context: TurnContextProtocol ): # pylint: disable=unused-argument """ - Override this method in a derived class to provide logic for when members other than the bot join - the conversation. You can add your bot's welcome logic. + Override this method in a derived class to provide logic for when members other than the agent join + the conversation. You can add your agent's welcome logic. :param members_added: A list of all the members added to the conversation, as described by the conversation update activity :type members_added: :class:`typing.List` :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute .. remarks:: When the :meth:`on_conversation_update_activity()` method receives a conversation update activity that indicates - one or more users other than the bot are joining the conversation, it calls this method. + one or more users other than the agent are joining the conversation, it calls this method. """ return @@ -195,20 +195,20 @@ async def on_members_removed_activity( self, members_removed: list[ChannelAccount], turn_context: TurnContextProtocol ): # pylint: disable=unused-argument """ - Override this method in a derived class to provide logic for when members other than the bot leave - the conversation. You can add your bot's good-bye logic. + Override this method in a derived class to provide logic for when members other than the agent leave + the conversation. You can add your agent's good-bye logic. :param members_added: A list of all the members removed from the conversation, as described by the conversation update activity :type members_added: :class:`typing.List` :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute .. remarks:: When the :meth:`on_conversation_update_activity()` method receives a conversation - update activity that indicates one or more users other than the bot are leaving the conversation, + update activity that indicates one or more users other than the agent are leaving the conversation, it calls this method. """ @@ -220,7 +220,7 @@ async def on_message_reaction_activity(self, turn_context: TurnContextProtocol): :meth:`on_turn()` is used. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute @@ -230,7 +230,7 @@ async def on_message_reaction_activity(self, turn_context: TurnContextProtocol): Message reactions are only supported by a few channels. The activity that the message reaction corresponds to is indicated in the reply to Id property. The value of this property is the activity id of a previously - sent activity given back to the bot as the response from a send call. + sent activity given back to the agent as the response from a send call. When the :meth:`on_turn()` method receives a message reaction activity, it calls this method. @@ -266,7 +266,7 @@ async def on_reactions_added( # pylint: disable=unused-argument :param message_reactions: The list of reactions added :type message_reactions: :class:`typing.List` :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute @@ -275,7 +275,7 @@ async def on_reactions_added( # pylint: disable=unused-argument to a previously sent message on the conversation. Message reactions are supported by only a few channels. The activity that the message is in reaction to is identified by the activity's reply to ID property. - The value of this property is the activity ID of a previously sent activity. When the bot sends an activity, + The value of this property is the activity ID of a previously sent activity. When the agent sends an activity, the channel assigns an ID to it, which is available in the resource response Id of the result. """ return @@ -292,7 +292,7 @@ async def on_reactions_removed( # pylint: disable=unused-argument :param message_reactions: The list of reactions removed :type message_reactions: :class:`typing.List` :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute @@ -300,7 +300,7 @@ async def on_reactions_removed( # pylint: disable=unused-argument Message reactions correspond to the user adding a 'like' or 'sad' etc. (often an emoji) to a previously sent message on the conversation. Message reactions are supported by only a few channels. The activity that the message is in reaction to is identified by the activity's reply to Id property. - The value of this property is the activity ID of a previously sent activity. When the bot sends an activity, + The value of this property is the activity ID of a previously sent activity. When the agent sends an activity, the channel assigns an ID to it, which is available in the resource response Id of the result. """ return @@ -311,7 +311,7 @@ async def on_event_activity(self, turn_context: TurnContextProtocol): :meth:`on_turn()` is used. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute @@ -324,7 +324,7 @@ async def on_event_activity(self, turn_context: TurnContextProtocol): Add logic to apply before the specific event-handling logic before the call to this base class method. Add logic to apply after the specific event-handling logic after the call to this base class method. - Event activities communicate programmatic information from a client or channel to a bot. + Event activities communicate programmatic information from a client or channel to an agent. The meaning of an event activity is defined by the event activity name property, which is meaningful within the scope of a channel. """ @@ -342,13 +342,13 @@ async def on_token_response_event( # pylint: disable=unused-argument If using an `oauth_prompt`, override this method to forward this activity to the current dialog. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute .. remarks:: When the :meth:`on_event()` method receives an event with an activity name of - `tokens/response`, it calls this method. If your bot uses an `oauth_prompt`, forward the incoming + `tokens/response`, it calls this method. If your agent uses an `oauth_prompt`, forward the incoming activity to the current dialog. """ return @@ -362,14 +362,14 @@ async def on_event( # pylint: disable=unused-argument :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute .. remarks:: When the :meth:`on_event_activity()` is used method receives an event with an activity name other than `tokens/response`, it calls this method. - This method could optionally be overridden if the bot is meant to handle miscellaneous events. + This method could optionally be overridden if the agent is meant to handle miscellaneous events. """ return @@ -380,7 +380,7 @@ async def on_end_of_conversation_activity( # pylint: disable=unused-argument Invoked when a conversation end activity is received from the channel. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute """ return @@ -393,7 +393,7 @@ async def on_typing_activity( # pylint: disable=unused-argument ActivityTypes.typing activities, such as the conversational logic. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute """ return @@ -406,7 +406,7 @@ async def on_installation_update( # pylint: disable=unused-argument ActivityTypes.InstallationUpdate activities. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute """ if turn_context.activity.action in ("add", "add-upgrade"): @@ -423,7 +423,7 @@ async def on_installation_update_add( # pylint: disable=unused-argument ActivityTypes.InstallationUpdate activities with 'action' set to 'add'. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute """ return @@ -436,7 +436,7 @@ async def on_installation_update_remove( # pylint: disable=unused-argument ActivityTypes.InstallationUpdate activities with 'action' set to 'remove'. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute """ return @@ -450,7 +450,7 @@ async def on_unrecognized_activity_type( # pylint: disable=unused-argument If overridden, this method could potentially respond to any of the other activity types. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute @@ -467,7 +467,7 @@ async def on_invoke_activity( # pylint: disable=unused-argument Registers an activity event handler for the _invoke_ event, emitted for every incoming event activity. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute """ @@ -503,7 +503,7 @@ async def on_sign_in_invoke( # pylint: disable=unused-argument By default, this method does nothing. :param turn_context: The context object for this turn - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :returns: A task that represents the work queued to execute """ @@ -513,15 +513,15 @@ async def on_adaptive_card_invoke( self, turn_context: TurnContextProtocol, invoke_value: AdaptiveCardInvokeValue ) -> AdaptiveCardInvokeResponse: """ - Invoked when the bot is sent an Adaptive Card Action Execute. + Invoked when the agent is sent an Adaptive Card Action Execute. When the on_invoke_activity method receives an Invoke with a Activity.name of `adaptiveCard/action`, it calls this method. :param turn_context: A context object for this turn. - :type turn_context: :class:`botbuilder.core.TurnContext` + :type turn_context: :class:`microsoft.agents.builder.TurnContext` :param invoke_value: A string-typed object from the incoming activity's value. - :type invoke_value: :class:`botframework.schema.models.AdaptiveCardInvokeValue` + :type invoke_value: :class:`microsoft.agents.core.models.AdaptiveCardInvokeValue` :return: The HealthCheckResponse object """ raise _InvokeResponseException(HTTPStatus.NOT_IMPLEMENTED) diff --git a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/bot.py b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/agent.py similarity index 95% rename from libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/bot.py rename to libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/agent.py index b74142b3..deaa2286 100644 --- a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/bot.py +++ b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/agent.py @@ -7,7 +7,7 @@ from .turn_context import TurnContext -class Bot(Protocol): +class Agent(Protocol): """ Represents a bot that can operate on incoming activities. """ diff --git a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/channel_adapter.py b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_adapter.py similarity index 82% rename from libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/channel_adapter.py rename to libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_adapter.py index d7a1bfc8..d77ad278 100644 --- a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/channel_adapter.py +++ b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_adapter.py @@ -18,8 +18,8 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol): - BOT_IDENTITY_KEY = "BotIdentity" - OAUTH_SCOPE_KEY = "Microsoft.Agents.BotBuilder.ChannelAdapter.OAuthScope" + AGENT_IDENTITY_KEY = "AgentIdentity" + OAUTH_SCOPE_KEY = "Microsoft.Agents.Builder.ChannelAdapter.OAuthScope" INVOKE_RESPONSE_KEY = "ChannelAdapter.InvokeResponse" on_turn_error: Callable[[TurnContext, Exception], Awaitable] = None @@ -50,7 +50,7 @@ async def update_activity(self, context: TurnContext, activity: Activity): :param context: The context object for the turn. :type context: :class:`TurnContext` :param activity: New replacement activity. - :type activity: :class:`botbuilder.schema.Activity` + :type activity: :class:`builder.schema.Activity` :return: """ raise NotImplementedError() @@ -65,7 +65,7 @@ async def delete_activity( :param context: The context object for the turn. :type context: :class:`TurnContext` :param reference: Conversation reference for the activity to delete. - :type reference: :class:`botbuilder.schema.ConversationReference` + :type reference: :class:`builder.schema.ConversationReference` :return: """ raise NotImplementedError() @@ -82,24 +82,24 @@ def use(self, middleware): async def continue_conversation( self, - bot_id: str, # pylint: disable=unused-argument + agent_id: str, # pylint: disable=unused-argument reference: ConversationReference, callback: Callable[[TurnContext], Awaitable], ): """ Sends a proactive message to a conversation. Call this method to proactively send a message to a conversation. - Most channels require a user to initiate a conversation with a bot before the bot can send activities + Most channels require a user to initiate a conversation with an agent before the agent can send activities to the user. - :param bot_id: The application ID of the bot. This parameter is ignored in - single tenant the Adapters (Console, Test, etc) but is critical to the BotFrameworkAdapter + :param agent_id: The application ID of the agent. This parameter is ignored in + single tenant the Adapters (Console, Test, etc) but is critical to the ChannelAdapter which is multi-tenant aware. :param reference: A reference to the conversation to continue. - :type reference: :class:`botbuilder.schema.ConversationReference` - :param callback: The method to call for the resulting bot turn. + :type reference: :class:`builder.schema.ConversationReference` + :param callback: The method to call for the resulting agent turn. :type callback: :class:`typing.Callable` - :param claims_identity: A :class:`botframework.connector.auth.ClaimsIdentity` for the conversation. - :type claims_identity: :class:`botframework.connector.auth.ClaimsIdentity` + :param claims_identity: A :class:`microsoft.agents.authentication.ClaimsIdentity` for the conversation. + :type claims_identity: :class:`microsoft.agents.authentication.ClaimsIdentity` :param audience:A value signifying the recipient of the proactive message. :type audience: str """ @@ -115,14 +115,14 @@ async def continue_conversation_with_claims( ): """ Sends a proactive message to a conversation. Call this method to proactively send a message to a conversation. - Most channels require a user to initiate a conversation with a bot before the bot can send activities + Most channels require a user to initiate a conversation with an agent before the agent can send activities to the user. - :param claims_identity: A :class:`botframework.connector.auth.ClaimsIdentity` for the conversation. - :type claims_identity: :class:`botframework.connector.auth.ClaimsIdentity` + :param claims_identity: A :class:`microsoft.agents.authentication.ClaimsIdentity` for the conversation. + :type claims_identity: :class:`microsoft.agents.authentication.ClaimsIdentity` :param continuation_activity: The activity to send. - :type continuation_activity: :class:`botbuilder - :param callback: The method to call for the resulting bot turn. + :type continuation_activity: :class:`builder + :param callback: The method to call for the resulting agent turn. :type callback: :class:`typing.Callable` :param audience: A value signifying the recipient of the proactive message. :type audience: str @@ -131,7 +131,7 @@ async def continue_conversation_with_claims( async def create_conversation( self, - bot_app_id: str, + agent_app_id: str, channel_id: str, service_url: str, audience: str, @@ -142,7 +142,7 @@ async def create_conversation( Starts a new conversation with a user. Used to direct message to a member of a group. :param reference: The conversation reference that contains the tenant - :type reference: :class:`botbuilder.schema.ConversationReference` + :type reference: :class:`builder.schema.ConversationReference` :param logic: The logic to use for the creation of the conversation :type logic: :class:`typing.Callable` :param conversation_parameters: The information to use to create the conversation @@ -151,15 +151,15 @@ async def create_conversation( :type channel_id: :class:`typing.str` :param service_url: The channel's service URL endpoint. :type service_url: :class:`typing.str` - :param credentials: The application credentials for the bot. - :type credentials: :class:`botframework.connector.auth.AppCredentials` + :param credentials: The application credentials for the agent. + :type credentials: :class:`microsoft.agents.authentication.AppCredentials` :raises: It raises a generic exception error. :return: A task representing the work queued to execute. .. remarks:: - To start a conversation, your bot must know its account information and the user's + To start a conversation, your agent must know its account information and the user's account information on that channel. Most channels only support initiating a direct message (non-group) conversation. The adapter attempts to create a new conversation on the channel, and diff --git a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/channel_api_handler_protocol.py b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_api_handler_protocol.py similarity index 98% rename from libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/channel_api_handler_protocol.py rename to libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_api_handler_protocol.py index 680bb80d..49b73d38 100644 --- a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/channel_api_handler_protocol.py +++ b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_api_handler_protocol.py @@ -25,7 +25,7 @@ async def on_get_conversations( continuation_token: Optional[str] = None, ) -> ConversationsResult: """ - List the Conversations in which this bot has participated. + List the Conversations in which this agent has participated. """ raise NotImplementedError() diff --git a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/channel_service_adapter.py b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_service_adapter.py similarity index 88% rename from libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/channel_service_adapter.py rename to libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_service_adapter.py index e21c4b47..14dada39 100644 --- a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/channel_service_adapter.py +++ b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_service_adapter.py @@ -40,10 +40,10 @@ class ChannelServiceAdapter(ChannelAdapter, ABC): CONNECTOR_FACTORY_KEY = "ConnectorFactory" USER_TOKEN_CLIENT_KEY = "UserTokenClient" - BOT_CALLBACK_HANDLER_KEY = "BotCallbackHandler" + AGENT_CALLBACK_HANDLER_KEY = "AgentCallbackHandler" CHANNEL_SERVICE_FACTORY_KEY = "ChannelServiceClientFactory" - _BOT_CONNECTOR_CLIENT_KEY = "ConnectorClient" - _INVOKE_RESPONSE_KEY = "BotFrameworkAdapter.InvokeResponse" + _AGENT_CONNECTOR_CLIENT_KEY = "ConnectorClient" + _INVOKE_RESPONSE_KEY = "ChannelServiceAdapter.InvokeResponse" def __init__(self, channel_service_client_factory: ChannelServiceClientFactoryBase): super().__init__() @@ -82,7 +82,7 @@ async def send_activities( else: connector_client = cast( ConnectorClientBase, - context.turn_state.get(self._BOT_CONNECTOR_CLIENT_KEY), + context.turn_state.get(self._AGENT_CONNECTOR_CLIENT_KEY), ) if not connector_client: raise Error("Unable to extract ConnectorClient from turn context.") @@ -117,7 +117,8 @@ async def update_activity(self, context: TurnContext, activity: Activity): raise TypeError("Expected Activity but got None instead") connector_client = cast( - ConnectorClientBase, context.turn_state.get(self._BOT_CONNECTOR_CLIENT_KEY) + ConnectorClientBase, + context.turn_state.get(self._AGENT_CONNECTOR_CLIENT_KEY), ) if not connector_client: raise Error("Unable to extract ConnectorClient from turn context.") @@ -136,7 +137,8 @@ async def delete_activity( raise TypeError("Expected ConversationReference but got None instead") connector_client = cast( - ConnectorClientBase, context.turn_state.get(self._BOT_CONNECTOR_CLIENT_KEY) + ConnectorClientBase, + context.turn_state.get(self._AGENT_CONNECTOR_CLIENT_KEY), ) if not connector_client: raise Error("Unable to extract ConnectorClient from turn context.") @@ -147,23 +149,23 @@ async def delete_activity( async def continue_conversation( # pylint: disable=arguments-differ self, - bot_app_id: str, + agent_app_id: str, continuation_activity: Activity, callback: Callable[[TurnContext], Awaitable], ): """ Sends a proactive message to a conversation. Call this method to proactively send a message to a conversation. - Most channels require a user to initiate a conversation with a bot before the bot can send activities + Most channels require a user to initiate a conversation with an agent before the agent can send activities to the user. :param reference: A reference to the conversation to continue. - :type reference: :class:`botbuilder.schema.ConversationReference` - :param callback: The method to call for the resulting bot turn. + :type reference: :class:`builder.schema.ConversationReference` + :param callback: The method to call for the resulting agent turn. :type callback: :class:`typing.Callable` - :param bot_app_id: The application Id of the bot. This is the appId returned by the Azure portal registration, + :param agent_app_id: The application Id of the agent. This is the appId returned by the Azure portal registration, and is generally found in the `MicrosoftAppId` parameter in `config.py`. - :type bot_app_id: :class:`typing.str` + :type agent_app_id: :class:`typing.str` """ if not callable: raise TypeError( @@ -172,7 +174,7 @@ async def continue_conversation( # pylint: disable=arguments-differ self._validate_continuation_activity(continuation_activity) - claims_identity = self.create_claims_identity(bot_app_id) + claims_identity = self.create_claims_identity(agent_app_id) return await self.process_proactive( claims_identity, @@ -194,7 +196,7 @@ async def continue_conversation_with_claims( async def create_conversation( # pylint: disable=arguments-differ self, - bot_app_id: str, + agent_app_id: str, channel_id: str, service_url: str, audience: str, @@ -213,7 +215,7 @@ async def create_conversation( # pylint: disable=arguments-differ raise TypeError("CloudAdapter.create_conversation(): callback is required.") # Create a ClaimsIdentity, to create the connector and for adding to the turn context. - claims_identity = self.create_claims_identity(bot_app_id) + claims_identity = self.create_claims_identity(agent_app_id) claims_identity.claims[AuthenticationConstants.SERVICE_URL_CLAIM] = service_url # Create the connector client to use for outbound requests. @@ -314,9 +316,9 @@ async def process_activity( :return: A task that represents the work queued to execute. .. remarks:: - This class processes an activity received by the bots web server. This includes any messages + This class processes an activity received by the agents web server. This includes any messages sent from a user and is the method that drives what's often referred to as the - bots *reactive messaging* flow. + agent *reactive messaging* flow. Call this method to reactively send a message to a conversation. If the task completes successfully, then an :class:`InvokeResponse` is returned; otherwise. `null` is returned. @@ -324,13 +326,13 @@ async def process_activity( scopes: list[str] = None outgoing_audience: str = None - if claims_identity.is_bot_claim(): + if claims_identity.is_agent_claim(): outgoing_audience = claims_identity.get_token_audience() scopes = [f"{claims_identity.get_outgoing_app_id()}/.default"] - activity.caller_id = f"{CallerIdConstants.bot_to_bot_prefix}{claims_identity.get_outgoing_app_id()}" + activity.caller_id = f"{CallerIdConstants.agent_to_agent_prefix}{claims_identity.get_outgoing_app_id()}" else: - outgoing_audience = AuthenticationConstants.BOT_FRAMEWORK_SCOPE - scopes = [f"{AuthenticationConstants.BOT_FRAMEWORK_SCOPE}/.default"] + outgoing_audience = AuthenticationConstants.AGENTS_SDK_SCOPE + scopes = [f"{AuthenticationConstants.AGENTS_SDK_SCOPE}/.default"] use_anonymous_auth_callback = False if ( @@ -375,11 +377,11 @@ async def process_activity( # If there are any results they will have been left on the TurnContext. return self._process_turn_results(context) - def create_claims_identity(self, bot_app_id: str = "") -> ClaimsIdentity: + def create_claims_identity(self, agent_app_id: str = "") -> ClaimsIdentity: return ClaimsIdentity( { - AuthenticationConstants.AUDIENCE_CLAIM: bot_app_id, - AuthenticationConstants.APP_ID_CLAIM: bot_app_id, + AuthenticationConstants.AUDIENCE_CLAIM: agent_app_id, + AuthenticationConstants.APP_ID_CLAIM: agent_app_id, }, False, ) @@ -432,10 +434,10 @@ def _create_turn_context( ) -> TurnContext: context = TurnContext(self, activity) - context.turn_state[self.BOT_IDENTITY_KEY] = claims_identity - context.turn_state[self._BOT_CONNECTOR_CLIENT_KEY] = connector_client + context.turn_state[self.AGENT_IDENTITY_KEY] = claims_identity + context.turn_state[self._AGENT_CONNECTOR_CLIENT_KEY] = connector_client context.turn_state[self.USER_TOKEN_CLIENT_KEY] = user_token_client - context.turn_state[self.BOT_CALLBACK_HANDLER_KEY] = callback + context.turn_state[self.AGENT_CALLBACK_HANDLER_KEY] = callback context.turn_state[self.CHANNEL_SERVICE_FACTORY_KEY] = ( self._channel_service_client_factory ) @@ -454,7 +456,7 @@ def _process_turn_results(self, context: TurnContext) -> InvokeResponse: ).model_dump(mode="json", by_alias=True, exclude_unset=True), ) - # Handle Invoke scenarios where the bot will return a specific body and return code. + # Handle Invoke scenarios where the agent will return a specific body and return code. if context.activity.type == ActivityTypes.invoke: activity_invoke_response: Activity = context.turn_state.get( self._INVOKE_RESPONSE_KEY diff --git a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/channel_service_client_factory_base.py b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_service_client_factory_base.py similarity index 100% rename from libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/channel_service_client_factory_base.py rename to libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_service_client_factory_base.py diff --git a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/message_factory.py b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/message_factory.py similarity index 99% rename from libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/message_factory.py rename to libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/message_factory.py index 56a81a25..423a8dcf 100644 --- a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/message_factory.py +++ b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/message_factory.py @@ -36,8 +36,8 @@ def attachment_activity( class MessageFactory: """ - A set of utility functions designed to assist with the formatting of the various message types a - bot can return. + A set of utility functions designed to assist with the formatting of the various message types + an agent can return. """ @staticmethod diff --git a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/middleware_set.py b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/middleware_set.py similarity index 93% rename from libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/middleware_set.py rename to libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/middleware_set.py index 80cb0603..5f6f5e58 100644 --- a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/middleware_set.py +++ b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/middleware_set.py @@ -18,7 +18,7 @@ async def on_turn( class MiddlewareSet(Middleware): """ A set of `Middleware` plugins. The set itself is middleware so you can easily package up a set - of middleware that can be composed into a bot with a single `bot.use(mySet)` call or even into + of middleware that can be composed into an agent with a single `agent.use(mySet)` call or even into another middleware set using `set.use(mySet)`. """ @@ -28,7 +28,7 @@ def __init__(self): def use(self, *middleware: Middleware): """ - Registers middleware plugin(s) with the bot or set. + Registers middleware plugin(s) with the agent or set. :param middleware : :return: """ diff --git a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/rest_channel_service_client_factory.py b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/rest_channel_service_client_factory.py similarity index 92% rename from libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/rest_channel_service_client_factory.py rename to libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/rest_channel_service_client_factory.py index 8c19c559..0ddc00ff 100644 --- a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/rest_channel_service_client_factory.py +++ b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/rest_channel_service_client_factory.py @@ -19,8 +19,8 @@ def __init__( self, configuration: Any, connections: Connections, - token_service_endpoint=AuthenticationConstants.BOT_FRAMEWORK_OAUTH_URL, - token_service_audience=AuthenticationConstants.BOT_FRAMEWORK_SCOPE, + token_service_endpoint=AuthenticationConstants.AGENTS_SDK_OAUTH_URL, + token_service_audience=AuthenticationConstants.AGENTS_SDK_SCOPE, ) -> None: self._connections = connections self._token_service_endpoint = token_service_endpoint diff --git a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/turn_context.py b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/turn_context.py similarity index 99% rename from libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/turn_context.py rename to libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/turn_context.py index eb95c661..693bfaaa 100644 --- a/libraries/Botbuilder/microsoft-agents-botbuilder/microsoft/agents/botbuilder/turn_context.py +++ b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/turn_context.py @@ -373,7 +373,7 @@ def remove_mention_text(activity: Activity, identifier: str) -> str: Previously: This was a copy of the re.escape function in Python 3.8. This was done because the 3.6.x version didn't escape in the same way and handling - bot names with regex characters in it would fail in TurnContext.remove_mention_text + agent names with regex characters in it would fail in TurnContext.remove_mention_text without escaping the text. """ mentions = TurnContext.get_mentions(activity) diff --git a/libraries/Botbuilder/microsoft-agents-botbuilder/pyproject.toml b/libraries/Builder/microsoft-agents-builder/pyproject.toml similarity index 93% rename from libraries/Botbuilder/microsoft-agents-botbuilder/pyproject.toml rename to libraries/Builder/microsoft-agents-builder/pyproject.toml index 970ca90a..8dd3cf6f 100644 --- a/libraries/Botbuilder/microsoft-agents-botbuilder/pyproject.toml +++ b/libraries/Builder/microsoft-agents-builder/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools"] build-backend = "setuptools.build_meta" [project] -name = "microsoft-agents-botbuilder" +name = "microsoft-agents-builder" version = "0.0.0a1" description = "A protocol library for Microsoft Agents" authors = [{name = "Microsoft Corporation"}] diff --git a/libraries/Botbuilder/microsoft-agents-botbuilder/tests/test_activity_handler.py b/libraries/Builder/microsoft-agents-builder/tests/test_activity_handler.py similarity index 98% rename from libraries/Botbuilder/microsoft-agents-botbuilder/tests/test_activity_handler.py rename to libraries/Builder/microsoft-agents-builder/tests/test_activity_handler.py index 102e7af1..e0a53cee 100644 --- a/libraries/Botbuilder/microsoft-agents-botbuilder/tests/test_activity_handler.py +++ b/libraries/Builder/microsoft-agents-builder/tests/test_activity_handler.py @@ -1,6 +1,6 @@ import pytest from unittest.mock import AsyncMock -from microsoft.agents.botbuilder import ActivityHandler, TurnContext +from microsoft.agents.builder import ActivityHandler, TurnContext from microsoft.agents.core.models import ( ActivityTypes, ChannelAccount, diff --git a/libraries/Client/microsoft-agents-client/microsoft/agents/client/__init__.py b/libraries/Client/microsoft-agents-client/microsoft/agents/client/__init__.py index 1740902b..07e97aac 100644 --- a/libraries/Client/microsoft-agents-client/microsoft/agents/client/__init__.py +++ b/libraries/Client/microsoft-agents-client/microsoft/agents/client/__init__.py @@ -1,4 +1,4 @@ -from .bot_conversation_reference import BotConversationReference +from .agent_conversation_reference import AgentConversationReference from .channel_factory_protocol import ChannelFactoryProtocol from .channel_host_protocol import ChannelHostProtocol from .channel_info_protocol import ChannelInfoProtocol @@ -13,11 +13,11 @@ from .conversation_id_factory_options import ConversationIdFactoryOptions from .conversation_id_factory_protocol import ConversationIdFactoryProtocol from .conversation_id_factory import ConversationIdFactory -from .http_bot_channel_factory import HttpBotChannelFactory -from .http_bot_channel import HttpBotChannel +from .http_agent_channel_factory import HttpAgentChannelFactory +from .http_agent_channel import HttpAgentChannel __all__ = [ - "BotConversationReference", + "AgentConversationReference", "ChannelFactoryProtocol", "ChannelHostProtocol", "ChannelInfoProtocol", @@ -30,6 +30,6 @@ "ConversationIdFactoryOptions", "ConversationIdFactoryProtocol", "ConversationIdFactory", - "HttpBotChannelFactory", - "HttpBotChannel", + "HttpAgentChannelFactory", + "HttpAgentChannel", ] diff --git a/libraries/Client/microsoft-agents-client/microsoft/agents/client/bot_conversation_reference.py b/libraries/Client/microsoft-agents-client/microsoft/agents/client/agent_conversation_reference.py similarity index 76% rename from libraries/Client/microsoft-agents-client/microsoft/agents/client/bot_conversation_reference.py rename to libraries/Client/microsoft-agents-client/microsoft/agents/client/agent_conversation_reference.py index d4fe6bef..6ecf7bb2 100644 --- a/libraries/Client/microsoft-agents-client/microsoft/agents/client/bot_conversation_reference.py +++ b/libraries/Client/microsoft-agents-client/microsoft/agents/client/agent_conversation_reference.py @@ -1,6 +1,6 @@ from microsoft.agents.core.models import AgentsModel, ConversationReference -class BotConversationReference(AgentsModel): +class AgentConversationReference(AgentsModel): conversation_reference: ConversationReference oauth_scope: str diff --git a/libraries/Client/microsoft-agents-client/microsoft/agents/client/channel_protocol.py b/libraries/Client/microsoft-agents-client/microsoft/agents/client/channel_protocol.py index 4fb4dee9..693afb36 100644 --- a/libraries/Client/microsoft-agents-client/microsoft/agents/client/channel_protocol.py +++ b/libraries/Client/microsoft-agents-client/microsoft/agents/client/channel_protocol.py @@ -6,8 +6,8 @@ class ChannelProtocol(Protocol): async def post_activity( self, - to_bot_id: str, - to_bot_resource: str, + to_agent_id: str, + to_agent_resource: str, endpoint: str, service_url: str, conversation_id: str, diff --git a/libraries/Client/microsoft-agents-client/microsoft/agents/client/configuration_channel_host.py b/libraries/Client/microsoft-agents-client/microsoft/agents/client/configuration_channel_host.py index 2316a001..d445255d 100644 --- a/libraries/Client/microsoft-agents-client/microsoft/agents/client/configuration_channel_host.py +++ b/libraries/Client/microsoft-agents-client/microsoft/agents/client/configuration_channel_host.py @@ -28,11 +28,11 @@ def __init__( if channel_host_configuration: if channel_host_configuration.CHANNELS: - for bot_from_config in channel_host_configuration.CHANNELS: - bot = copy(bot_from_config) - if not bot.channel_factory: - bot.channel_factory = default_channel_name - self.channels[bot.id] = bot + for agent_from_config in channel_host_configuration.CHANNELS: + agent = copy(agent_from_config) + if not agent.channel_factory: + agent.channel_factory = default_channel_name + self.channels[agent.id] = agent self.host_endpoint = channel_host_configuration.HOST_ENDPOINT self.host_app_id = channel_host_configuration.HOST_APP_ID diff --git a/libraries/Client/microsoft-agents-client/microsoft/agents/client/conversation_id_factory.py b/libraries/Client/microsoft-agents-client/microsoft/agents/client/conversation_id_factory.py index 3822a35c..63c98fb5 100644 --- a/libraries/Client/microsoft-agents-client/microsoft/agents/client/conversation_id_factory.py +++ b/libraries/Client/microsoft-agents-client/microsoft/agents/client/conversation_id_factory.py @@ -5,7 +5,7 @@ from microsoft.agents.core.models import AgentsModel from microsoft.agents.storage import Storage, StoreItem -from .bot_conversation_reference import BotConversationReference +from .agent_conversation_reference import AgentConversationReference from .conversation_id_factory_protocol import ConversationIdFactoryProtocol @@ -34,33 +34,33 @@ async def create_conversation_id(self, options) -> str: ) conversation_reference = options.activity.get_conversation_reference() - bot_conversation_id = str(uuid4()) + agent_conversation_id = str(uuid4()) - bot_conversation_reference = BotConversationReference( + agent_conversation_reference = AgentConversationReference( conversation_reference=conversation_reference, oauth_scope=options.from_oauth_scope, ) - _implement_store_item_for_agents_model_cls(bot_conversation_reference) + _implement_store_item_for_agents_model_cls(agent_conversation_reference) - conversation_info = {bot_conversation_id: bot_conversation_reference} + conversation_info = {agent_conversation_id: agent_conversation_reference} await self._storage.write(conversation_info) - return bot_conversation_id + return agent_conversation_id - async def get_bot_conversation_reference( - self, bot_conversation_id - ) -> BotConversationReference: - if not bot_conversation_id: + async def get_agent_conversation_reference( + self, agent_conversation_id + ) -> AgentConversationReference: + if not agent_conversation_id: raise ValueError( - "ConversationIdFactory.get_bot_conversation_reference(): bot_conversation_id cannot be None" + "ConversationIdFactory.get_agent_conversation_reference(): agent_conversation_id cannot be None" ) storage_record = await self._storage.read( - [bot_conversation_id], target_cls=BotConversationReference + [agent_conversation_id], target_cls=AgentConversationReference ) - return storage_record[bot_conversation_id] + return storage_record[agent_conversation_id] - async def delete_conversation_reference(self, bot_conversation_id): - await self._storage.delete([bot_conversation_id]) + async def delete_conversation_reference(self, agent_conversation_id): + await self._storage.delete([agent_conversation_id]) diff --git a/libraries/Client/microsoft-agents-client/microsoft/agents/client/conversation_id_factory_options.py b/libraries/Client/microsoft-agents-client/microsoft/agents/client/conversation_id_factory_options.py index 05334903..25350c4b 100644 --- a/libraries/Client/microsoft-agents-client/microsoft/agents/client/conversation_id_factory_options.py +++ b/libraries/Client/microsoft-agents-client/microsoft/agents/client/conversation_id_factory_options.py @@ -7,12 +7,12 @@ class ConversationIdFactoryOptions: def __init__( self, from_oauth_scope: str, - from_bot_id: str, + from_agent_id: str, activity: Activity, - bot: ChannelInfoProtocol, + agent: ChannelInfoProtocol, ) -> None: self.from_oauth_scope = from_oauth_scope - self.from_bot_id = from_bot_id + self.from_agent_id = from_agent_id # TODO: implement Activity and types as protocols and replace here self.activity = activity - self.bot = bot + self.agent = agent diff --git a/libraries/Client/microsoft-agents-client/microsoft/agents/client/conversation_id_factory_protocol.py b/libraries/Client/microsoft-agents-client/microsoft/agents/client/conversation_id_factory_protocol.py index b8b92c7c..845e155a 100644 --- a/libraries/Client/microsoft-agents-client/microsoft/agents/client/conversation_id_factory_protocol.py +++ b/libraries/Client/microsoft-agents-client/microsoft/agents/client/conversation_id_factory_protocol.py @@ -1,7 +1,7 @@ from typing import Protocol from abc import abstractmethod -from .bot_conversation_reference import BotConversationReference +from .agent_conversation_reference import AgentConversationReference from .conversation_id_factory_options import ConversationIdFactoryOptions @@ -11,24 +11,24 @@ async def create_conversation_id( self, options: ConversationIdFactoryOptions ) -> str: """ - Creates a conversation ID for a bot conversation. + Creates a conversation ID for an agent conversation. :param options: A ConversationIdFactoryOptions instance. :return: A unique conversation ID. """ @abstractmethod - async def get_bot_conversation_reference( - self, bot_conversation_id: str - ) -> BotConversationReference: + async def get_agent_conversation_reference( + self, agent_conversation_id: str + ) -> AgentConversationReference: """ - Gets the BotConversationReference for a conversation ID. - :param bot_conversation_id: An ID created with create_conversation_id. - :return: BotConversationReference or None if not found. + Gets the AgentConversationReference for a conversation ID. + :param agent_conversation_id: An ID created with create_conversation_id. + :return: AgentConversationReference or None if not found. """ @abstractmethod - async def delete_conversation_reference(self, bot_conversation_id: str) -> None: + async def delete_conversation_reference(self, agent_conversation_id: str) -> None: """ - Deletes a bot conversation reference. - :param bot_conversation_id: A conversation ID created with create_conversation_id. + Deletes an agent conversation reference. + :param agent_conversation_id: A conversation ID created with create_conversation_id. """ diff --git a/libraries/Client/microsoft-agents-client/microsoft/agents/client/http_bot_channel.py b/libraries/Client/microsoft-agents-client/microsoft/agents/client/http_agent_channel.py similarity index 86% rename from libraries/Client/microsoft-agents-client/microsoft/agents/client/http_bot_channel.py rename to libraries/Client/microsoft-agents-client/microsoft/agents/client/http_agent_channel.py index e62991b7..374f32ed 100644 --- a/libraries/Client/microsoft-agents-client/microsoft/agents/client/http_bot_channel.py +++ b/libraries/Client/microsoft-agents-client/microsoft/agents/client/http_agent_channel.py @@ -15,14 +15,14 @@ from .conversation_constants import ConversationConstants -class HttpBotChannel(ChannelProtocol): +class HttpAgentChannel(ChannelProtocol): def __init__(self, token_access: AccessTokenProviderBase) -> None: self._token_access = token_access async def post_activity( self, - to_bot_id: str, - to_bot_resource: str, + to_agent_id: str, + to_agent_resource: str, endpoint: str, service_url: str, conversation_id: str, @@ -32,15 +32,15 @@ async def post_activity( **kwargs, ) -> InvokeResponse[AgentsModel]: if not endpoint: - raise ValueError("HttpBotChannel.post_activity: Endpoint is required") + raise ValueError("HttpAgentChannel.post_activity: Endpoint is required") if not service_url: - raise ValueError("HttpBotChannel.post_activity: Service URL is required") + raise ValueError("HttpAgentChannel.post_activity: Service URL is required") if not conversation_id: raise ValueError( - "HttpBotChannel.post_activity: Conversation ID is required" + "HttpAgentChannel.post_activity: Conversation ID is required" ) if not activity: - raise ValueError("HttpBotChannel.post_activity: Activity is required") + raise ValueError("HttpAgentChannel.post_activity: Activity is required") activity_copy = deepcopy(activity) @@ -59,7 +59,7 @@ async def post_activity( activity_copy.recipient.role = RoleTypes.skill token_result = await self._token_access.get_access_token( - to_bot_resource, [f"{to_bot_id}/.default"] + to_agent_resource, [f"{to_agent_id}/.default"] ) headers = { "Authorization": f"Bearer {token_result}", diff --git a/libraries/Client/microsoft-agents-client/microsoft/agents/client/http_bot_channel_factory.py b/libraries/Client/microsoft-agents-client/microsoft/agents/client/http_agent_channel_factory.py similarity index 63% rename from libraries/Client/microsoft-agents-client/microsoft/agents/client/http_bot_channel_factory.py rename to libraries/Client/microsoft-agents-client/microsoft/agents/client/http_agent_channel_factory.py index 935601e1..eb4acac0 100644 --- a/libraries/Client/microsoft-agents-client/microsoft/agents/client/http_bot_channel_factory.py +++ b/libraries/Client/microsoft-agents-client/microsoft/agents/client/http_agent_channel_factory.py @@ -2,9 +2,9 @@ from .channel_factory_protocol import ChannelFactoryProtocol from .channel_protocol import ChannelProtocol -from .http_bot_channel import HttpBotChannel +from .http_agent_channel import HttpAgentChannel -class HttpBotChannelFactory(ChannelFactoryProtocol): +class HttpAgentChannelFactory(ChannelFactoryProtocol): def create_channel(self, token_access: AccessTokenProviderBase) -> ChannelProtocol: - return HttpBotChannel(token_access) + return HttpAgentChannel(token_access) diff --git a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/__init__.py b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/__init__.py index 6b5e2107..8b7e1178 100644 --- a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/__init__.py +++ b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/__init__.py @@ -1,4 +1,4 @@ -from .bot_type import BotType +from .agent_type import AgentType from .connection_settings import ConnectionSettings from .copilot_client import CopilotClient from .direct_to_engine_connection_settings_protocol import ( @@ -9,7 +9,7 @@ from .power_platform_environment import PowerPlatformEnvironment __all__ = [ - "BotType", + "AgentType", "ConnectionSettings", "CopilotClient", "DirectToEngineConnectionSettingsProtocol", diff --git a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/bot_type.py b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/agent_type.py similarity index 73% rename from libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/bot_type.py rename to libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/agent_type.py index cd6dc138..03d4489f 100644 --- a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/bot_type.py +++ b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/agent_type.py @@ -1,6 +1,6 @@ from enum import Enum -class BotType(str, Enum): +class AgentType(str, Enum): PUBLISHED = "published" PREBUILT = "prebuilt" diff --git a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/connection_settings.py b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/connection_settings.py index 82bc570a..c4d53760 100644 --- a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/connection_settings.py +++ b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/connection_settings.py @@ -3,7 +3,7 @@ DirectToEngineConnectionSettingsProtocol, ) from .power_platform_cloud import PowerPlatformCloud -from .bot_type import BotType +from .agent_type import AgentType class ConnectionSettings(DirectToEngineConnectionSettingsProtocol): @@ -16,7 +16,7 @@ def __init__( environment_id: str, bot_identifier: str, cloud: Optional[PowerPlatformCloud], - copilot_bot_type: Optional[BotType], + copilot_agent_type: Optional[AgentType], custom_power_platform_cloud: Optional[str], ) -> None: self.environment_id = environment_id @@ -28,5 +28,5 @@ def __init__( raise ValueError("Bot Identifier must be provided") self.cloud = cloud or PowerPlatformCloud.UNKNOWN - self.copilot_bot_type = copilot_bot_type or BotType.PUBLISHED + self.copilot_agent_type = copilot_agent_type or AgentType.PUBLISHED self.custom_power_platform_cloud = custom_power_platform_cloud diff --git a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/direct_to_engine_connection_settings_protocol.py b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/direct_to_engine_connection_settings_protocol.py index 38eecffd..fdc1ad7c 100644 --- a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/direct_to_engine_connection_settings_protocol.py +++ b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/direct_to_engine_connection_settings_protocol.py @@ -1,6 +1,6 @@ from typing import Protocol, Optional -from .bot_type import BotType +from .agent_type import AgentType from .power_platform_cloud import PowerPlatformCloud @@ -15,11 +15,11 @@ class DirectToEngineConnectionSettingsProtocol(Protocol): # if PowerPlatformCloud is set to Other, this is the url for the power platform API endpoint. custom_power_platform_cloud: Optional[str] - # Environment ID for the environment that hosts the bot + # Environment ID for the environment that hosts the agent environment_id: Optional[str] # Power Platform Cloud where the environment is hosted cloud: Optional[PowerPlatformCloud] # Type of Bot hosted in Copilot Studio - copilot_bot_type: Optional[BotType] + copilot_agent_type: Optional[AgentType] diff --git a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/power_platform_environment.py b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/power_platform_environment.py index a0228032..5fabf3ce 100644 --- a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/power_platform_environment.py +++ b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/power_platform_environment.py @@ -1,7 +1,7 @@ from urllib.parse import urlparse, urlunparse from typing import Optional from .connection_settings import ConnectionSettings -from .bot_type import BotType +from .agent_type import AgentType from .power_platform_cloud import PowerPlatformCloud @@ -17,7 +17,7 @@ class PowerPlatformEnvironment: def get_copilot_studio_connection_url( settings: ConnectionSettings, conversation_id: Optional[str] = None, - bot_type: BotType = BotType.PUBLISHED, + agent_type: AgentType = AgentType.PUBLISHED, cloud: PowerPlatformCloud = PowerPlatformCloud.PROD, cloud_base_address: Optional[str] = None, ) -> str: @@ -42,15 +42,15 @@ def get_copilot_studio_connection_url( raise ValueError( "Either CustomPowerPlatformCloud or cloud_base_address must be provided when PowerPlatformCloud is Other" ) - if settings.copilot_bot_type: - bot_type = settings.copilot_bot_type + if settings.copilot_agent_type: + agent_type = settings.copilot_agent_type cloud_base_address = cloud_base_address or "api.unknown.powerplatform.com" host = PowerPlatformEnvironment.get_environment_endpoint( cloud, settings.environment_id, cloud_base_address ) return PowerPlatformEnvironment.create_uri( - settings.bot_identifier, host, bot_type, conversation_id + settings.bot_identifier, host, agent_type, conversation_id ) @staticmethod @@ -89,11 +89,11 @@ def get_token_audience( def create_uri( bot_identifier: str, host: str, - bot_type: BotType, + agent_type: AgentType, conversation_id: Optional[str], ) -> str: bot_path_name = ( - "dataverse-backed" if bot_type == BotType.PUBLISHED else "prebuilt" + "dataverse-backed" if agent_type == AgentType.PUBLISHED else "prebuilt" ) path = f"/copilotstudio/{bot_path_name}/authenticated/bots/{bot_identifier}/conversations" if conversation_id: diff --git a/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/__init__.py b/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/__init__.py index d72dd4aa..5f589df0 100644 --- a/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/__init__.py +++ b/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/__init__.py @@ -1,7 +1,7 @@ from .access_token_provider_base import AccessTokenProviderBase from .authentication_constants import AuthenticationConstants from .connections import Connections -from .bot_auth_configuration import BotAuthConfiguration +from .agent_auth_configuration import AgentAuthConfiguration from .claims_identity import ClaimsIdentity from .jwt_token_validator import JwtTokenValidator @@ -9,7 +9,7 @@ "AccessTokenProviderBase", "AuthenticationConstants", "Connections", - "BotAuthConfiguration", + "AgentAuthConfiguration", "ClaimsIdentity", "JwtTokenValidator", ] diff --git a/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/bot_auth_configuration.py b/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/agent_auth_configuration.py similarity index 83% rename from libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/bot_auth_configuration.py rename to libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/agent_auth_configuration.py index 1b0deb88..430b6364 100644 --- a/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/bot_auth_configuration.py +++ b/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/agent_auth_configuration.py @@ -1,9 +1,9 @@ from typing import Protocol, Optional -class BotAuthConfiguration(Protocol): +class AgentAuthConfiguration(Protocol): """ - Configuration for Bot authentication. + Configuration for Agent authentication. """ TENANT_ID: Optional[str] diff --git a/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/authentication_constants.py b/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/authentication_constants.py index 16142a80..b0d8847b 100644 --- a/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/authentication_constants.py +++ b/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/authentication_constants.py @@ -6,13 +6,13 @@ class AuthenticationConstants(ABC): # Bot Framework OAuth scope to request. - BOT_FRAMEWORK_SCOPE = "https://api.botframework.com" + AGENTS_SDK_SCOPE = "https://api.botframework.com" # Token issuer for ABS tokens. - BOT_FRAMEWORK_TOKEN_ISSUER = "https://api.botframework.com" + AGENTS_SDK_TOKEN_ISSUER = "https://api.botframework.com" # Default OAuth Url used to get a token from IUserTokenClient. - BOT_FRAMEWORK_OAUTH_URL = "https://api.botframework.com" + AGENTS_SDK_OAUTH_URL = "https://api.botframework.com" # Public Azure Bot Service OpenId Metadata URL. PUBLIC_AZURE_BOT_SERVICE_OPENID_METADATA_URL = ( diff --git a/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/claims_identity.py b/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/claims_identity.py index b854b9db..a8a92ebb 100644 --- a/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/claims_identity.py +++ b/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/claims_identity.py @@ -47,11 +47,11 @@ def get_outgoing_app_id(self) -> Optional[str]: return app_id - def is_bot_claim(self) -> bool: + def is_agent_claim(self) -> bool: """ - Checks if the current claims represents a bot claim (not coming from ABS/SMBA). + Checks if the current claims represents an agent claim (not coming from ABS/SMBA). - :return: True if the list of claims is a bot claim, otherwise False. + :return: True if the list of claims is an agent claim, otherwise False. """ version = self.claims.get(AuthenticationConstants.VERSION_CLAIM, None) @@ -62,7 +62,7 @@ def is_bot_claim(self) -> bool: if ( not audience or audience.lower() - == AuthenticationConstants.BOT_FRAMEWORK_TOKEN_ISSUER.lower() + == AuthenticationConstants.AGENTS_SDK_TOKEN_ISSUER.lower() ): return False diff --git a/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/connections.py b/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/connections.py index bfa95ea4..a3bf0275 100644 --- a/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/connections.py +++ b/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/connections.py @@ -10,14 +10,14 @@ class Connections(Protocol): @abstractmethod def get_connection(self, connection_name: str) -> AccessTokenProviderBase: """ - Get the OAuth connection for the bot. + Get the OAuth connection for the agent. """ raise NotImplementedError() @abstractmethod def get_default_connection(self) -> AccessTokenProviderBase: """ - Get the default OAuth connection for the bot. + Get the default OAuth connection for the agent. """ raise NotImplementedError() @@ -26,6 +26,6 @@ def get_token_provider( self, claims_identity: ClaimsIdentity, service_url: str ) -> AccessTokenProviderBase: """ - Get the OAuth token provider for the bot. + Get the OAuth token provider for the agent. """ raise NotImplementedError() diff --git a/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/jwt_token_validator.py b/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/jwt_token_validator.py index f65055dd..56249ad3 100644 --- a/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/jwt_token_validator.py +++ b/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/jwt_token_validator.py @@ -2,12 +2,12 @@ from jwt import PyJWKClient, PyJWK, decode, get_unverified_header -from .bot_auth_configuration import BotAuthConfiguration +from .agent_auth_configuration import AgentAuthConfiguration from .claims_identity import ClaimsIdentity class JwtTokenValidator: - def __init__(self, configuration: BotAuthConfiguration): + def __init__(self, configuration: AgentAuthConfiguration): self.configuration = configuration def validate_token(self, token: str) -> ClaimsIdentity: diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/channel_adapter_protocol.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/channel_adapter_protocol.py index c5ac9566..c22c61fe 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/channel_adapter_protocol.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/channel_adapter_protocol.py @@ -38,7 +38,7 @@ def use(self, middleware: object) -> "ChannelAdapterProtocol": @abstractmethod async def continue_conversation( self, - bot_id: str, + agent_id: str, reference: ConversationReference, callback: Callable[[TurnContextProtocol], Awaitable], ) -> None: @@ -58,7 +58,7 @@ async def continue_conversation_with_claims( @abstractmethod async def create_conversation( self, - bot_app_id: str, + agent_app_id: str, channel_id: str, service_url: str, audience: str, diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/activity.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/activity.py index de22f225..4b06225d 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/activity.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/activity.py @@ -115,7 +115,7 @@ class Activity(AgentsModel): :type text_highlights: list[~microsoft.agents.protocols.models.TextHighlight] :param semantic_action: An optional programmatic action accompanying this request :type semantic_action: ~microsoft.agents.protocols.models.SemanticAction - :param caller_id: A string containing an IRI identifying the caller of a bot. This field is not intended to be transmitted over the wire, + :param caller_id: A string containing an IRI identifying the caller of an agent. This field is not intended to be transmitted over the wire, but is instead populated by bots and clients based on cryptographically verifiable data that asserts the identity of the callers (e.g. tokens). :type caller_id: str """ @@ -170,8 +170,8 @@ def apply_conversation_reference( Updates this activity with the delivery information from an existing ConversationReference. :param reference: The existing conversation reference. - :param is_incoming: Optional, True to treat the activity as an incoming activity, where the bot is the recipient; otherwise, False. - Default is False, and the activity will show the bot as the sender. + :param is_incoming: Optional, True to treat the activity as an incoming activity, where the agent is the recipient; otherwise, False. + Default is False, and the activity will show the agent as the sender. :returns: This activity, updated with the delivery information. diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/adaptive_card_invoke_value.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/adaptive_card_invoke_value.py index b6e35110..8035cc2c 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/adaptive_card_invoke_value.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/adaptive_card_invoke_value.py @@ -10,9 +10,9 @@ class AdaptiveCardInvokeValue(AgentsModel): Defines the structure that arrives in the Activity.Value for Invoke activity with Name of 'adaptiveCard/action'. :param action: The action of this adaptive card invoke action value. - :type action: :class:`botframework.schema.models.AdaptiveCardInvokeAction` + :type action: :class:`microsoft.agents.core.models.AdaptiveCardInvokeAction` :param authentication: The TokenExchangeInvokeRequest for this adaptive card invoke action value. - :type authentication: :class:`botframework.schema.models.TokenExchangeInvokeRequest` + :type authentication: :class:`microsoft.agents.core.models.TokenExchangeInvokeRequest` :param state: The 'state' or magic code for an OAuth flow. :type state: str """ diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/caller_id_constants.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/caller_id_constants.py index f08ed014..58e23dae 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/caller_id_constants.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/caller_id_constants.py @@ -4,4 +4,4 @@ class CallerIdConstants(str, Enum): public_azure_channel = "urn:botframework:azure" us_gov_channel = "urn:botframework:azureusgov" - bot_to_bot_prefix = "urn:botframework:aadappid:" + agent_to_agent_prefix = "urn:botframework:aadappid:" diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/sign_in_constants.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/sign_in_constants.py index 3bc6f6b6..ad183ca3 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/sign_in_constants.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/sign_in_constants.py @@ -9,5 +9,5 @@ class SignInConstants(str, Enum): verify_state_operation_name = "signin/verifyState" # Name for signin invoke to perform a token exchange. token_exchange_operation_name = "signin/tokenExchange" - # The EventActivity name when a token is sent to the bot. + # The EventActivity name when a token is sent to the agent. token_response_event_name = "tokens/response" diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/token_exchange_state.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/token_exchange_state.py index fa821449..3dbef8bf 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/token_exchange_state.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/token_exchange_state.py @@ -12,7 +12,7 @@ class TokenExchangeState(AgentsModel): :type conversation: ~microsoft.agents.protocols.models.ConversationReference :param relates_to: Gets or sets a reference to a related parent conversation for this token exchange. :type relates_to: ~microsoft.agents.protocols.models.ConversationReference - :param bot_ur: The URL of the bot messaging endpoint. + :param bot_ur: The URL of the agent messaging endpoint. :type bot_ur: str :param ms_app_id: The bot's registered application ID. :type ms_app_id: str diff --git a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/__init__.py b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/__init__.py index cf0232ed..697555c9 100644 --- a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/__init__.py +++ b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/__init__.py @@ -1,10 +1,10 @@ -from .bot_http_adapter import BotHttpAdapter +from .agent_http_adapter import AgentHttpAdapter from .channel_service_route_table import channel_service_route_table from .cloud_adapter import CloudAdapter from .jwt_authorization_middleware import jwt_authorization_middleware __all__ = [ - "BotHttpAdapter", + "AgentHttpAdapter", "CloudAdapter", "jwt_authorization_middleware", "channel_service_route_table", diff --git a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/bot_http_adapter.py b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/agent_http_adapter.py similarity index 63% rename from libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/bot_http_adapter.py rename to libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/agent_http_adapter.py index 11e385e1..22482644 100644 --- a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/bot_http_adapter.py +++ b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/agent_http_adapter.py @@ -9,10 +9,10 @@ Response, ) -from microsoft.agents.botbuilder import Bot +from microsoft.agents.builder import Agent -class BotHttpAdapter(Protocol): +class AgentHttpAdapter(Protocol): @abstractmethod - async def process(self, request: Request, bot: Bot) -> Optional[Response]: + async def process(self, request: Request, bot: Agent) -> Optional[Response]: raise NotImplementedError() diff --git a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/channel_service_route_table.py b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/channel_service_route_table.py index bc4f9f60..5c9bfa7c 100644 --- a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/channel_service_route_table.py +++ b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/channel_service_route_table.py @@ -12,7 +12,7 @@ ConversationParameters, Transcript, ) -from microsoft.agents.botbuilder import ChannelApiHandlerProtocol +from microsoft.agents.builder import ChannelApiHandlerProtocol async def deserialize_from_body( diff --git a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/cloud_adapter.py b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/cloud_adapter.py index 436b0cfc..eed3aa64 100644 --- a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/cloud_adapter.py +++ b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/cloud_adapter.py @@ -17,18 +17,18 @@ Activity, DeliveryModes, ) -from microsoft.agents.botbuilder import ( - Bot, +from microsoft.agents.builder import ( + Agent, ChannelServiceAdapter, ChannelServiceClientFactoryBase, MessageFactory, TurnContext, ) -from .bot_http_adapter import BotHttpAdapter +from .agent_http_adapter import AgentHttpAdapter -class CloudAdapter(ChannelServiceAdapter, BotHttpAdapter): +class CloudAdapter(ChannelServiceAdapter, AgentHttpAdapter): def __init__( self, channel_service_client_factory: ChannelServiceClientFactoryBase, @@ -36,7 +36,7 @@ def __init__( """ Initializes a new instance of the CloudAdapter class. - :param bot_framework_authentication: Optional BotFrameworkAuthentication instance + :param channel_service_client_factory: The factory to use to create the channel service client. """ super().__init__(channel_service_client_factory) @@ -57,7 +57,7 @@ async def on_turn_error(context: TurnContext, error: Exception): self.on_turn_error = on_turn_error self._channel_service_client_factory = channel_service_client_factory - async def process(self, request: Request, bot: Bot) -> Optional[Response]: + async def process(self, request: Request, bot: Agent) -> Optional[Response]: if not request: raise TypeError("CloudAdapter.process: request can't be None") if not bot: @@ -82,7 +82,7 @@ async def process(self, request: Request, bot: Bot) -> Optional[Response]: raise HTTPBadRequest try: - # Process the inbound activity with the bot + # Process the inbound activity with the agent invoke_response = await self.process_activity( claims_identity, activity, bot.on_turn ) diff --git a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/jwt_authorization_middleware.py b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/jwt_authorization_middleware.py index 6fe17e82..bf258d7f 100644 --- a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/jwt_authorization_middleware.py +++ b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/jwt_authorization_middleware.py @@ -1,11 +1,11 @@ from aiohttp.web import Request, middleware, json_response -from microsoft.agents.authentication import BotAuthConfiguration, JwtTokenValidator +from microsoft.agents.authentication import AgentAuthConfiguration, JwtTokenValidator @middleware async def jwt_authorization_middleware(request: Request, handler): - auth_config: BotAuthConfiguration = request.app["bot_configuration"] + auth_config: AgentAuthConfiguration = request.app["bot_configuration"] token_validator = JwtTokenValidator(auth_config) auth_header = request.headers.get("Authorization") if auth_header: diff --git a/libraries/Hosting/microsoft-agents-hosting-aiohttp/pyproject.toml b/libraries/Hosting/microsoft-agents-hosting-aiohttp/pyproject.toml index cfc9abe2..b7e04c1a 100644 --- a/libraries/Hosting/microsoft-agents-hosting-aiohttp/pyproject.toml +++ b/libraries/Hosting/microsoft-agents-hosting-aiohttp/pyproject.toml @@ -15,7 +15,7 @@ classifiers = [ ] dependencies = [ "microsoft-agents-connector", - "microsoft-agents-botbuilder", + "microsoft-agents-builder", "aiohttp>=3.11.11", ] diff --git a/test_samples/bot_to_bot/bot_1/app.py b/test_samples/bot_to_bot/bot_1/app.py index 525eb5aa..d06c7c0a 100644 --- a/test_samples/bot_to_bot/bot_1/app.py +++ b/test_samples/bot_to_bot/bot_1/app.py @@ -3,7 +3,7 @@ from aiohttp.web import Application, Request, Response, run_app -from microsoft.agents.botbuilder import RestChannelServiceClientFactory +from microsoft.agents.builder import RestChannelServiceClientFactory from microsoft.agents.hosting.aiohttp import ( CloudAdapter, jwt_authorization_middleware, @@ -18,7 +18,7 @@ from microsoft.agents.client import ( ConfigurationChannelHost, ConversationIdFactory, - HttpBotChannelFactory, + HttpAgentChannelFactory, ) from microsoft.agents.storage import MemoryStorage @@ -48,7 +48,7 @@ def get_connection(self, connection_name: str) -> AccessTokenProviderBase: CONFIG = DefaultConfig() CHANNEL_CLIENT_FACTORY = RestChannelServiceClientFactory(CONFIG, DEFAULT_CONNECTION) -BOT_CHANNEL_FACTORY = HttpBotChannelFactory() +BOT_CHANNEL_FACTORY = HttpAgentChannelFactory() CHANNEL_HOST = ConfigurationChannelHost( BOT_CHANNEL_FACTORY, DEFAULT_CONNECTION, CONFIG, "HttpBotClient" ) diff --git a/test_samples/bot_to_bot/bot_1/bot1.py b/test_samples/bot_to_bot/bot_1/bot1.py index 3bca8de5..30c01969 100644 --- a/test_samples/bot_to_bot/bot_1/bot1.py +++ b/test_samples/bot_to_bot/bot_1/bot1.py @@ -24,7 +24,7 @@ ConversationIdFactoryProtocol, ConversationIdFactoryOptions, ) -from microsoft.agents.botbuilder import ( +from microsoft.agents.builder import ( ActivityHandler, ChannelApiHandlerProtocol, ChannelAdapter, @@ -206,9 +206,9 @@ async def _send_to_bot( from_oauth_scope=turn_context.turn_state.get( ChannelAdapter.OAUTH_SCOPE_KEY ), - from_bot_id=self._channel_host.host_app_id, + from_agent_id=self._channel_host.host_app_id, activity=turn_context.activity, - bot=target_channel, + agent=target_channel, ) conversation_id = await self._conversation_id_factory.create_conversation_id( @@ -259,7 +259,7 @@ async def _process_activity( activity: Activity, ): bot_conversation_reference = ( - await self._conversation_id_factory.get_bot_conversation_reference( + await self._conversation_id_factory.get_agent_conversation_reference( conversation_id ) ) @@ -271,7 +271,7 @@ async def bot_callback_handler(turn_context: TurnContextProtocol): bot_conversation_reference.conversation_reference ) turn_context.activity.id = reply_to_activity_id - turn_context.activity.caller_id = f"{CallerIdConstants.bot_to_bot_prefix}{claims_identity.get_outgoing_app_id()}" + turn_context.activity.caller_id = f"{CallerIdConstants.agent_to_agent_prefix}{claims_identity.get_outgoing_app_id()}" if activity.type == ActivityTypes.end_of_conversation: await self._conversation_id_factory.delete_conversation_reference( diff --git a/test_samples/bot_to_bot/bot_2/app.py b/test_samples/bot_to_bot/bot_2/app.py index 041e7dba..2d192972 100644 --- a/test_samples/bot_to_bot/bot_2/app.py +++ b/test_samples/bot_to_bot/bot_2/app.py @@ -3,7 +3,7 @@ from aiohttp.web import Application, Request, Response, run_app -from microsoft.agents.botbuilder import RestChannelServiceClientFactory +from microsoft.agents.builder import RestChannelServiceClientFactory from microsoft.agents.hosting.aiohttp import CloudAdapter, jwt_authorization_middleware from microsoft.agents.authentication import ( Connections, diff --git a/test_samples/bot_to_bot/bot_2/bot2.py b/test_samples/bot_to_bot/bot_2/bot2.py index 43530c77..2ee2248e 100644 --- a/test_samples/bot_to_bot/bot_2/bot2.py +++ b/test_samples/bot_to_bot/bot_2/bot2.py @@ -1,4 +1,4 @@ -from microsoft.agents.botbuilder import ActivityHandler, MessageFactory, TurnContext +from microsoft.agents.builder import ActivityHandler, MessageFactory, TurnContext from microsoft.agents.core.models import ( ChannelAccount, Activity, diff --git a/test_samples/copilot_studio_client_sample/chat_console_service.py b/test_samples/copilot_studio_client_sample/chat_console_service.py index ab749f8a..86a3fa9e 100644 --- a/test_samples/copilot_studio_client_sample/chat_console_service.py +++ b/test_samples/copilot_studio_client_sample/chat_console_service.py @@ -23,7 +23,7 @@ async def start_service(self): question = input("user> ") # Send the user input to the Copilot Studio bot and await the response. - # In this case we are not sending a conversation ID, as the bot is already connected by "StartConversationAsync", a conversation ID is persisted by the underlying client. + # In this case we are not sending a conversation ID, as the agent is already connected by "StartConversationAsync", a conversation ID is persisted by the underlying client. async for bot_activity in self._copilot_client.ask_question(question): self._print_activity(bot_activity) diff --git a/test_samples/copilot_studio_client_sample/config.py b/test_samples/copilot_studio_client_sample/config.py index 73f4cca5..d885afdc 100644 --- a/test_samples/copilot_studio_client_sample/config.py +++ b/test_samples/copilot_studio_client_sample/config.py @@ -4,7 +4,7 @@ from microsoft.agents.copilotstudio.client import ( ConnectionSettings, PowerPlatformCloud, - BotType, + AgentType, ) @@ -16,7 +16,7 @@ def __init__( environment_id: Optional[str] = None, bot_identifier: Optional[str] = None, cloud: Optional[PowerPlatformCloud] = None, - copilot_bot_type: Optional[BotType] = None, + copilot_agent_type: Optional[AgentType] = None, custom_power_platform_cloud: Optional[str] = None, ) -> None: self.app_client_id = app_client_id or environ.get("APP_CLIENT_ID") @@ -30,8 +30,8 @@ def __init__( environment_id = environment_id or environ.get("ENVIRONMENT_ID") bot_identifier = bot_identifier or environ.get("BOT_IDENTIFIER") cloud = cloud or PowerPlatformCloud[environ.get("CLOUD", "UNKNOWN")] - copilot_bot_type = ( - copilot_bot_type or BotType[environ.get("COPILOT_BOT_TYPE", "PUBLISHED")] + copilot_agent_type = ( + copilot_agent_type or AgentType[environ.get("COPILOT_agent_type", "PUBLISHED")] ) custom_power_platform_cloud = custom_power_platform_cloud or environ.get( "CUSTOM_POWER_PLATFORM_CLOUD", None @@ -41,6 +41,6 @@ def __init__( environment_id, bot_identifier, cloud, - copilot_bot_type, + copilot_agent_type, custom_power_platform_cloud, ) diff --git a/test_samples/echo_bot/app.py b/test_samples/echo_bot/app.py index 5a1af1fb..3f78f27e 100644 --- a/test_samples/echo_bot/app.py +++ b/test_samples/echo_bot/app.py @@ -3,7 +3,7 @@ from aiohttp.web import Application, Request, Response, run_app -from microsoft.agents.botbuilder import RestChannelServiceClientFactory +from microsoft.agents.builder import RestChannelServiceClientFactory from microsoft.agents.hosting.aiohttp import CloudAdapter, jwt_authorization_middleware from microsoft.agents.authentication import ( Connections, diff --git a/test_samples/echo_bot/echo_bot.py b/test_samples/echo_bot/echo_bot.py index 74f722b0..6b927c0e 100644 --- a/test_samples/echo_bot/echo_bot.py +++ b/test_samples/echo_bot/echo_bot.py @@ -1,4 +1,4 @@ -from microsoft.agents.botbuilder import ActivityHandler, MessageFactory, TurnContext +from microsoft.agents.builder import ActivityHandler, MessageFactory, TurnContext from microsoft.agents.core.models import ChannelAccount From f815ee3727f369dc1dc12e4f75c32e941f42f90b Mon Sep 17 00:00:00 2001 From: Axel Suarez Date: Thu, 20 Mar 2025 16:37:43 -0700 Subject: [PATCH 2/5] WIP - Renaming bot references --- .../microsoft/agents/builder/agent.py | 4 ++-- .../microsoft/agents/builder/turn_context.py | 4 ++-- .../copilotstudio/client/connection_settings.py | 8 ++++---- .../direct_to_engine_connection_settings_protocol.py | 2 +- .../client/power_platform_environment.py | 12 ++++++------ .../microsoft/agents/core/models/activity.py | 6 +++--- .../agents/core/models/conversation_reference.py | 10 ++++++---- .../agents/hosting/aiohttp/agent_http_adapter.py | 2 +- .../agents/hosting/aiohttp/cloud_adapter.py | 8 ++++---- .../hosting/aiohttp/jwt_authorization_middleware.py | 2 +- test_samples/bot_to_bot/bot_1/app.py | 2 +- test_samples/bot_to_bot/bot_2/app.py | 2 +- test_samples/copilot_studio_client_sample/config.py | 6 +++--- test_samples/echo_bot/app.py | 2 +- 14 files changed, 36 insertions(+), 34 deletions(-) diff --git a/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/agent.py b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/agent.py index deaa2286..1661c719 100644 --- a/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/agent.py +++ b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/agent.py @@ -9,13 +9,13 @@ class Agent(Protocol): """ - Represents a bot that can operate on incoming activities. + Represents an agent that can operate on incoming activities. """ @abstractmethod async def on_turn(self, context: TurnContext): """ - When implemented in a bot, handles an incoming activity. + When implemented in an agent, handles an incoming activity. :param context: The context object for this turn. :return: """ diff --git a/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/turn_context.py b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/turn_context.py index 693bfaaa..e86e98d5 100644 --- a/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/turn_context.py +++ b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/turn_context.py @@ -340,11 +340,11 @@ def apply_conversation_reference( activity.conversation = reference.conversation if is_incoming: activity.from_property = reference.user - activity.recipient = reference.bot + activity.recipient = reference.agent if reference.activity_id: activity.id = reference.activity_id else: - activity.from_property = reference.bot + activity.from_property = reference.agent activity.recipient = reference.user if reference.activity_id: activity.reply_to_id = reference.activity_id diff --git a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/connection_settings.py b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/connection_settings.py index c4d53760..6e8bd61d 100644 --- a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/connection_settings.py +++ b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/connection_settings.py @@ -14,18 +14,18 @@ class ConnectionSettings(DirectToEngineConnectionSettingsProtocol): def __init__( self, environment_id: str, - bot_identifier: str, + agent_identifier: str, cloud: Optional[PowerPlatformCloud], copilot_agent_type: Optional[AgentType], custom_power_platform_cloud: Optional[str], ) -> None: self.environment_id = environment_id - self.bot_identifier = bot_identifier + self.agent_identifier = agent_identifier if not self.environment_id: raise ValueError("Environment ID must be provided") - if not self.bot_identifier: - raise ValueError("Bot Identifier must be provided") + if not self.agent_identifier: + raise ValueError("Agent Identifier must be provided") self.cloud = cloud or PowerPlatformCloud.UNKNOWN self.copilot_agent_type = copilot_agent_type or AgentType.PUBLISHED diff --git a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/direct_to_engine_connection_settings_protocol.py b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/direct_to_engine_connection_settings_protocol.py index fdc1ad7c..807e0d76 100644 --- a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/direct_to_engine_connection_settings_protocol.py +++ b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/direct_to_engine_connection_settings_protocol.py @@ -10,7 +10,7 @@ class DirectToEngineConnectionSettingsProtocol(Protocol): """ # Schema name for the Copilot Studio Hosted Copilot. - bot_identifier: Optional[str] + agent_identifier: Optional[str] # if PowerPlatformCloud is set to Other, this is the url for the power platform API endpoint. custom_power_platform_cloud: Optional[str] diff --git a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/power_platform_environment.py b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/power_platform_environment.py index 5fabf3ce..78589fdf 100644 --- a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/power_platform_environment.py +++ b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/power_platform_environment.py @@ -27,8 +27,8 @@ def get_copilot_studio_connection_url( ) if not settings.environment_id: raise ValueError("EnvironmentId must be provided") - if not settings.bot_identifier: - raise ValueError("BotIdentifier must be provided") + if not settings.agent_identifier: + raise ValueError("AgentIdentifier must be provided") if settings.cloud and settings.cloud != PowerPlatformCloud.UNKNOWN: cloud = settings.cloud if cloud == PowerPlatformCloud.OTHER: @@ -50,7 +50,7 @@ def get_copilot_studio_connection_url( cloud, settings.environment_id, cloud_base_address ) return PowerPlatformEnvironment.create_uri( - settings.bot_identifier, host, agent_type, conversation_id + settings.agent_identifier, host, agent_type, conversation_id ) @staticmethod @@ -87,15 +87,15 @@ def get_token_audience( @staticmethod def create_uri( - bot_identifier: str, + agent_identifier: str, host: str, agent_type: AgentType, conversation_id: Optional[str], ) -> str: - bot_path_name = ( + agent_path_name = ( "dataverse-backed" if agent_type == AgentType.PUBLISHED else "prebuilt" ) - path = f"/copilotstudio/{bot_path_name}/authenticated/bots/{bot_identifier}/conversations" + path = f"/copilotstudio/{agent_path_name}/authenticated/bots/{agent_identifier}/conversations" if conversation_id: path += f"/{conversation_id}" return urlunparse( diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/activity.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/activity.py index 4b06225d..2de61f13 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/activity.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/activity.py @@ -188,12 +188,12 @@ def apply_conversation_reference( if is_incoming: self.from_property = reference.user - self.recipient = reference.bot + self.recipient = reference.agent if reference.activity_id is not None: self.id = reference.activity_id else: - self.from_property = reference.bot + self.from_property = reference.agent self.recipient = reference.user if reference.activity_id is not None: @@ -515,7 +515,7 @@ def get_conversation_reference(self) -> ConversationReference: else None ), user=copy(self.from_property), - bot=copy(self.recipient), + agent=copy(self.recipient), conversation=copy(self.conversation), channel_id=self.channel_id, locale=self.locale, diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_reference.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_reference.py index 995196ae..c6ce6fed 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_reference.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_reference.py @@ -1,6 +1,8 @@ from uuid import uuid4 as uuid from typing import Optional +from pydantic import Field + from .channel_account import ChannelAccount from .conversation_account import ConversationAccount from .agents_model import AgentsModel @@ -16,8 +18,8 @@ class ConversationReference(AgentsModel): :type activity_id: str :param user: (Optional) User participating in this conversation :type user: ~microsoft.agents.protocols.models.ChannelAccount - :param bot: Bot participating in this conversation - :type bot: ~microsoft.agents.protocols.models.ChannelAccount + :param agent: Bot participating in this conversation + :type agent: ~microsoft.agents.protocols.models.ChannelAccount :param conversation: Conversation reference :type conversation: ~microsoft.agents.protocols.models.ConversationAccount :param channel_id: Channel ID @@ -36,7 +38,7 @@ class ConversationReference(AgentsModel): # optionals here are due to webchat activity_id: Optional[NonEmptyString] = None user: ChannelAccount = None - bot: ChannelAccount = None + agent: ChannelAccount = Field(None, alias="bot") conversation: ConversationAccount channel_id: NonEmptyString locale: Optional[NonEmptyString] = None @@ -52,7 +54,7 @@ def get_continuation_activity(self) -> "Activity": # type: ignore channel_id=self.channel_id, service_url=self.service_url, conversation=self.conversation, - recipient=self.bot, + recipient=self.agent, from_property=self.user, relates_to=self, ) diff --git a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/agent_http_adapter.py b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/agent_http_adapter.py index 22482644..305aec5f 100644 --- a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/agent_http_adapter.py +++ b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/agent_http_adapter.py @@ -14,5 +14,5 @@ class AgentHttpAdapter(Protocol): @abstractmethod - async def process(self, request: Request, bot: Agent) -> Optional[Response]: + async def process(self, request: Request, agent: Agent) -> Optional[Response]: raise NotImplementedError() diff --git a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/cloud_adapter.py b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/cloud_adapter.py index eed3aa64..b997b7bb 100644 --- a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/cloud_adapter.py +++ b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/cloud_adapter.py @@ -57,11 +57,11 @@ async def on_turn_error(context: TurnContext, error: Exception): self.on_turn_error = on_turn_error self._channel_service_client_factory = channel_service_client_factory - async def process(self, request: Request, bot: Agent) -> Optional[Response]: + async def process(self, request: Request, agent: Agent) -> Optional[Response]: if not request: raise TypeError("CloudAdapter.process: request can't be None") - if not bot: - raise TypeError("CloudAdapter.process: bot can't be None") + if not agent: + raise TypeError("CloudAdapter.process: agent can't be None") if request.method == "POST": # Deserialize the incoming Activity @@ -84,7 +84,7 @@ async def process(self, request: Request, bot: Agent) -> Optional[Response]: try: # Process the inbound activity with the agent invoke_response = await self.process_activity( - claims_identity, activity, bot.on_turn + claims_identity, activity, agent.on_turn ) if ( diff --git a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/jwt_authorization_middleware.py b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/jwt_authorization_middleware.py index bf258d7f..69f8b717 100644 --- a/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/jwt_authorization_middleware.py +++ b/libraries/Hosting/microsoft-agents-hosting-aiohttp/microsoft/agents/hosting/aiohttp/jwt_authorization_middleware.py @@ -5,7 +5,7 @@ @middleware async def jwt_authorization_middleware(request: Request, handler): - auth_config: AgentAuthConfiguration = request.app["bot_configuration"] + auth_config: AgentAuthConfiguration = request.app["agent_configuration"] token_validator = JwtTokenValidator(auth_config) auth_header = request.headers.get("Authorization") if auth_header: diff --git a/test_samples/bot_to_bot/bot_1/app.py b/test_samples/bot_to_bot/bot_1/app.py index d06c7c0a..05703154 100644 --- a/test_samples/bot_to_bot/bot_1/app.py +++ b/test_samples/bot_to_bot/bot_1/app.py @@ -76,7 +76,7 @@ async def messages(req: Request) -> Response: APP = Application(middlewares=[jwt_authorization_middleware]) APP.router.add_post("/api/messages", messages) APP.router.add_routes(channel_service_route_table(BOT, "/api/botresponse")) -APP["bot_configuration"] = CONFIG +APP["agent_configuration"] = CONFIG APP["adapter"] = ADAPTER if __name__ == "__main__": diff --git a/test_samples/bot_to_bot/bot_2/app.py b/test_samples/bot_to_bot/bot_2/app.py index 2d192972..ffcd4b58 100644 --- a/test_samples/bot_to_bot/bot_2/app.py +++ b/test_samples/bot_to_bot/bot_2/app.py @@ -50,7 +50,7 @@ async def messages(req: Request) -> Response: APP = Application(middlewares=[jwt_authorization_middleware]) APP.router.add_post("/api/messages", messages) -APP["bot_configuration"] = CONFIG +APP["agent_configuration"] = CONFIG APP["adapter"] = ADAPTER if __name__ == "__main__": diff --git a/test_samples/copilot_studio_client_sample/config.py b/test_samples/copilot_studio_client_sample/config.py index d885afdc..07fcd1b7 100644 --- a/test_samples/copilot_studio_client_sample/config.py +++ b/test_samples/copilot_studio_client_sample/config.py @@ -14,7 +14,7 @@ def __init__( app_client_id: Optional[str] = None, tenant_id: Optional[str] = None, environment_id: Optional[str] = None, - bot_identifier: Optional[str] = None, + agent_identifier: Optional[str] = None, cloud: Optional[PowerPlatformCloud] = None, copilot_agent_type: Optional[AgentType] = None, custom_power_platform_cloud: Optional[str] = None, @@ -28,7 +28,7 @@ def __init__( raise ValueError("Tenant ID must be provided") environment_id = environment_id or environ.get("ENVIRONMENT_ID") - bot_identifier = bot_identifier or environ.get("BOT_IDENTIFIER") + agent_identifier = agent_identifier or environ.get("BOT_IDENTIFIER") cloud = cloud or PowerPlatformCloud[environ.get("CLOUD", "UNKNOWN")] copilot_agent_type = ( copilot_agent_type or AgentType[environ.get("COPILOT_agent_type", "PUBLISHED")] @@ -39,7 +39,7 @@ def __init__( super().__init__( environment_id, - bot_identifier, + agent_identifier, cloud, copilot_agent_type, custom_power_platform_cloud, diff --git a/test_samples/echo_bot/app.py b/test_samples/echo_bot/app.py index 3f78f27e..7d1caa52 100644 --- a/test_samples/echo_bot/app.py +++ b/test_samples/echo_bot/app.py @@ -50,7 +50,7 @@ async def messages(req: Request) -> Response: APP = Application(middlewares=[jwt_authorization_middleware]) APP.router.add_post("/api/messages", messages) -APP["bot_configuration"] = CONFIG +APP["agent_configuration"] = CONFIG APP["adapter"] = ADAPTER if __name__ == "__main__": From aeff9a8d3ce7719900312dcc2133e443da9509a1 Mon Sep 17 00:00:00 2001 From: Axel Suarez Date: Fri, 21 Mar 2025 14:44:16 -0700 Subject: [PATCH 3/5] WIP - Renaming bot references --- .../agents/builder/channel_service_adapter.py | 2 +- .../microsoft/agents/builder/turn_context.py | 2 +- ..._sign_in_base.py => agent_sign_in_base.py} | 2 +- .../agents/connector/connector_client.py | 2 +- .../agents/connector/conversations_base.py | 2 +- .../operations/_connector_operations.py | 26 +++++++++---------- .../agents/connector/operations/_internals.py | 26 +++++++++---------- .../connector/token/operations/__init__.py | 4 +-- .../connector/token/operations/_internals.py | 12 ++++----- .../operations/_user_token_operations.py | 12 ++++----- .../connector/token/user_token_client.py | 14 +++++----- .../connector/user_token_client_base.py | 4 +-- ..._to_engine_connection_settings_protocol.py | 2 +- .../authentication_constants.py | 12 ++++----- .../microsoft/agents/core/models/activity.py | 8 +++--- .../agents/core/models/channel_account.py | 5 ++-- .../microsoft/agents/core/models/channels.py | 2 +- .../core/models/conversation_account.py | 5 ++-- .../core/models/conversation_parameters.py | 8 +++--- .../core/models/conversation_reference.py | 2 +- .../core/models/end_of_conversation_codes.py | 4 +-- .../agents/core/models/role_types.py | 2 +- .../core/models/token_exchange_state.py | 10 ++++--- .../bot_1 => agent_to_agent/agent_1}/app.py | 0 .../bot_1 => agent_to_agent/agent_1}/bot1.py | 0 .../agent_1}/config.py | 6 ++--- .../bot_2 => agent_to_agent/agent_2}/app.py | 0 .../bot_2 => agent_to_agent/agent_2}/bot2.py | 0 .../agent_2}/config.py | 0 29 files changed, 88 insertions(+), 86 deletions(-) rename libraries/Client/microsoft-agents-connector/microsoft/agents/connector/{bot_sign_in_base.py => agent_sign_in_base.py} (94%) rename test_samples/{bot_to_bot/bot_1 => agent_to_agent/agent_1}/app.py (100%) rename test_samples/{bot_to_bot/bot_1 => agent_to_agent/agent_1}/bot1.py (100%) rename test_samples/{bot_to_bot/bot_1 => agent_to_agent/agent_1}/config.py (89%) rename test_samples/{bot_to_bot/bot_2 => agent_to_agent/agent_2}/app.py (100%) rename test_samples/{bot_to_bot/bot_2 => agent_to_agent/agent_2}/bot2.py (100%) rename test_samples/{bot_to_bot/bot_2 => agent_to_agent/agent_2}/config.py (100%) diff --git a/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_service_adapter.py b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_service_adapter.py index 14dada39..37bd35c6 100644 --- a/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_service_adapter.py +++ b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_service_adapter.py @@ -419,7 +419,7 @@ def _create_create_activity( tenant_id=conversation_parameters.tenant_id, ) activity.channel_data = conversation_parameters.channel_data - activity.recipient = conversation_parameters.bot + activity.recipient = conversation_parameters.agent return activity diff --git a/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/turn_context.py b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/turn_context.py index e86e98d5..d2d49402 100644 --- a/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/turn_context.py +++ b/libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/turn_context.py @@ -21,7 +21,7 @@ class TurnContext(TurnContextProtocol): # Same constant as in the BF Adapter, duplicating here to avoid circular dependency - _INVOKE_RESPONSE_KEY = "BotFrameworkAdapter.InvokeResponse" + _INVOKE_RESPONSE_KEY = "TurnContext.InvokeResponse" def __init__(self, adapter_or_context, request: Activity = None): """ diff --git a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/bot_sign_in_base.py b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/agent_sign_in_base.py similarity index 94% rename from libraries/Client/microsoft-agents-connector/microsoft/agents/connector/bot_sign_in_base.py rename to libraries/Client/microsoft-agents-connector/microsoft/agents/connector/agent_sign_in_base.py index dcdf9c02..b9ef10d9 100644 --- a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/bot_sign_in_base.py +++ b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/agent_sign_in_base.py @@ -4,7 +4,7 @@ from microsoft.agents.core.models import SignInResource -class BotSignInBase(Protocol): +class AgentSignInBase(Protocol): @abstractmethod async def get_sign_in_url( self, diff --git a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/connector_client.py b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/connector_client.py index 30e4f4d8..40fd7989 100644 --- a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/connector_client.py +++ b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/connector_client.py @@ -30,7 +30,7 @@ class ConnectorClient( ConnectorClientBase ): # pylint: disable=client-accepts-api-version-keyword - """The Azure Bot Service Connector APIs allow bots to send and receive + """The ABS Connector APIs allow agents to send and receive messages, button clicks, and other programmatic events when connecting with end users. This API also includes facilities to get conversation metadata and perform other operations (deletions and content editing). This REST API diff --git a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/conversations_base.py b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/conversations_base.py index 88b71394..f25c50f4 100644 --- a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/conversations_base.py +++ b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/conversations_base.py @@ -24,7 +24,7 @@ async def get_conversations( self, continuation_token: Optional[str] = None ) -> ConversationsResult: """ - List the Conversations in which this bot has participated. + List the Conversations in which this agent has participated. """ raise NotImplementedError() diff --git a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_connector_operations.py b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_connector_operations.py index 3a0822fe..133d2643 100644 --- a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_connector_operations.py +++ b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_connector_operations.py @@ -279,7 +279,7 @@ async def get_conversations( ) -> JSON: """GetConversations. - List the Conversations in which this bot has participated. + List the Conversations in which this agent has participated. GET from this method with a skip token @@ -378,7 +378,7 @@ async def create_conversation( POST to this method with a - * Bot being the bot creating the conversation + * Agent being the agent creating the conversation * IsGroup set to true if this is not a direct message (default is false) * Array containing the members to include in the conversation @@ -386,13 +386,13 @@ async def create_conversation( use in the message payload and REST API uris. - Most channels only support the semantics of bots initiating a direct message conversation. An + Most channels only support the semantics of agents initiating a direct message conversation. An example of how to do that would be: .. code-block:: var resource = await connector.conversations.CreateConversation(new - ConversationParameters(){ Bot = bot, members = new ChannelAccount[] { new + ConversationParameters(){ Bot = agent, members = new ChannelAccount[] { new ChannelAccount("user1") } ); await connect.Conversations.SendToConversationAsync(resource.Id, new Activity() ... ) ;. @@ -606,7 +606,7 @@ async def create_conversation( POST to this method with a - * Bot being the bot creating the conversation + * Bot being the agent creating the conversation * IsGroup set to true if this is not a direct message (default is false) * Array containing the members to include in the conversation @@ -614,13 +614,13 @@ async def create_conversation( use in the message payload and REST API uris. - Most channels only support the semantics of bots initiating a direct message conversation. An + Most channels only support the semantics of agents initiating a direct message conversation. An example of how to do that would be: .. code-block:: var resource = await connector.conversations.CreateConversation(new - ConversationParameters(){ Bot = bot, members = new ChannelAccount[] { new + ConversationParameters(){ Bot = agent, members = new ChannelAccount[] { new ChannelAccount("user1") } ); await connect.Conversations.SendToConversationAsync(resource.Id, new Activity() ... ) ;. @@ -655,7 +655,7 @@ async def create_conversation( POST to this method with a - * Bot being the bot creating the conversation + * Bot being the agent creating the conversation * IsGroup set to true if this is not a direct message (default is false) * Array containing the members to include in the conversation @@ -663,13 +663,13 @@ async def create_conversation( use in the message payload and REST API uris. - Most channels only support the semantics of bots initiating a direct message conversation. An + Most channels only support the semantics of agents initiating a direct message conversation. An example of how to do that would be: .. code-block:: var resource = await connector.conversations.CreateConversation(new - ConversationParameters(){ Bot = bot, members = new ChannelAccount[] { new + ConversationParameters(){ Bot = agent, members = new ChannelAccount[] { new ChannelAccount("user1") } ); await connect.Conversations.SendToConversationAsync(resource.Id, new Activity() ... ) ;. @@ -1931,7 +1931,7 @@ async def update_activity( Edit an existing activity. - Some channels allow you to edit an existing activity to reflect the new state of a bot + Some channels allow you to edit an existing activity to reflect the new state of an agent conversation. For example, you can remove buttons after someone has clicked "Approve" button. @@ -2127,7 +2127,7 @@ async def update_activity( Edit an existing activity. - Some channels allow you to edit an existing activity to reflect the new state of a bot + Some channels allow you to edit an existing activity to reflect the new state of an agent conversation. For example, you can remove buttons after someone has clicked "Approve" button. @@ -2166,7 +2166,7 @@ async def update_activity( Edit an existing activity. - Some channels allow you to edit an existing activity to reflect the new state of a bot + Some channels allow you to edit an existing activity to reflect the new state of an agent conversation. For example, you can remove buttons after someone has clicked "Approve" button. diff --git a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_internals.py b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_internals.py index 9fccef59..0770de23 100644 --- a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_internals.py +++ b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_internals.py @@ -1324,7 +1324,7 @@ def get_conversations( ) -> JSON: """GetConversations. - List the Conversations in which this bot has participated. + List the Conversations in which this agent has participated. GET from this method with a skip token @@ -1423,7 +1423,7 @@ def create_conversation( POST to this method with a - * Bot being the bot creating the conversation + * Agent being the agent creating the conversation * IsGroup set to true if this is not a direct message (default is false) * Array containing the members to include in the conversation @@ -1431,13 +1431,13 @@ def create_conversation( use in the message payload and REST API uris. - Most channels only support the semantics of bots initiating a direct message conversation. An + Most channels only support the semantics of agents initiating a direct message conversation. An example of how to do that would be: .. code-block:: var resource = await connector.conversations.CreateConversation(new - ConversationParameters(){ Bot = bot, members = new ChannelAccount[] { new + ConversationParameters(){ Bot = agent, members = new ChannelAccount[] { new ChannelAccount("user1") } ); await connect.Conversations.SendToConversationAsync(resource.Id, new Activity() ... ) ;. @@ -1651,7 +1651,7 @@ def create_conversation( POST to this method with a - * Bot being the bot creating the conversation + * Bot being the agent creating the conversation * IsGroup set to true if this is not a direct message (default is false) * Array containing the members to include in the conversation @@ -1659,13 +1659,13 @@ def create_conversation( use in the message payload and REST API uris. - Most channels only support the semantics of bots initiating a direct message conversation. An + Most channels only support the semantics of agents initiating a direct message conversation. An example of how to do that would be: .. code-block:: var resource = await connector.conversations.CreateConversation(new - ConversationParameters(){ Bot = bot, members = new ChannelAccount[] { new + ConversationParameters(){ Bot = agent, members = new ChannelAccount[] { new ChannelAccount("user1") } ); await connect.Conversations.SendToConversationAsync(resource.Id, new Activity() ... ) ;. @@ -1700,7 +1700,7 @@ def create_conversation( POST to this method with a - * Bot being the bot creating the conversation + * Bot being the agent creating the conversation * IsGroup set to true if this is not a direct message (default is false) * Array containing the members to include in the conversation @@ -1708,13 +1708,13 @@ def create_conversation( use in the message payload and REST API uris. - Most channels only support the semantics of bots initiating a direct message conversation. An + Most channels only support the semantics of agents initiating a direct message conversation. An example of how to do that would be: .. code-block:: var resource = await connector.conversations.CreateConversation(new - ConversationParameters(){ Bot = bot, members = new ChannelAccount[] { new + ConversationParameters(){ Bot = agent, members = new ChannelAccount[] { new ChannelAccount("user1") } ); await connect.Conversations.SendToConversationAsync(resource.Id, new Activity() ... ) ;. @@ -2976,7 +2976,7 @@ def update_activity( Edit an existing activity. - Some channels allow you to edit an existing activity to reflect the new state of a bot + Some channels allow you to edit an existing activity to reflect the new state of an agent conversation. For example, you can remove buttons after someone has clicked "Approve" button. @@ -3172,7 +3172,7 @@ def update_activity( Edit an existing activity. - Some channels allow you to edit an existing activity to reflect the new state of a bot + Some channels allow you to edit an existing activity to reflect the new state of an agent conversation. For example, you can remove buttons after someone has clicked "Approve" button. @@ -3211,7 +3211,7 @@ def update_activity( Edit an existing activity. - Some channels allow you to edit an existing activity to reflect the new state of a bot + Some channels allow you to edit an existing activity to reflect the new state of an agent conversation. For example, you can remove buttons after someone has clicked "Approve" button. diff --git a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/operations/__init__.py b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/operations/__init__.py index d38b8753..66a0cfc3 100644 --- a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/operations/__init__.py +++ b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/operations/__init__.py @@ -5,12 +5,12 @@ # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position -from ._user_token_operations import BotSignInOperations # type: ignore +from ._user_token_operations import AgentSignInOperations # type: ignore from ._user_token_operations import UserTokenOperations # type: ignore from ._user_token_operations import TokenInternalsOperations # type: ignore __all__ = [ - "BotSignInOperations", + "AgentSignInOperations", "UserTokenOperations", "TokenInternalsOperations", ] diff --git a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/operations/_internals.py b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/operations/_internals.py index 96039cba..af535f10 100644 --- a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/operations/_internals.py +++ b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/operations/_internals.py @@ -48,7 +48,7 @@ _SERIALIZER.client_side_validation = False -def build_bot_sign_in_get_sign_in_url_request( # pylint: disable=name-too-long +def build_agent_sign_in_get_sign_in_url_request( # pylint: disable=name-too-long *, state: str, code_challenge: Optional[str] = None, @@ -85,7 +85,7 @@ def build_bot_sign_in_get_sign_in_url_request( # pylint: disable=name-too-long ) -def build_bot_sign_in_get_sign_in_resource_request( # pylint: disable=name-too-long +def build_agent_sign_in_get_sign_in_resource_request( # pylint: disable=name-too-long *, state: str, code_challenge: Optional[str] = None, @@ -404,14 +404,14 @@ def build_token_internals_post_error_response_request( return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -class BotSignInOperations: +class AgentSignInOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~microsoft.agents.protocols.connector.Token`'s - :attr:`bot_sign_in` attribute. + :attr:`agent_sign_in` attribute. """ def __init__(self, *args, **kwargs): @@ -460,7 +460,7 @@ def get_sign_in_url( cls: ClsType[str] = kwargs.pop("cls", None) - _request = build_bot_sign_in_get_sign_in_url_request( + _request = build_agent_sign_in_get_sign_in_url_request( state=state, code_challenge=code_challenge, emulator_url=emulator_url, @@ -545,7 +545,7 @@ def get_sign_in_resource( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_bot_sign_in_get_sign_in_resource_request( + _request = build_agent_sign_in_get_sign_in_resource_request( state=state, code_challenge=code_challenge, emulator_url=emulator_url, diff --git a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/operations/_user_token_operations.py b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/operations/_user_token_operations.py index a2a809bb..edadbe39 100644 --- a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/operations/_user_token_operations.py +++ b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/operations/_user_token_operations.py @@ -33,8 +33,8 @@ from azure.core.utils import case_insensitive_dict from ._internals import ( - build_bot_sign_in_get_sign_in_resource_request, - build_bot_sign_in_get_sign_in_url_request, + build_agent_sign_in_get_sign_in_resource_request, + build_agent_sign_in_get_sign_in_url_request, build_token_internals_post_error_response_request, build_token_internals_post_sign_in_url_response_request, build_token_internals_post_token_exchange_resource_request, @@ -58,14 +58,14 @@ ] -class BotSignInOperations: +class AgentSignInOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~microsoft.agents.connector.Token`'s - :attr:`bot_sign_in` attribute. + :attr:`agent_sign_in` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -114,7 +114,7 @@ async def get_sign_in_url( cls: ClsType[str] = kwargs.pop("cls", None) - _request = build_bot_sign_in_get_sign_in_url_request( + _request = build_agent_sign_in_get_sign_in_url_request( state=state, code_challenge=code_challenge, emulator_url=emulator_url, @@ -199,7 +199,7 @@ async def get_sign_in_resource( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_bot_sign_in_get_sign_in_resource_request( + _request = build_agent_sign_in_get_sign_in_resource_request( state=state, code_challenge=code_challenge, emulator_url=emulator_url, diff --git a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/user_token_client.py b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/user_token_client.py index 6d67e9da..e8194e37 100644 --- a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/user_token_client.py +++ b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/token/user_token_client.py @@ -15,12 +15,12 @@ from ._user_token_client_configuration import TokenConfiguration from .operations import ( - BotSignInOperations, + AgentSignInOperations, TokenInternalsOperations, UserTokenOperations, ) from .._serialization import Deserializer, Serializer -from ..bot_sign_in_base import BotSignInBase +from ..agent_sign_in_base import AgentSignInBase from ..user_token_base import UserTokenBase from ..user_token_client_base import UserTokenClientBase @@ -30,8 +30,8 @@ class UserTokenClient( ): # pylint: disable=client-accepts-api-version-keyword """Token. - :ivar bot_sign_in: BotSignInOperations operations - :vartype bot_sign_in: microsoft.agents.connector.operations.BotSignInOperations + :ivar agent_sign_in: AgentSignInOperations operations + :vartype agent_sign_in: microsoft.agents.connector.operations.AgentSignInOperations :ivar user_token: UserTokenOperations operations :vartype user_token: microsoft.agents.connector.operations.UserTokenOperations :ivar token_internals: TokenInternalsOperations operations @@ -75,7 +75,7 @@ def __init__( self._serialize = Serializer() self._deserialize = Deserializer() self._serialize.client_side_validation = False - self._bot_sign_in = BotSignInOperations( + self._agent_sign_in = AgentSignInOperations( self._client, self._config, self._serialize, self._deserialize ) self._user_token = UserTokenOperations( @@ -86,8 +86,8 @@ def __init__( ) @property - def bot_sign_in(self) -> BotSignInBase: - return self._bot_sign_in + def agent_sign_in(self) -> AgentSignInBase: + return self._agent_sign_in @property def user_token(self) -> UserTokenBase: diff --git a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/user_token_client_base.py b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/user_token_client_base.py index f25aad4d..d7f0f141 100644 --- a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/user_token_client_base.py +++ b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/user_token_client_base.py @@ -1,14 +1,14 @@ from abc import abstractmethod from typing import Protocol -from .bot_sign_in_base import BotSignInBase +from .agent_sign_in_base import AgentSignInBase from .user_token_base import UserTokenBase class UserTokenClientBase(Protocol): @property @abstractmethod - def bot_sign_in(self) -> BotSignInBase: + def agent_sign_in(self) -> AgentSignInBase: pass @property diff --git a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/direct_to_engine_connection_settings_protocol.py b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/direct_to_engine_connection_settings_protocol.py index 807e0d76..b4750c31 100644 --- a/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/direct_to_engine_connection_settings_protocol.py +++ b/libraries/Client/microsoft-agents-copilotstudio-client/microsoft/agents/copilotstudio/client/direct_to_engine_connection_settings_protocol.py @@ -21,5 +21,5 @@ class DirectToEngineConnectionSettingsProtocol(Protocol): # Power Platform Cloud where the environment is hosted cloud: Optional[PowerPlatformCloud] - # Type of Bot hosted in Copilot Studio + # Type of Agent hosted in Copilot Studio copilot_agent_type: Optional[AgentType] diff --git a/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/authentication_constants.py b/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/authentication_constants.py index b0d8847b..c370ea72 100644 --- a/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/authentication_constants.py +++ b/libraries/Core/microsoft-agents-authentication/microsoft/agents/authentication/authentication_constants.py @@ -5,7 +5,7 @@ class AuthenticationConstants(ABC): - # Bot Framework OAuth scope to request. + # Agents SDK OAuth scope to request. AGENTS_SDK_SCOPE = "https://api.botframework.com" # Token issuer for ABS tokens. @@ -14,8 +14,8 @@ class AuthenticationConstants(ABC): # Default OAuth Url used to get a token from IUserTokenClient. AGENTS_SDK_OAUTH_URL = "https://api.botframework.com" - # Public Azure Bot Service OpenId Metadata URL. - PUBLIC_AZURE_BOT_SERVICE_OPENID_METADATA_URL = ( + # Public ABS OpenId Metadata URL. + PUBLIC_ABS_OPENID_METADATA_URL = ( "https://login.botframework.com/v1/.well-known/openidconfiguration" ) @@ -27,8 +27,8 @@ class AuthenticationConstants(ABC): # Enterprise Channel OpenId Metadata URL format. ENTERPRISE_CHANNEL_OPENID_METADATA_URL_FORMAT = "https://{0}.enterprisechannel.botframework.com/v1/.well-known/openidconfiguration" - # Gov Azure Bot Service OpenId Metadata URL. - GOV_AZURE_BOT_SERVICE_OPENID_METADATA_URL = ( + # Gov ABS OpenId Metadata URL. + GOV_ABS_OPENID_METADATA_URL = ( "https://login.botframework.azure.us/v1/.well-known/openidconfiguration" ) @@ -95,7 +95,7 @@ class AuthenticationConstants(ABC): # App ID claim name. As used in Microsoft AAD 1.0 tokens. APP_ID_CLAIM = "appid" - # Service URL claim name. As used in Microsoft Bot Framework v3.1 auth. + # Service URL claim name. SERVICE_URL_CLAIM = "serviceurl" # Tenant Id claim name. As used in Microsoft AAD tokens. diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/activity.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/activity.py index 2de61f13..fad8324f 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/activity.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/activity.py @@ -18,9 +18,9 @@ from ._type_aliases import NonEmptyString -# TODO: B2B Bot 2 is responding with None as id, had to mark it as optional (investigate) +# TODO: A2A Agent 2 is responding with None as id, had to mark it as optional (investigate) class Activity(AgentsModel): - """An Activity is the basic communication type for the Bot Framework 3.0 protocol. + """An Activity is the basic communication type for the protocol. :param type: Contains the activity type. Possible values include: 'message', 'contactRelationUpdate', 'conversationUpdate', 'typing', @@ -72,7 +72,7 @@ class Activity(AgentsModel): :type text: str :param speak: The text to speak. :type speak: str - :param input_hint: Indicates whether your bot is accepting, expecting, or ignoring user input after the message is delivered to the client. + :param input_hint: Indicates whether your agent is accepting, expecting, or ignoring user input after the message is delivered to the client. Possible values include: 'acceptingInput', 'ignoringInput', 'expectingInput' :type input_hint: str or ~microsoft.agents.protocols.models.InputHints :param summary: The text to display if the channel cannot render cards. @@ -116,7 +116,7 @@ class Activity(AgentsModel): :param semantic_action: An optional programmatic action accompanying this request :type semantic_action: ~microsoft.agents.protocols.models.SemanticAction :param caller_id: A string containing an IRI identifying the caller of an agent. This field is not intended to be transmitted over the wire, - but is instead populated by bots and clients based on cryptographically verifiable data that asserts the identity of the callers (e.g. tokens). + but is instead populated by agents and clients based on cryptographically verifiable data that asserts the identity of the callers (e.g. tokens). :type caller_id: str """ diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/channel_account.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/channel_account.py index 3f601da9..7c4d1743 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/channel_account.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/channel_account.py @@ -5,7 +5,7 @@ class ChannelAccount(AgentsModel): """Channel account information needed to route a message. - :param id: Channel id for the user or bot on this channel (Example: + :param id: Channel id for the user or agent on this channel (Example: joe@smith.com, or @joesmith or 123456) :type id: str :param name: Display friendly name @@ -13,8 +13,7 @@ class ChannelAccount(AgentsModel): :param aad_object_id: This account's object ID within Azure Active Directory (AAD) :type aad_object_id: str - :param role: Role of the entity behind the account (Example: User, Bot, - etc.). Possible values include: 'user', 'bot' + :param role: Role of the entity behind the account :type role: str or ~microsoft.agents.protocols.models.RoleTypes """ diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/channels.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/channels.py index ca20b701..dbb47e62 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/channels.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/channels.py @@ -7,7 +7,7 @@ class Channels(str, Enum): """ - Ids of channels supported by the Bot Builder. + Ids of channels supported by ABS. """ console = "console" diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_account.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_account.py index acd08382..c710fdfe 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_account.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_account.py @@ -11,7 +11,7 @@ class ConversationAccount(AgentsModel): :param conversation_type: Indicates the type of the conversation in channels that distinguish between conversation types :type conversation_type: str - :param id: Channel id for the user or bot on this channel (Example: + :param id: Channel id for the user or agent on this channel (Example: joe@smith.com, or @joesmith or 123456) :type id: str :param name: Display friendly name @@ -19,8 +19,7 @@ class ConversationAccount(AgentsModel): :param aad_object_id: This account's object ID within Azure Active Directory (AAD) :type aad_object_id: str - :param role: Role of the entity behind the account (Example: User, Bot, - etc.). Possible values include: 'user', 'bot', 'skill' + :param role: Role of the entity behind the account :type role: str or ~microsoft.agents.protocols.models.RoleTypes :param tenant_id: This conversation's tenant ID :type tenant_id: str diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_parameters.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_parameters.py index cada9e04..90d68848 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_parameters.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_parameters.py @@ -1,3 +1,5 @@ +from pydantic import Field + from .channel_account import ChannelAccount from .activity import Activity from .agents_model import AgentsModel @@ -9,8 +11,8 @@ class ConversationParameters(AgentsModel): :param is_group: IsGroup :type is_group: bool - :param bot: The bot address for this conversation - :type bot: ~microsoft.agents.protocols.models.ChannelAccount + :param agent: The bot address for this conversation + :type agent: ~microsoft.agents.protocols.models.ChannelAccount :param members: Members to add to the conversation :type members: list[~microsoft.agents.protocols.models.ChannelAccount] :param topic_name: (Optional) Topic of the conversation (if supported by @@ -27,7 +29,7 @@ class ConversationParameters(AgentsModel): """ is_group: bool = None - bot: ChannelAccount = None + agent: ChannelAccount = Field(None, alias="bot") members: list[ChannelAccount] = None topic_name: NonEmptyString = None activity: Activity = None diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_reference.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_reference.py index c6ce6fed..1017c706 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_reference.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_reference.py @@ -18,7 +18,7 @@ class ConversationReference(AgentsModel): :type activity_id: str :param user: (Optional) User participating in this conversation :type user: ~microsoft.agents.protocols.models.ChannelAccount - :param agent: Bot participating in this conversation + :param agent: Agent participating in this conversation :type agent: ~microsoft.agents.protocols.models.ChannelAccount :param conversation: Conversation reference :type conversation: ~microsoft.agents.protocols.models.ConversationAccount diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/end_of_conversation_codes.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/end_of_conversation_codes.py index 7e95c578..a9e70448 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/end_of_conversation_codes.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/end_of_conversation_codes.py @@ -5,6 +5,6 @@ class EndOfConversationCodes(str, Enum): unknown = "unknown" completed_successfully = "completedSuccessfully" user_cancelled = "userCancelled" - bot_timed_out = "botTimedOut" - bot_issued_invalid_message = "botIssuedInvalidMessage" + timed_out = "botTimedOut" + issued_invalid_message = "botIssuedInvalidMessage" channel_failed = "channelFailed" diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/role_types.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/role_types.py index bcafa6b0..8064c371 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/role_types.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/role_types.py @@ -3,5 +3,5 @@ class RoleTypes(str, Enum): user = "user" - bot = "bot" + agent = "bot" skill = "skill" diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/token_exchange_state.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/token_exchange_state.py index 3dbef8bf..56aa2c46 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/token_exchange_state.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/token_exchange_state.py @@ -1,3 +1,5 @@ +from pydantic import Field + from .conversation_reference import ConversationReference from .agents_model import AgentsModel from ._type_aliases import NonEmptyString @@ -12,14 +14,14 @@ class TokenExchangeState(AgentsModel): :type conversation: ~microsoft.agents.protocols.models.ConversationReference :param relates_to: Gets or sets a reference to a related parent conversation for this token exchange. :type relates_to: ~microsoft.agents.protocols.models.ConversationReference - :param bot_ur: The URL of the agent messaging endpoint. - :type bot_ur: str - :param ms_app_id: The bot's registered application ID. + :param agent_url: The URL of the agent messaging endpoint. + :type agent_url: str + :param ms_app_id: The agent's registered application ID. :type ms_app_id: str """ connection_name: NonEmptyString = None conversation: ConversationReference = None relates_to: ConversationReference = None - bot_url: NonEmptyString = None + agent_url: NonEmptyString = Field(None, alias="bot_url") ms_app_id: NonEmptyString = None diff --git a/test_samples/bot_to_bot/bot_1/app.py b/test_samples/agent_to_agent/agent_1/app.py similarity index 100% rename from test_samples/bot_to_bot/bot_1/app.py rename to test_samples/agent_to_agent/agent_1/app.py diff --git a/test_samples/bot_to_bot/bot_1/bot1.py b/test_samples/agent_to_agent/agent_1/bot1.py similarity index 100% rename from test_samples/bot_to_bot/bot_1/bot1.py rename to test_samples/agent_to_agent/agent_1/bot1.py diff --git a/test_samples/bot_to_bot/bot_1/config.py b/test_samples/agent_to_agent/agent_1/config.py similarity index 89% rename from test_samples/bot_to_bot/bot_1/config.py rename to test_samples/agent_to_agent/agent_1/config.py index a4daff4b..89f6938d 100644 --- a/test_samples/bot_to_bot/bot_1/config.py +++ b/test_samples/agent_to_agent/agent_1/config.py @@ -7,7 +7,7 @@ class DefaultConfig(MsalAuthConfiguration, ChannelsConfiguration): - """Bot Configuration""" + """Agent Configuration""" AUTH_TYPE = AuthTypes.client_secret TENANT_ID = "" @@ -22,8 +22,8 @@ def CHANNEL_HOST_CONFIGURATION(): return ChannelHostConfiguration( CHANNELS=[ ChannelInfo( - id="EchoBot", - app_id="", # Target bot's app_id + id="EchoAgent", + app_id="", # Target agent's app_id resource_url="http://localhost:3999/api/messages", token_provider="ChannelConnection", channel_factory="HttpBotClient", diff --git a/test_samples/bot_to_bot/bot_2/app.py b/test_samples/agent_to_agent/agent_2/app.py similarity index 100% rename from test_samples/bot_to_bot/bot_2/app.py rename to test_samples/agent_to_agent/agent_2/app.py diff --git a/test_samples/bot_to_bot/bot_2/bot2.py b/test_samples/agent_to_agent/agent_2/bot2.py similarity index 100% rename from test_samples/bot_to_bot/bot_2/bot2.py rename to test_samples/agent_to_agent/agent_2/bot2.py diff --git a/test_samples/bot_to_bot/bot_2/config.py b/test_samples/agent_to_agent/agent_2/config.py similarity index 100% rename from test_samples/bot_to_bot/bot_2/config.py rename to test_samples/agent_to_agent/agent_2/config.py From e4a0286041a87a38010e3e5c1342d232939f453c Mon Sep 17 00:00:00 2001 From: Axel Suarez Date: Mon, 24 Mar 2025 15:10:43 -0700 Subject: [PATCH 4/5] Renaming bot references. Samples tested --- .../operations/_connector_operations.py | 30 +--------- .../agents/connector/operations/_internals.py | 30 +--------- .../core/models/conversation_parameters.py | 2 +- .../agent_1/{bot1.py => agent1.py} | 56 +++++++++---------- test_samples/agent_to_agent/agent_1/app.py | 15 +++-- test_samples/agent_to_agent/agent_1/config.py | 2 +- .../agent_2/{bot2.py => agent2.py} | 10 ++-- test_samples/agent_to_agent/agent_2/app.py | 9 ++- test_samples/agent_to_agent/agent_2/config.py | 2 +- .../copilot_studio_client_sample/app.py | 8 +-- .../chat_console_service.py | 12 ++-- .../copilot_studio_client_sample/config.py | 2 +- .../msal_cache_plugin.py | 1 - test_samples/{echo_bot => echo_agent}/app.py | 9 ++- .../{echo_bot => echo_agent}/config.py | 2 +- .../echo_bot.py => echo_agent/echo_agent.py} | 2 +- 16 files changed, 70 insertions(+), 122 deletions(-) rename test_samples/agent_to_agent/agent_1/{bot1.py => agent1.py} (84%) rename test_samples/agent_to_agent/agent_2/{bot2.py => agent2.py} (74%) rename test_samples/{echo_bot => echo_agent}/app.py (89%) rename test_samples/{echo_bot => echo_agent}/config.py (89%) rename test_samples/{echo_bot/echo_bot.py => echo_agent/echo_agent.py} (94%) diff --git a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_connector_operations.py b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_connector_operations.py index 133d2643..719b83a6 100644 --- a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_connector_operations.py +++ b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_connector_operations.py @@ -386,15 +386,7 @@ async def create_conversation( use in the message payload and REST API uris. - Most channels only support the semantics of agents initiating a direct message conversation. An - example of how to do that would be: - - .. code-block:: - - var resource = await connector.conversations.CreateConversation(new - ConversationParameters(){ Bot = agent, members = new ChannelAccount[] { new - ChannelAccount("user1") } ); - await connect.Conversations.SendToConversationAsync(resource.Id, new Activity() ... ) ;. + Most channels only support the semantics of agents initiating a direct message conversation. :param body: Parameters to create the conversation from. Default value is None. :type body: JSON @@ -614,15 +606,7 @@ async def create_conversation( use in the message payload and REST API uris. - Most channels only support the semantics of agents initiating a direct message conversation. An - example of how to do that would be: - - .. code-block:: - - var resource = await connector.conversations.CreateConversation(new - ConversationParameters(){ Bot = agent, members = new ChannelAccount[] { new - ChannelAccount("user1") } ); - await connect.Conversations.SendToConversationAsync(resource.Id, new Activity() ... ) ;. + Most channels only support the semantics of agents initiating a direct message conversation. :param body: Parameters to create the conversation from. Default value is None. :type body: IO[bytes] @@ -663,15 +647,7 @@ async def create_conversation( use in the message payload and REST API uris. - Most channels only support the semantics of agents initiating a direct message conversation. An - example of how to do that would be: - - .. code-block:: - - var resource = await connector.conversations.CreateConversation(new - ConversationParameters(){ Bot = agent, members = new ChannelAccount[] { new - ChannelAccount("user1") } ); - await connect.Conversations.SendToConversationAsync(resource.Id, new Activity() ... ) ;. + Most channels only support the semantics of agents initiating a direct message conversation. :param body: Parameters to create the conversation from. Is either a JSON type or a IO[bytes] type. Default value is None. diff --git a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_internals.py b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_internals.py index 0770de23..4642bcea 100644 --- a/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_internals.py +++ b/libraries/Client/microsoft-agents-connector/microsoft/agents/connector/operations/_internals.py @@ -1431,15 +1431,7 @@ def create_conversation( use in the message payload and REST API uris. - Most channels only support the semantics of agents initiating a direct message conversation. An - example of how to do that would be: - - .. code-block:: - - var resource = await connector.conversations.CreateConversation(new - ConversationParameters(){ Bot = agent, members = new ChannelAccount[] { new - ChannelAccount("user1") } ); - await connect.Conversations.SendToConversationAsync(resource.Id, new Activity() ... ) ;. + Most channels only support the semantics of agents initiating a direct message conversation. :param body: Parameters to create the conversation from. Default value is None. :type body: JSON @@ -1659,15 +1651,7 @@ def create_conversation( use in the message payload and REST API uris. - Most channels only support the semantics of agents initiating a direct message conversation. An - example of how to do that would be: - - .. code-block:: - - var resource = await connector.conversations.CreateConversation(new - ConversationParameters(){ Bot = agent, members = new ChannelAccount[] { new - ChannelAccount("user1") } ); - await connect.Conversations.SendToConversationAsync(resource.Id, new Activity() ... ) ;. + Most channels only support the semantics of agents initiating a direct message conversation. :param body: Parameters to create the conversation from. Default value is None. :type body: IO[bytes] @@ -1708,15 +1692,7 @@ def create_conversation( use in the message payload and REST API uris. - Most channels only support the semantics of agents initiating a direct message conversation. An - example of how to do that would be: - - .. code-block:: - - var resource = await connector.conversations.CreateConversation(new - ConversationParameters(){ Bot = agent, members = new ChannelAccount[] { new - ChannelAccount("user1") } ); - await connect.Conversations.SendToConversationAsync(resource.Id, new Activity() ... ) ;. + Most channels only support the semantics of agents initiating a direct message conversation. :param body: Parameters to create the conversation from. Is either a JSON type or a IO[bytes] type. Default value is None. diff --git a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_parameters.py b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_parameters.py index 90d68848..e9bcf9c2 100644 --- a/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_parameters.py +++ b/libraries/Core/microsoft-agents-core/microsoft/agents/core/models/conversation_parameters.py @@ -11,7 +11,7 @@ class ConversationParameters(AgentsModel): :param is_group: IsGroup :type is_group: bool - :param agent: The bot address for this conversation + :param agent: The agent address for this conversation :type agent: ~microsoft.agents.protocols.models.ChannelAccount :param members: Members to add to the conversation :type members: list[~microsoft.agents.protocols.models.ChannelAccount] diff --git a/test_samples/agent_to_agent/agent_1/bot1.py b/test_samples/agent_to_agent/agent_1/agent1.py similarity index 84% rename from test_samples/agent_to_agent/agent_1/bot1.py rename to test_samples/agent_to_agent/agent_1/agent1.py index 30c01969..841c5781 100644 --- a/test_samples/agent_to_agent/agent_1/bot1.py +++ b/test_samples/agent_to_agent/agent_1/agent1.py @@ -31,8 +31,8 @@ ) -class Bot1(ActivityHandler, ChannelApiHandlerProtocol): - _active_bot_client = False +class Agent1(ActivityHandler, ChannelApiHandlerProtocol): + _active_agent_client = False def __init__( self, @@ -41,25 +41,25 @@ def __init__( conversation_id_factory: ConversationIdFactoryProtocol, ): if not adapter: - raise ValueError("Bot1.__init__(): adapter cannot be None") + raise ValueError("Agent1.__init__(): adapter cannot be None") if not channel_host: - raise ValueError("Bot1.__init__(): channel_host cannot be None") + raise ValueError("Agent1.__init__(): channel_host cannot be None") if not conversation_id_factory: - raise ValueError("Bot1.__init__(): conversation_id_factory cannot be None") + raise ValueError("Agent1.__init__(): conversation_id_factory cannot be None") self._adapter = adapter self._channel_host = channel_host self._conversation_id_factory = conversation_id_factory - target_b2b_id = "EchoBot" - self._target_b2b = self._channel_host.channels.get(target_b2b_id) + target_a2a_id = "EchoAgent" + self._target_a2a = self._channel_host.channels.get(target_a2a_id) async def on_turn(self, turn_context: TurnContextProtocol): - # Forward all activities except EndOfConversation to the B2B connection + # Forward all activities except EndOfConversation to the A2A connection if turn_context.activity.type != ActivityTypes.end_of_conversation: - # Try to get the active B2B connection - if Bot1._active_bot_client: - await self._send_to_bot(turn_context, self._target_b2b) + # Try to get the active A2A connection + if Agent1._active_agent_client: + await self._send_to_agent(turn_context, self._target_a2a) return await super().on_turn(turn_context) @@ -70,19 +70,19 @@ async def on_message_activity(self, turn_context: TurnContextProtocol): # TODO: review activity | str interface for send_activity await turn_context.send_activity("Got it, connecting you to the agent...") - Bot1._active_bot_client = True + Agent1._active_agent_client = True - # send to bot - await self._send_to_bot(turn_context, self._target_b2b) + # send to agent + await self._send_to_agent(turn_context, self._target_a2a) return await turn_context.send_activity('Say "agent" and I\'ll patch you through') async def on_end_of_conversation_activity(self, turn_context: TurnContextProtocol): - # Clear the active B2B connection - Bot1._active_bot_client = False + # Clear the active A2A connection + Agent1._active_agent_client = False - # Show status message, text and value returned by the B2B connection + # Show status message, text and value returned by the A2A connection eoc_activity_message = f"Received {turn_context.activity.type}. Code: {turn_context.activity.code}." if turn_context.activity.text: eoc_activity_message += f" Text: {turn_context.activity.text}" @@ -92,7 +92,7 @@ async def on_end_of_conversation_activity(self, turn_context: TurnContextProtoco await turn_context.send_activity(eoc_activity_message) await turn_context.send_activity( - 'Back in the root bot. Say "agent" and I\'ll patch you through' + 'Back in the root agent. Say "agent" and I\'ll patch you through' ) async def on_members_added_activity( @@ -198,10 +198,10 @@ async def on_upload_attachment( ) -> ResourceResponse: pass - async def _send_to_bot( + async def _send_to_agent( self, turn_context: TurnContextProtocol, target_channel: ChannelInfoProtocol ): - # Create a conversation ID to communicate with the B2B connection + # Create a conversation ID to communicate with the A2A connection options = ConversationIdFactoryOptions( from_oauth_scope=turn_context.turn_state.get( ChannelAdapter.OAUTH_SCOPE_KEY @@ -218,7 +218,7 @@ async def _send_to_bot( # TODO: might need to close connection, tbd channel = self._channel_host.get_channel_from_channel_info(target_channel) - # Route activity to the B2B connection + # Route activity to the A2A connection response = await channel.post_activity( target_channel.app_id, target_channel.resource_url, @@ -258,7 +258,7 @@ async def _process_activity( reply_to_activity_id: Optional[str], activity: Activity, ): - bot_conversation_reference = ( + agent_conversation_reference = ( await self._conversation_id_factory.get_agent_conversation_reference( conversation_id ) @@ -266,9 +266,9 @@ async def _process_activity( resource_response: ResourceResponse = None - async def bot_callback_handler(turn_context: TurnContextProtocol): + async def agent_callback_handler(turn_context: TurnContextProtocol): activity.apply_conversation_reference( - bot_conversation_reference.conversation_reference + agent_conversation_reference.conversation_reference ) turn_context.activity.id = reply_to_activity_id turn_context.activity.caller_id = f"{CallerIdConstants.agent_to_agent_prefix}{claims_identity.get_outgoing_app_id()}" @@ -278,7 +278,7 @@ async def bot_callback_handler(turn_context: TurnContextProtocol): conversation_id ) - Bot1._apply_activity_to_turn_context(turn_context, activity) + Agent1._apply_activity_to_turn_context(turn_context, activity) await self.on_turn(turn_context) else: nonlocal resource_response @@ -286,13 +286,13 @@ async def bot_callback_handler(turn_context: TurnContextProtocol): # TODO: fix overload continuation_activity = ( - bot_conversation_reference.conversation_reference.get_continuation_activity() + agent_conversation_reference.conversation_reference.get_continuation_activity() ) await self._adapter.continue_conversation_with_claims( claims_identity=claims_identity, continuation_activity=continuation_activity, - callback=bot_callback_handler, - audience=bot_conversation_reference.oauth_scope, + callback=agent_callback_handler, + audience=agent_conversation_reference.oauth_scope, ) return resource_response or ResourceResponse(id=str(uuid4())) diff --git a/test_samples/agent_to_agent/agent_1/app.py b/test_samples/agent_to_agent/agent_1/app.py index 05703154..2cf9f0a9 100644 --- a/test_samples/agent_to_agent/agent_1/app.py +++ b/test_samples/agent_to_agent/agent_1/app.py @@ -22,7 +22,7 @@ ) from microsoft.agents.storage import MemoryStorage -from bot1 import Bot1 +from agent1 import Agent1 from config import DefaultConfig AUTH_PROVIDER = MsalAuth(DefaultConfig()) @@ -48,19 +48,18 @@ def get_connection(self, connection_name: str) -> AccessTokenProviderBase: CONFIG = DefaultConfig() CHANNEL_CLIENT_FACTORY = RestChannelServiceClientFactory(CONFIG, DEFAULT_CONNECTION) -BOT_CHANNEL_FACTORY = HttpAgentChannelFactory() +AGENT_CHANNEL_FACTORY = HttpAgentChannelFactory() CHANNEL_HOST = ConfigurationChannelHost( - BOT_CHANNEL_FACTORY, DEFAULT_CONNECTION, CONFIG, "HttpBotClient" + AGENT_CHANNEL_FACTORY, DEFAULT_CONNECTION, CONFIG, "HttpAgentClient" ) STORAGE = MemoryStorage() CONVERSATION_ID_FACTORY = ConversationIdFactory(STORAGE) # Create adapter. -# See https://aka.ms/about-bot-adapter to learn more about how bots work. ADAPTER = CloudAdapter(CHANNEL_CLIENT_FACTORY) -# Create the Bot -BOT = Bot1( +# Create the Agent +AGENT = Agent1( adapter=ADAPTER, channel_host=CHANNEL_HOST, conversation_id_factory=CONVERSATION_ID_FACTORY, @@ -70,12 +69,12 @@ def get_connection(self, connection_name: str) -> AccessTokenProviderBase: # Listen for incoming requests on /api/messages async def messages(req: Request) -> Response: adapter: CloudAdapter = req.app["adapter"] - return await adapter.process(req, BOT) + return await adapter.process(req, AGENT) APP = Application(middlewares=[jwt_authorization_middleware]) APP.router.add_post("/api/messages", messages) -APP.router.add_routes(channel_service_route_table(BOT, "/api/botresponse")) +APP.router.add_routes(channel_service_route_table(AGENT, "/api/botresponse")) APP["agent_configuration"] = CONFIG APP["adapter"] = ADAPTER diff --git a/test_samples/agent_to_agent/agent_1/config.py b/test_samples/agent_to_agent/agent_1/config.py index 89f6938d..31e0a5ef 100644 --- a/test_samples/agent_to_agent/agent_1/config.py +++ b/test_samples/agent_to_agent/agent_1/config.py @@ -26,7 +26,7 @@ def CHANNEL_HOST_CONFIGURATION(): app_id="", # Target agent's app_id resource_url="http://localhost:3999/api/messages", token_provider="ChannelConnection", - channel_factory="HttpBotClient", + channel_factory="HttpAgentClient", endpoint="http://localhost:3999/api/messages", ) ], diff --git a/test_samples/agent_to_agent/agent_2/bot2.py b/test_samples/agent_to_agent/agent_2/agent2.py similarity index 74% rename from test_samples/agent_to_agent/agent_2/bot2.py rename to test_samples/agent_to_agent/agent_2/agent2.py index 2ee2248e..10e0ab5b 100644 --- a/test_samples/agent_to_agent/agent_2/bot2.py +++ b/test_samples/agent_to_agent/agent_2/agent2.py @@ -6,29 +6,29 @@ ) -class Bot2(ActivityHandler): +class Agent2(ActivityHandler): async def on_members_added_activity( self, members_added: list[ChannelAccount], turn_context: TurnContext ): for member in members_added: if member.id != turn_context.activity.recipient.id: - await turn_context.send_activity("Hi, This is Bot2") + await turn_context.send_activity("Hi, This is Agent2") async def on_message_activity(self, turn_context: TurnContext): if any( stop_message in turn_context.activity.text for stop_message in ["stop", "end"] ): - await turn_context.send_activity("(Bot2) Ending conversation from Bot2") + await turn_context.send_activity("(Agent2) Ending conversation from Agent2") end_of_conversation = Activity.create_end_of_conversation_activity() end_of_conversation.code = EndOfConversationCodes.completed_successfully await turn_context.send_activity(end_of_conversation) else: await turn_context.send_activity( - f"Echo(Bot2): {turn_context.activity.text}" + f"Echo(Agent2): {turn_context.activity.text}" ) await turn_context.send_activity( - 'Echo(Bot2): Say "end" or "stop" and I\'ll end the conversation and return to the parent.' + 'Echo(Agent2): Say "end" or "stop" and I\'ll end the conversation and return to the parent.' ) async def on_end_of_conversation_activity(self, turn_context): diff --git a/test_samples/agent_to_agent/agent_2/app.py b/test_samples/agent_to_agent/agent_2/app.py index ffcd4b58..67d74c1c 100644 --- a/test_samples/agent_to_agent/agent_2/app.py +++ b/test_samples/agent_to_agent/agent_2/app.py @@ -12,7 +12,7 @@ ) from microsoft.agents.authorization.msal import MsalAuth -from bot2 import Bot2 +from agent2 import Agent2 from config import DefaultConfig AUTH_PROVIDER = MsalAuth(DefaultConfig()) @@ -35,17 +35,16 @@ def get_connection(self, connection_name: str) -> AccessTokenProviderBase: CHANNEL_CLIENT_FACTORY = RestChannelServiceClientFactory(CONFIG, DefaultConnection()) # Create adapter. -# See https://aka.ms/about-bot-adapter to learn more about how bots work. ADAPTER = CloudAdapter(CHANNEL_CLIENT_FACTORY) -# Create the Bot -BOT = Bot2() +# Create the Agent +AGENT = Agent2() # Listen for incoming requests on /api/messages async def messages(req: Request) -> Response: adapter: CloudAdapter = req.app["adapter"] - return await adapter.process(req, BOT) + return await adapter.process(req, AGENT) APP = Application(middlewares=[jwt_authorization_middleware]) diff --git a/test_samples/agent_to_agent/agent_2/config.py b/test_samples/agent_to_agent/agent_2/config.py index e3ab5f8d..d1622e53 100644 --- a/test_samples/agent_to_agent/agent_2/config.py +++ b/test_samples/agent_to_agent/agent_2/config.py @@ -2,7 +2,7 @@ class DefaultConfig(MsalAuthConfiguration): - """Bot Configuration""" + """Agent Configuration""" AUTH_TYPE = AuthTypes.client_secret TENANT_ID = "" diff --git a/test_samples/copilot_studio_client_sample/app.py b/test_samples/copilot_studio_client_sample/app.py index bfd9b750..c307f18f 100644 --- a/test_samples/copilot_studio_client_sample/app.py +++ b/test_samples/copilot_studio_client_sample/app.py @@ -10,10 +10,10 @@ from config import McsConnectionSettings load_dotenv() -connection_settings = McsConnectionSettings() +mcs_connection_settings = McsConnectionSettings() -def aquire_token(mcs_settings: McsConnectionSettings, cache_path: str) -> str: +def acquire_token(mcs_settings: McsConnectionSettings, cache_path: str) -> str: cache = get_msal_token_cache(cache_path) app = PublicClientApplication( mcs_settings.app_client_id, @@ -45,7 +45,7 @@ def aquire_token(mcs_settings: McsConnectionSettings, cache_path: str) -> str: def create_mcs_client(connection_settings: ConnectionSettings) -> CopilotClient: - token = aquire_token( + token = acquire_token( connection_settings, environ.get("TOKEN_CACHE_PATH") or path.join(path.dirname(__file__), "bin/token_cache.bin"), @@ -56,7 +56,7 @@ def create_mcs_client(connection_settings: ConnectionSettings) -> CopilotClient: loop = asyncio.get_event_loop() try: loop.run_until_complete( - ChatConsoleService(create_mcs_client(connection_settings)).start_service() + ChatConsoleService(create_mcs_client(mcs_connection_settings)).start_service() ) finally: loop.close() diff --git a/test_samples/copilot_studio_client_sample/chat_console_service.py b/test_samples/copilot_studio_client_sample/chat_console_service.py index 86a3fa9e..d7bf7653 100644 --- a/test_samples/copilot_studio_client_sample/chat_console_service.py +++ b/test_samples/copilot_studio_client_sample/chat_console_service.py @@ -8,10 +8,10 @@ def __init__(self, copilot_client: CopilotClient): self._copilot_client = copilot_client async def start_service(self): - print("bot> ") + print("agent> ") - # Attempt to connect to the copilot studio hosted bot here - # if successful, this will loop though all events that the Copilot Studio bot sends to the client setup the conversation. + # Attempt to connect to the copilot studio hosted agent here + # if successful, this will loop though all events that the Copilot Studio agent sends to the client setup the conversation. async for activity in self._copilot_client.start_conversation(): if not activity: raise Exception("ChatConsoleService.start_service: Activity is None") @@ -22,10 +22,10 @@ async def start_service(self): while True: question = input("user> ") - # Send the user input to the Copilot Studio bot and await the response. + # Send the user input to the Copilot Studio agent and await the response. # In this case we are not sending a conversation ID, as the agent is already connected by "StartConversationAsync", a conversation ID is persisted by the underlying client. - async for bot_activity in self._copilot_client.ask_question(question): - self._print_activity(bot_activity) + async for activity in self._copilot_client.ask_question(question): + self._print_activity(activity) @staticmethod def _print_activity(activity: Activity): diff --git a/test_samples/copilot_studio_client_sample/config.py b/test_samples/copilot_studio_client_sample/config.py index 07fcd1b7..ab60c2bb 100644 --- a/test_samples/copilot_studio_client_sample/config.py +++ b/test_samples/copilot_studio_client_sample/config.py @@ -28,7 +28,7 @@ def __init__( raise ValueError("Tenant ID must be provided") environment_id = environment_id or environ.get("ENVIRONMENT_ID") - agent_identifier = agent_identifier or environ.get("BOT_IDENTIFIER") + agent_identifier = agent_identifier or environ.get("AGENT_IDENTIFIER") cloud = cloud or PowerPlatformCloud[environ.get("CLOUD", "UNKNOWN")] copilot_agent_type = ( copilot_agent_type or AgentType[environ.get("COPILOT_agent_type", "PUBLISHED")] diff --git a/test_samples/copilot_studio_client_sample/msal_cache_plugin.py b/test_samples/copilot_studio_client_sample/msal_cache_plugin.py index a3180a32..95384ba5 100644 --- a/test_samples/copilot_studio_client_sample/msal_cache_plugin.py +++ b/test_samples/copilot_studio_client_sample/msal_cache_plugin.py @@ -1,5 +1,4 @@ import logging -import json from msal_extensions import ( build_encrypted_persistence, diff --git a/test_samples/echo_bot/app.py b/test_samples/echo_agent/app.py similarity index 89% rename from test_samples/echo_bot/app.py rename to test_samples/echo_agent/app.py index 7d1caa52..fb6a11b8 100644 --- a/test_samples/echo_bot/app.py +++ b/test_samples/echo_agent/app.py @@ -12,7 +12,7 @@ ) from microsoft.agents.authorization.msal import MsalAuth -from echo_bot import EchoBot +from echo_agent import EchoAgent from config import DefaultConfig AUTH_PROVIDER = MsalAuth(DefaultConfig()) @@ -35,17 +35,16 @@ def get_connection(self, connection_name: str) -> AccessTokenProviderBase: CHANNEL_CLIENT_FACTORY = RestChannelServiceClientFactory(CONFIG, DefaultConnection()) # Create adapter. -# See https://aka.ms/about-bot-adapter to learn more about how bots work. ADAPTER = CloudAdapter(CHANNEL_CLIENT_FACTORY) -# Create the Bot -BOT = EchoBot() +# Create the Agent +AGENT = EchoAgent() # Listen for incoming requests on /api/messages async def messages(req: Request) -> Response: adapter: CloudAdapter = req.app["adapter"] - return await adapter.process(req, BOT) + return await adapter.process(req, AGENT) APP = Application(middlewares=[jwt_authorization_middleware]) diff --git a/test_samples/echo_bot/config.py b/test_samples/echo_agent/config.py similarity index 89% rename from test_samples/echo_bot/config.py rename to test_samples/echo_agent/config.py index 1fe1ea0c..1da53dbf 100644 --- a/test_samples/echo_bot/config.py +++ b/test_samples/echo_agent/config.py @@ -2,7 +2,7 @@ class DefaultConfig(MsalAuthConfiguration): - """Bot Configuration""" + """Agent Configuration""" AUTH_TYPE = AuthTypes.client_secret TENANT_ID = "" diff --git a/test_samples/echo_bot/echo_bot.py b/test_samples/echo_agent/echo_agent.py similarity index 94% rename from test_samples/echo_bot/echo_bot.py rename to test_samples/echo_agent/echo_agent.py index 6b927c0e..aa68ac1d 100644 --- a/test_samples/echo_bot/echo_bot.py +++ b/test_samples/echo_agent/echo_agent.py @@ -2,7 +2,7 @@ from microsoft.agents.core.models import ChannelAccount -class EchoBot(ActivityHandler): +class EchoAgent(ActivityHandler): async def on_members_added_activity( self, members_added: list[ChannelAccount], turn_context: TurnContext ): From 8e8360533204eabb76f49a467a00f763914ec50a Mon Sep 17 00:00:00 2001 From: Axel Suarez Date: Mon, 24 Mar 2025 15:11:35 -0700 Subject: [PATCH 5/5] Renaming bot references. Formatting --- test_samples/agent_to_agent/agent_1/agent1.py | 4 +++- test_samples/copilot_studio_client_sample/config.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test_samples/agent_to_agent/agent_1/agent1.py b/test_samples/agent_to_agent/agent_1/agent1.py index 841c5781..7067b98d 100644 --- a/test_samples/agent_to_agent/agent_1/agent1.py +++ b/test_samples/agent_to_agent/agent_1/agent1.py @@ -45,7 +45,9 @@ def __init__( if not channel_host: raise ValueError("Agent1.__init__(): channel_host cannot be None") if not conversation_id_factory: - raise ValueError("Agent1.__init__(): conversation_id_factory cannot be None") + raise ValueError( + "Agent1.__init__(): conversation_id_factory cannot be None" + ) self._adapter = adapter self._channel_host = channel_host diff --git a/test_samples/copilot_studio_client_sample/config.py b/test_samples/copilot_studio_client_sample/config.py index ab60c2bb..e1d4ed71 100644 --- a/test_samples/copilot_studio_client_sample/config.py +++ b/test_samples/copilot_studio_client_sample/config.py @@ -31,7 +31,8 @@ def __init__( agent_identifier = agent_identifier or environ.get("AGENT_IDENTIFIER") cloud = cloud or PowerPlatformCloud[environ.get("CLOUD", "UNKNOWN")] copilot_agent_type = ( - copilot_agent_type or AgentType[environ.get("COPILOT_agent_type", "PUBLISHED")] + copilot_agent_type + or AgentType[environ.get("COPILOT_agent_type", "PUBLISHED")] ) custom_power_platform_cloud = custom_power_platform_cloud or environ.get( "CUSTOM_POWER_PLATFORM_CLOUD", None