microsoft-agents-hosting-core 0.4.0.dev16__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- microsoft_agents_hosting_core-0.5.0/LICENSE +21 -0
- microsoft_agents_hosting_core-0.5.0/PKG-INFO +191 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/__init__.py +2 -1
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/_oauth/__init__.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/_oauth/_flow_state.py +2 -2
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/_oauth/_oauth_flow.py +26 -23
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/activity_handler.py +20 -17
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/__init__.py +2 -1
- microsoft_agents_hosting_core-0.5.0/microsoft_agents/hosting/core/app/_routes/__init__.py +13 -0
- microsoft_agents_hosting_core-0.5.0/microsoft_agents/hosting/core/app/_routes/_route.py +89 -0
- microsoft_agents_hosting_core-0.5.0/microsoft_agents/hosting/core/app/_routes/_route_list.py +32 -0
- microsoft_agents_hosting_core-0.5.0/microsoft_agents/hosting/core/app/_routes/route_rank.py +14 -0
- microsoft_agents_hosting_core-0.5.0/microsoft_agents/hosting/core/app/_type_defs.py +15 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/agent_application.py +116 -52
- microsoft_agents_hosting_core-0.5.0/microsoft_agents/hosting/core/app/input_file.py +49 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/oauth/__init__.py +4 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/oauth/_handlers/__init__.py +5 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/oauth/_handlers/_authorization_handler.py +9 -4
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/oauth/_handlers/_user_authorization.py +6 -4
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/oauth/_handlers/agentic_user_authorization.py +14 -9
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/oauth/_sign_in_response.py +4 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/oauth/_sign_in_state.py +5 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/oauth/auth_handler.py +4 -2
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/oauth/authorization.py +43 -20
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/state/state.py +50 -6
- microsoft_agents_hosting_core-0.5.0/microsoft_agents/hosting/core/app/typing_indicator.py +79 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/authorization/access_token_provider_base.py +4 -1
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/authorization/agent_auth_configuration.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/authorization/anonymous_token_provider.py +4 -1
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/authorization/auth_types.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/authorization/connections.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/authorization/jwt_token_validator.py +9 -4
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/channel_adapter.py +9 -9
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/channel_api_handler_protocol.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/channel_service_adapter.py +65 -10
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/channel_service_client_factory_base.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/client/agent_conversation_reference.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/client/channel_factory_protocol.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/client/channel_host_protocol.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/client/channel_info_protocol.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/client/channel_protocol.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/client/channels_configuration.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/client/configuration_channel_host.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/client/conversation_constants.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/client/conversation_id_factory.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/client/conversation_id_factory_options.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/client/conversation_id_factory_protocol.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/client/http_agent_channel.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/client/http_agent_channel_factory.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/connector/client/connector_client.py +1 -4
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/connector/client/user_token_client.py +40 -43
- microsoft_agents_hosting_core-0.5.0/microsoft_agents/hosting/core/connector/user_token_base.py +120 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/connector/user_token_client_base.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/rest_channel_service_client_factory.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/state/agent_state.py +16 -20
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/storage/error_handling.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/storage/memory_storage.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/storage/storage.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/storage/store_item.py +3 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/storage/transcript_file_store.py +1 -5
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/turn_context.py +2 -1
- microsoft_agents_hosting_core-0.5.0/microsoft_agents_hosting_core.egg-info/PKG-INFO +191 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents_hosting_core.egg-info/SOURCES.txt +7 -1
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents_hosting_core.egg-info/requires.txt +1 -1
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/pyproject.toml +9 -2
- microsoft_agents_hosting_core-0.5.0/readme.md +166 -0
- microsoft_agents_hosting_core-0.4.0.dev16/PKG-INFO +0 -16
- microsoft_agents_hosting_core-0.4.0.dev16/microsoft_agents/hosting/core/app/input_file.py +0 -45
- microsoft_agents_hosting_core-0.4.0.dev16/microsoft_agents/hosting/core/app/route.py +0 -32
- microsoft_agents_hosting_core-0.4.0.dev16/microsoft_agents/hosting/core/app/typing_indicator.py +0 -55
- microsoft_agents_hosting_core-0.4.0.dev16/microsoft_agents/hosting/core/connector/user_token_base.py +0 -44
- microsoft_agents_hosting_core-0.4.0.dev16/microsoft_agents_hosting_core.egg-info/PKG-INFO +0 -16
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/_oauth/_flow_storage_client.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/agent.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/app_error.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/app_options.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/query.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/state/__init__.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/state/conversation_state.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/state/temp_state.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/app/state/turn_state.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/authorization/__init__.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/authorization/authentication_constants.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/authorization/claims_identity.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/card_factory.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/client/__init__.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/connector/__init__.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/connector/agent_sign_in_base.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/connector/attachments_base.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/connector/client/__init__.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/connector/connector_client_base.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/connector/conversations_base.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/connector/get_product_info.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/connector/teams/__init__.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/connector/teams/teams_connector_client.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/message_factory.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/middleware_set.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/state/__init__.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/state/state_property_accessor.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/state/user_state.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/storage/__init__.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/storage/_type_aliases.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/storage/transcript_info.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/storage/transcript_logger.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/storage/transcript_memory_store.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents/hosting/core/storage/transcript_store.py +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents_hosting_core.egg-info/dependency_links.txt +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/microsoft_agents_hosting_core.egg-info/top_level.txt +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/setup.cfg +0 -0
- {microsoft_agents_hosting_core-0.4.0.dev16 → microsoft_agents_hosting_core-0.5.0}/setup.py +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: microsoft-agents-hosting-core
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Core library for Microsoft Agents
|
|
5
|
+
Author: Microsoft Corporation
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/microsoft/Agents
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: microsoft-agents-activity==0.5.0
|
|
19
|
+
Requires-Dist: pyjwt>=2.10.1
|
|
20
|
+
Requires-Dist: isodate>=0.6.1
|
|
21
|
+
Requires-Dist: azure-core>=1.30.0
|
|
22
|
+
Requires-Dist: python-dotenv>=1.1.1
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
Dynamic: requires-dist
|
|
25
|
+
|
|
26
|
+
# Microsoft Agents Hosting Core
|
|
27
|
+
|
|
28
|
+
[](https://pypi.org/project/microsoft-agents-hosting-core/)
|
|
29
|
+
|
|
30
|
+
The core hosting library for Microsoft 365 Agents SDK. This library provides the fundamental building blocks for creating conversational AI agents, including activity processing, state management, authentication, and channel communication.
|
|
31
|
+
|
|
32
|
+
This is the heart of the Microsoft 365 Agents SDK - think of it as the engine that powers your conversational agents. It handles the complex orchestration of conversations, manages state across turns, and provides the infrastructure needed to build production-ready agents that work across Microsoft 365 platforms.
|
|
33
|
+
|
|
34
|
+
# What is this?
|
|
35
|
+
This library is part of the **Microsoft 365 Agents SDK for Python** - a comprehensive framework for building enterprise-grade conversational AI agents. The SDK enables developers to create intelligent agents that work across multiple platforms including Microsoft Teams, M365 Copilot, Copilot Studio, and web chat, with support for third-party integrations like Slack, Facebook Messenger, and Twilio.
|
|
36
|
+
|
|
37
|
+
## Release Notes
|
|
38
|
+
<table style="width:100%">
|
|
39
|
+
<tr>
|
|
40
|
+
<th style="width:20%">Version</th>
|
|
41
|
+
<th style="width:20%">Date</th>
|
|
42
|
+
<th style="width:60%">Release Notes</th>
|
|
43
|
+
</tr>
|
|
44
|
+
<tr>
|
|
45
|
+
<td>0.5.0</td>
|
|
46
|
+
<td>2025-10-22</td>
|
|
47
|
+
<td>
|
|
48
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md">
|
|
49
|
+
0.5.0 Release Notes
|
|
50
|
+
</a>
|
|
51
|
+
</td>
|
|
52
|
+
</tr>
|
|
53
|
+
</table>
|
|
54
|
+
|
|
55
|
+
## Packages Overview
|
|
56
|
+
|
|
57
|
+
We offer the following PyPI packages to create conversational experiences based on Agents:
|
|
58
|
+
|
|
59
|
+
| Package Name | PyPI Version | Description |
|
|
60
|
+
|--------------|-------------|-------------|
|
|
61
|
+
| `microsoft-agents-activity` | [](https://pypi.org/project/microsoft-agents-activity/) | Types and validators implementing the Activity protocol spec. |
|
|
62
|
+
| `microsoft-agents-hosting-core` | [](https://pypi.org/project/microsoft-agents-hosting-core/) | Core library for Microsoft Agents hosting. |
|
|
63
|
+
| `microsoft-agents-hosting-aiohttp` | [](https://pypi.org/project/microsoft-agents-hosting-aiohttp/) | Configures aiohttp to run the Agent. |
|
|
64
|
+
| `microsoft-agents-hosting-teams` | [](https://pypi.org/project/microsoft-agents-hosting-teams/) | Provides classes to host an Agent for Teams. |
|
|
65
|
+
| `microsoft-agents-storage-blob` | [](https://pypi.org/project/microsoft-agents-storage-blob/) | Extension to use Azure Blob as storage. |
|
|
66
|
+
| `microsoft-agents-storage-cosmos` | [](https://pypi.org/project/microsoft-agents-storage-cosmos/) | Extension to use CosmosDB as storage. |
|
|
67
|
+
| `microsoft-agents-authentication-msal` | [](https://pypi.org/project/microsoft-agents-authentication-msal/) | MSAL-based authentication for Microsoft Agents. |
|
|
68
|
+
|
|
69
|
+
Additionally we provide a Copilot Studio Client, to interact with Agents created in CopilotStudio:
|
|
70
|
+
|
|
71
|
+
| Package Name | PyPI Version | Description |
|
|
72
|
+
|--------------|-------------|-------------|
|
|
73
|
+
| `microsoft-agents-copilotstudio-client` | [](https://pypi.org/project/microsoft-agents-copilotstudio-client/) | Direct to Engine client to interact with Agents created in CopilotStudio |
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## Installation
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install microsoft-agents-hosting-core
|
|
80
|
+
```
|
|
81
|
+
## Simple Echo Agent
|
|
82
|
+
See the [Quickstart sample](https://github.com/microsoft/Agents/tree/main/samples/python/quickstart) for full working code.
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
agents_sdk_config = load_configuration_from_env(environ)
|
|
86
|
+
|
|
87
|
+
STORAGE = MemoryStorage()
|
|
88
|
+
CONNECTION_MANAGER = MsalConnectionManager(**agents_sdk_config)
|
|
89
|
+
ADAPTER = CloudAdapter(connection_manager=CONNECTION_MANAGER)
|
|
90
|
+
AUTHORIZATION = Authorization(STORAGE, CONNECTION_MANAGER, **agents_sdk_config)
|
|
91
|
+
|
|
92
|
+
AGENT_APP = AgentApplication[TurnState](
|
|
93
|
+
storage=STORAGE, adapter=ADAPTER, authorization=AUTHORIZATION, **agents_sdk_config
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
@AGENT_APP.activity("message")
|
|
97
|
+
async def on_message(context: TurnContext, state: TurnState):
|
|
98
|
+
await context.send_activity(f"You said: {context.activity.text}")
|
|
99
|
+
|
|
100
|
+
...
|
|
101
|
+
|
|
102
|
+
start_server(
|
|
103
|
+
agent_application=AGENT_APP,
|
|
104
|
+
auth_configuration=CONNECTION_MANAGER.get_default_connection_configuration(),
|
|
105
|
+
)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Core Concepts
|
|
109
|
+
|
|
110
|
+
### AgentApplication vs ActivityHandler
|
|
111
|
+
|
|
112
|
+
**AgentApplication** - Modern, fluent API for building agents:
|
|
113
|
+
- Decorator-based routing (`@agent_app.activity("message")`)
|
|
114
|
+
- Built-in state management and middleware
|
|
115
|
+
- AI-ready with authorization support
|
|
116
|
+
- Type-safe with generics
|
|
117
|
+
|
|
118
|
+
**ActivityHandler** - Traditional inheritance-based approach:
|
|
119
|
+
- Override methods for different activity types
|
|
120
|
+
- More familiar to Bot Framework developers
|
|
121
|
+
- Lower-level control over activity processing
|
|
122
|
+
|
|
123
|
+
### Route-based Message Handling
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
@AGENT_APP.message(re.compile(r"^hello$"))
|
|
127
|
+
async def on_hello(context: TurnContext, _state: TurnState):
|
|
128
|
+
await context.send_activity("Hello!")
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@AGENT_APP.activity("message")
|
|
132
|
+
async def on_message(context: TurnContext, _state: TurnState):
|
|
133
|
+
await context.send_activity(f"you said: {context.activity.text}")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Error Handling
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
@AGENT_APP.error
|
|
140
|
+
async def on_error(context: TurnContext, error: Exception):
|
|
141
|
+
# NOTE: In production environment, you should consider logging this to Azure
|
|
142
|
+
# application insights.
|
|
143
|
+
print(f"\n [on_turn_error] unhandled error: {error}", file=sys.stderr)
|
|
144
|
+
traceback.print_exc()
|
|
145
|
+
|
|
146
|
+
# Send a message to the user
|
|
147
|
+
await context.send_activity("The bot encountered an error or bug.")
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
## Key Classes Reference
|
|
152
|
+
|
|
153
|
+
### Core Classes
|
|
154
|
+
- **`AgentApplication`** - Main application class with fluent API
|
|
155
|
+
- **`ActivityHandler`** - Base class for inheritance-based agents
|
|
156
|
+
- **`TurnContext`** - Context for each conversation turn
|
|
157
|
+
- **`TurnState`** - State management across conversation turns
|
|
158
|
+
|
|
159
|
+
### State Management
|
|
160
|
+
- **`ConversationState`** - Conversation-scoped state
|
|
161
|
+
- **`UserState`** - User-scoped state across conversations
|
|
162
|
+
- **`TempState`** - Temporary state for current turn
|
|
163
|
+
- **`MemoryStorage`** - In-memory storage (development)
|
|
164
|
+
|
|
165
|
+
### Messaging
|
|
166
|
+
- **`MessageFactory`** - Create different types of messages
|
|
167
|
+
- **`CardFactory`** - Create rich card attachments
|
|
168
|
+
- **`InputFile`** - Handle file attachments
|
|
169
|
+
|
|
170
|
+
### Authorization
|
|
171
|
+
- **`Authorization`** - Authentication and authorization manager
|
|
172
|
+
- **`ClaimsIdentity`** - User identity and claims
|
|
173
|
+
|
|
174
|
+
# Quick Links
|
|
175
|
+
|
|
176
|
+
- 📦 [All SDK Packages on PyPI](https://pypi.org/search/?q=microsoft-agents)
|
|
177
|
+
- 📖 [Complete Documentation](https://aka.ms/agents)
|
|
178
|
+
- 💡 [Python Samples Repository](https://github.com/microsoft/Agents/tree/main/samples/python)
|
|
179
|
+
- 🐛 [Report Issues](https://github.com/microsoft/Agents-for-python/issues)
|
|
180
|
+
|
|
181
|
+
# Sample Applications
|
|
182
|
+
|
|
183
|
+
|Name|Description|README|
|
|
184
|
+
|----|----|----|
|
|
185
|
+
|Quickstart|Simplest agent|[Quickstart](https://github.com/microsoft/Agents/blob/main/samples/python/quickstart/README.md)|
|
|
186
|
+
|Auto Sign In|Simple OAuth agent using Graph and GitHub|[auto-signin](https://github.com/microsoft/Agents/blob/main/samples/python/auto-signin/README.md)|
|
|
187
|
+
|OBO Authorization|OBO flow to access a Copilot Studio Agent|[obo-authorization](https://github.com/microsoft/Agents/blob/main/samples/python/obo-authorization/README.md)|
|
|
188
|
+
|Semantic Kernel Integration|A weather agent built with Semantic Kernel|[semantic-kernel-multiturn](https://github.com/microsoft/Agents/blob/main/samples/python/semantic-kernel-multiturn/README.md)|
|
|
189
|
+
|Streaming Agent|Streams OpenAI responses|[azure-ai-streaming](https://github.com/microsoft/Agents/blob/main/samples/python/azureai-streaming/README.md)|
|
|
190
|
+
|Copilot Studio Client|Console app to consume a Copilot Studio Agent|[copilotstudio-client](https://github.com/microsoft/Agents/blob/main/samples/python/copilotstudio-client/README.md)|
|
|
191
|
+
|Cards Agent|Agent that uses rich cards to enhance conversation design |[cards](https://github.com/microsoft/Agents/blob/main/samples/python/cards/README.md)|
|
|
@@ -11,12 +11,13 @@ from .rest_channel_service_client_factory import RestChannelServiceClientFactory
|
|
|
11
11
|
from .turn_context import TurnContext
|
|
12
12
|
|
|
13
13
|
# Application Style
|
|
14
|
+
from .app._type_defs import RouteHandler, RouteSelector, StateT
|
|
14
15
|
from .app.agent_application import AgentApplication
|
|
15
16
|
from .app.app_error import ApplicationError
|
|
16
17
|
from .app.app_options import ApplicationOptions
|
|
17
18
|
from .app.input_file import InputFile, InputFileDownloader
|
|
18
19
|
from .app.query import Query
|
|
19
|
-
from .app.
|
|
20
|
+
from .app._routes import _Route, _RouteList, RouteRank
|
|
20
21
|
from .app.typing_indicator import TypingIndicator
|
|
21
22
|
|
|
22
23
|
# App Auth
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
|
|
1
4
|
from ._flow_state import _FlowState, _FlowStateTag, _FlowErrorTag
|
|
2
5
|
from ._flow_storage_client import _FlowStorageClient
|
|
3
6
|
from ._oauth_flow import _OAuthFlow, _FlowResponse
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
|
|
6
|
-
from datetime import datetime
|
|
6
|
+
from datetime import datetime, timezone
|
|
7
7
|
from enum import Enum
|
|
8
8
|
from typing import Optional
|
|
9
9
|
|
|
@@ -60,7 +60,7 @@ class _FlowState(BaseModel, StoreItem):
|
|
|
60
60
|
return _FlowState.model_validate(json_data)
|
|
61
61
|
|
|
62
62
|
def is_expired(self) -> bool:
|
|
63
|
-
return datetime.now().timestamp() >= self.expiration
|
|
63
|
+
return datetime.now(timezone.utc).timestamp() >= self.expiration
|
|
64
64
|
|
|
65
65
|
def reached_max_attempts(self) -> bool:
|
|
66
66
|
return self.attempts_remaining <= 0
|
|
@@ -6,7 +6,7 @@ from __future__ import annotations
|
|
|
6
6
|
import logging
|
|
7
7
|
|
|
8
8
|
from pydantic import BaseModel
|
|
9
|
-
from datetime import datetime
|
|
9
|
+
from datetime import datetime, timezone
|
|
10
10
|
from typing import Optional
|
|
11
11
|
|
|
12
12
|
from microsoft_agents.activity import (
|
|
@@ -30,7 +30,6 @@ class _FlowResponse(BaseModel):
|
|
|
30
30
|
flow_error_tag: _FlowErrorTag = _FlowErrorTag.NONE
|
|
31
31
|
token_response: Optional[TokenResponse] = None
|
|
32
32
|
sign_in_resource: Optional[SignInResource] = None
|
|
33
|
-
continuation_activity: Optional[Activity] = None
|
|
34
33
|
|
|
35
34
|
|
|
36
35
|
class _OAuthFlow:
|
|
@@ -112,7 +111,7 @@ class _OAuthFlow:
|
|
|
112
111
|
"""Get the user token based on the context.
|
|
113
112
|
|
|
114
113
|
Args:
|
|
115
|
-
magic_code (str,
|
|
114
|
+
magic_code (str, Optional): Defaults to None. The magic code for user authentication.
|
|
116
115
|
|
|
117
116
|
Returns:
|
|
118
117
|
TokenResponse
|
|
@@ -137,7 +136,7 @@ class _OAuthFlow:
|
|
|
137
136
|
if token_response:
|
|
138
137
|
logger.info("User token obtained successfully: %s", token_response)
|
|
139
138
|
self._flow_state.expiration = (
|
|
140
|
-
datetime.now().timestamp() + self._default_flow_duration
|
|
139
|
+
datetime.now(timezone.utc).timestamp() + self._default_flow_duration
|
|
141
140
|
)
|
|
142
141
|
self._flow_state.tag = _FlowStateTag.COMPLETE
|
|
143
142
|
|
|
@@ -183,20 +182,8 @@ class _OAuthFlow:
|
|
|
183
182
|
Notes:
|
|
184
183
|
The flow state is reset if a token is not obtained from cache.
|
|
185
184
|
"""
|
|
186
|
-
token_response = await self.get_user_token()
|
|
187
|
-
if token_response:
|
|
188
|
-
return _FlowResponse(
|
|
189
|
-
flow_state=self._flow_state, token_response=token_response
|
|
190
|
-
)
|
|
191
185
|
|
|
192
186
|
logger.debug("Starting new OAuth flow")
|
|
193
|
-
self._flow_state.tag = _FlowStateTag.BEGIN
|
|
194
|
-
self._flow_state.expiration = (
|
|
195
|
-
datetime.now().timestamp() + self._default_flow_duration
|
|
196
|
-
)
|
|
197
|
-
|
|
198
|
-
self._flow_state.attempts_remaining = self._max_attempts
|
|
199
|
-
self._flow_state.continuation_activity = activity.model_copy()
|
|
200
187
|
|
|
201
188
|
token_exchange_state = TokenExchangeState(
|
|
202
189
|
connection_name=self._abs_oauth_connection_name,
|
|
@@ -205,16 +192,33 @@ class _OAuthFlow:
|
|
|
205
192
|
ms_app_id=self._ms_app_id,
|
|
206
193
|
)
|
|
207
194
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
195
|
+
res = await self._user_token_client.user_token._get_token_or_sign_in_resource(
|
|
196
|
+
activity.from_property.id,
|
|
197
|
+
self._abs_oauth_connection_name,
|
|
198
|
+
activity.channel_id,
|
|
199
|
+
token_exchange_state.get_encoded_state(),
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
if res.token_response:
|
|
203
|
+
logger.info("Skipping flow, user token obtained.")
|
|
204
|
+
self._flow_state.tag = _FlowStateTag.COMPLETE
|
|
205
|
+
self._flow_state.expiration = (
|
|
206
|
+
datetime.now(timezone.utc).timestamp() + self._default_flow_duration
|
|
207
|
+
)
|
|
208
|
+
return _FlowResponse(
|
|
209
|
+
flow_state=self._flow_state, token_response=res.token_response
|
|
211
210
|
)
|
|
211
|
+
|
|
212
|
+
self._flow_state.tag = _FlowStateTag.BEGIN
|
|
213
|
+
self._flow_state.expiration = (
|
|
214
|
+
datetime.now(timezone.utc).timestamp() + self._default_flow_duration
|
|
212
215
|
)
|
|
216
|
+
self._flow_state.attempts_remaining = self._max_attempts
|
|
213
217
|
|
|
214
|
-
logger.debug("Sign-in resource obtained successfully: %s", sign_in_resource)
|
|
218
|
+
logger.debug("Sign-in resource obtained successfully: %s", res.sign_in_resource)
|
|
215
219
|
|
|
216
220
|
return _FlowResponse(
|
|
217
|
-
flow_state=self._flow_state, sign_in_resource=sign_in_resource
|
|
221
|
+
flow_state=self._flow_state, sign_in_resource=res.sign_in_resource
|
|
218
222
|
)
|
|
219
223
|
|
|
220
224
|
async def _continue_from_message(
|
|
@@ -299,7 +303,7 @@ class _OAuthFlow:
|
|
|
299
303
|
else:
|
|
300
304
|
self._flow_state.tag = _FlowStateTag.COMPLETE
|
|
301
305
|
self._flow_state.expiration = (
|
|
302
|
-
datetime.now().timestamp() + self._default_flow_duration
|
|
306
|
+
datetime.now(timezone.utc).timestamp() + self._default_flow_duration
|
|
303
307
|
)
|
|
304
308
|
logger.debug(
|
|
305
309
|
"OAuth flow completed successfully, got TokenResponse: %s",
|
|
@@ -310,7 +314,6 @@ class _OAuthFlow:
|
|
|
310
314
|
flow_state=self._flow_state.model_copy(),
|
|
311
315
|
flow_error_tag=flow_error_tag,
|
|
312
316
|
token_response=token_response,
|
|
313
|
-
continuation_activity=self._flow_state.continuation_activity,
|
|
314
317
|
)
|
|
315
318
|
|
|
316
319
|
async def begin_or_continue_flow(self, activity: Activity) -> _FlowResponse:
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
2
|
# Licensed under the MIT License.
|
|
3
|
+
|
|
3
4
|
from __future__ import annotations
|
|
4
5
|
from http import HTTPStatus
|
|
5
6
|
from pydantic import BaseModel
|
|
@@ -37,7 +38,7 @@ class ActivityHandler(Agent):
|
|
|
37
38
|
in order to process an inbound :class:`microsoft_agents.activity.Activity`.
|
|
38
39
|
|
|
39
40
|
:param turn_context: The context object for this turn
|
|
40
|
-
:type turn_context: :class:`microsoft_agents.
|
|
41
|
+
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
|
|
41
42
|
|
|
42
43
|
:returns: A task that represents the work queued to execute
|
|
43
44
|
|
|
@@ -142,7 +143,7 @@ class ActivityHandler(Agent):
|
|
|
142
143
|
:meth:`on_turn()` is used.
|
|
143
144
|
|
|
144
145
|
:param turn_context: The context object for this turn
|
|
145
|
-
:type turn_context: :class:`microsoft_agents.
|
|
146
|
+
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
|
|
146
147
|
:returns: A task that represents the work queued to execute
|
|
147
148
|
|
|
148
149
|
.. remarks::
|
|
@@ -175,7 +176,7 @@ class ActivityHandler(Agent):
|
|
|
175
176
|
|
|
176
177
|
:param members_added: A list of all the members added to the conversation, as described by the
|
|
177
178
|
conversation update activity
|
|
178
|
-
:type members_added: list[ChannelAccount]
|
|
179
|
+
:type members_added: list[:class:`microsoft_agents.activity.ChannelAccount`]
|
|
179
180
|
:param turn_context: The context object for this turn
|
|
180
181
|
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
|
|
181
182
|
:returns: A task that represents the work queued to execute
|
|
@@ -194,9 +195,9 @@ class ActivityHandler(Agent):
|
|
|
194
195
|
Override this method in a derived class to provide logic for when members other than the agent leave
|
|
195
196
|
the conversation. You can add your agent's good-bye logic.
|
|
196
197
|
|
|
197
|
-
:param
|
|
198
|
+
:param members_removed: A list of all the members removed from the conversation, as described by the
|
|
198
199
|
conversation update activity
|
|
199
|
-
:type
|
|
200
|
+
:type members_removed: list[:class:`microsoft_agents.activity.ChannelAccount`]
|
|
200
201
|
:param turn_context: The context object for this turn
|
|
201
202
|
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
|
|
202
203
|
:returns: A task that represents the work queued to execute
|
|
@@ -215,7 +216,7 @@ class ActivityHandler(Agent):
|
|
|
215
216
|
:meth:`on_turn()` is used.
|
|
216
217
|
|
|
217
218
|
:param turn_context: The context object for this turn
|
|
218
|
-
:type turn_context: :class:`microsoft_agents.
|
|
219
|
+
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
|
|
219
220
|
|
|
220
221
|
:returns: A task that represents the work queued to execute
|
|
221
222
|
|
|
@@ -259,7 +260,7 @@ class ActivityHandler(Agent):
|
|
|
259
260
|
are added to the conversation.
|
|
260
261
|
|
|
261
262
|
:param message_reactions: The list of reactions added
|
|
262
|
-
:type message_reactions: list[MessageReaction]
|
|
263
|
+
:type message_reactions: list[:class:`microsoft_agents.activity.MessageReaction`]
|
|
263
264
|
:param turn_context: The context object for this turn
|
|
264
265
|
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
|
|
265
266
|
:returns: A task that represents the work queued to execute
|
|
@@ -284,7 +285,7 @@ class ActivityHandler(Agent):
|
|
|
284
285
|
are removed from the conversation.
|
|
285
286
|
|
|
286
287
|
:param message_reactions: The list of reactions removed
|
|
287
|
-
:type message_reactions: list[MessageReaction]
|
|
288
|
+
:type message_reactions: list[:class:`microsoft_agents.activity.MessageReaction`]
|
|
288
289
|
:param turn_context: The context object for this turn
|
|
289
290
|
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
|
|
290
291
|
|
|
@@ -381,7 +382,7 @@ class ActivityHandler(Agent):
|
|
|
381
382
|
ActivityTypes.typing activities, such as the conversational logic.
|
|
382
383
|
|
|
383
384
|
:param turn_context: The context object for this turn
|
|
384
|
-
:type turn_context: :class:`microsoft_agents.
|
|
385
|
+
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
|
|
385
386
|
:returns: A task that represents the work queued to execute
|
|
386
387
|
"""
|
|
387
388
|
return
|
|
@@ -394,7 +395,7 @@ class ActivityHandler(Agent):
|
|
|
394
395
|
ActivityTypes.InstallationUpdate activities.
|
|
395
396
|
|
|
396
397
|
:param turn_context: The context object for this turn
|
|
397
|
-
:type turn_context: :class:`microsoft_agents.
|
|
398
|
+
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
|
|
398
399
|
:returns: A task that represents the work queued to execute
|
|
399
400
|
"""
|
|
400
401
|
if turn_context.activity.action in ("add", "add-upgrade"):
|
|
@@ -411,7 +412,7 @@ class ActivityHandler(Agent):
|
|
|
411
412
|
ActivityTypes.InstallationUpdate activities with 'action' set to 'add'.
|
|
412
413
|
|
|
413
414
|
:param turn_context: The context object for this turn
|
|
414
|
-
:type turn_context: :class:`microsoft_agents.
|
|
415
|
+
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
|
|
415
416
|
:returns: A task that represents the work queued to execute
|
|
416
417
|
"""
|
|
417
418
|
return
|
|
@@ -424,7 +425,7 @@ class ActivityHandler(Agent):
|
|
|
424
425
|
ActivityTypes.InstallationUpdate activities with 'action' set to 'remove'.
|
|
425
426
|
|
|
426
427
|
:param turn_context: The context object for this turn
|
|
427
|
-
:type turn_context: :class:`microsoft_agents.
|
|
428
|
+
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
|
|
428
429
|
:returns: A task that represents the work queued to execute
|
|
429
430
|
"""
|
|
430
431
|
return
|
|
@@ -438,7 +439,7 @@ class ActivityHandler(Agent):
|
|
|
438
439
|
If overridden, this method could potentially respond to any of the other activity types.
|
|
439
440
|
|
|
440
441
|
:param turn_context: The context object for this turn
|
|
441
|
-
:type turn_context: :class:`microsoft_agents.
|
|
442
|
+
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
|
|
442
443
|
|
|
443
444
|
:returns: A task that represents the work queued to execute
|
|
444
445
|
|
|
@@ -455,9 +456,10 @@ class ActivityHandler(Agent):
|
|
|
455
456
|
Registers an activity event handler for the _invoke_ event, emitted for every incoming event activity.
|
|
456
457
|
|
|
457
458
|
:param turn_context: The context object for this turn
|
|
458
|
-
:type turn_context: :class:`microsoft_agents.
|
|
459
|
+
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
|
|
459
460
|
|
|
460
461
|
:returns: A task that represents the work queued to execute
|
|
462
|
+
:rtype: Optional[:class:`microsoft_agents.activity.InvokeResponse`]
|
|
461
463
|
"""
|
|
462
464
|
try:
|
|
463
465
|
if (
|
|
@@ -491,7 +493,7 @@ class ActivityHandler(Agent):
|
|
|
491
493
|
By default, this method does nothing.
|
|
492
494
|
|
|
493
495
|
:param turn_context: The context object for this turn
|
|
494
|
-
:type turn_context: :class:`microsoft_agents.
|
|
496
|
+
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
|
|
495
497
|
|
|
496
498
|
:returns: A task that represents the work queued to execute
|
|
497
499
|
"""
|
|
@@ -507,10 +509,11 @@ class ActivityHandler(Agent):
|
|
|
507
509
|
calls this method.
|
|
508
510
|
|
|
509
511
|
:param turn_context: A context object for this turn.
|
|
510
|
-
:type turn_context: :class:`microsoft_agents.
|
|
512
|
+
:type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
|
|
511
513
|
:param invoke_value: A string-typed object from the incoming activity's value.
|
|
512
|
-
:type invoke_value: :class:`microsoft_agents.activity.
|
|
514
|
+
:type invoke_value: :class:`microsoft_agents.activity.AdaptiveCardInvokeValue`
|
|
513
515
|
:return: The HealthCheckResponse object
|
|
516
|
+
:rtype: :class:`microsoft_agents.activity.AdaptiveCardInvokeResponse`
|
|
514
517
|
"""
|
|
515
518
|
raise _InvokeResponseException(HTTPStatus.NOT_IMPLEMENTED)
|
|
516
519
|
|
|
@@ -10,8 +10,9 @@ from .app_error import ApplicationError
|
|
|
10
10
|
from .app_options import ApplicationOptions
|
|
11
11
|
from .input_file import InputFile, InputFileDownloader
|
|
12
12
|
from .query import Query
|
|
13
|
-
from .
|
|
13
|
+
from ._routes import _RouteList, _Route, RouteRank
|
|
14
14
|
from .typing_indicator import TypingIndicator
|
|
15
|
+
from ._type_defs import RouteHandler, RouteSelector, StateT
|
|
15
16
|
|
|
16
17
|
# Auth
|
|
17
18
|
from .oauth import (
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
from ._route_list import _RouteList
|
|
5
|
+
from ._route import _Route, _agentic_selector
|
|
6
|
+
from .route_rank import RouteRank
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"_RouteList",
|
|
10
|
+
"_Route",
|
|
11
|
+
"RouteRank",
|
|
12
|
+
"_agentic_selector",
|
|
13
|
+
]
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from typing import Generic, Optional, TypeVar
|
|
7
|
+
|
|
8
|
+
from ...turn_context import TurnContext
|
|
9
|
+
from .._type_defs import RouteHandler, RouteSelector
|
|
10
|
+
from ..state.turn_state import TurnState
|
|
11
|
+
from .route_rank import RouteRank
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _agentic_selector(selector: RouteSelector) -> RouteSelector:
|
|
15
|
+
def wrapped_selector(context: TurnContext) -> bool:
|
|
16
|
+
return context.activity.is_agentic_request() and selector(context)
|
|
17
|
+
|
|
18
|
+
return wrapped_selector
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
StateT = TypeVar("StateT", bound=TurnState)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class _Route(Generic[StateT]):
|
|
25
|
+
selector: RouteSelector
|
|
26
|
+
handler: RouteHandler[StateT]
|
|
27
|
+
_is_invoke: bool
|
|
28
|
+
_rank: int
|
|
29
|
+
auth_handlers: list[str]
|
|
30
|
+
_is_agentic: bool
|
|
31
|
+
|
|
32
|
+
def __init__(
|
|
33
|
+
self,
|
|
34
|
+
selector: RouteSelector,
|
|
35
|
+
handler: RouteHandler[StateT],
|
|
36
|
+
is_invoke: bool = False,
|
|
37
|
+
rank: int = RouteRank.DEFAULT,
|
|
38
|
+
auth_handlers: Optional[list[str]] = None,
|
|
39
|
+
is_agentic: bool = False,
|
|
40
|
+
**kwargs,
|
|
41
|
+
) -> None:
|
|
42
|
+
|
|
43
|
+
if rank < 0 or rank > RouteRank.LAST:
|
|
44
|
+
raise ValueError(
|
|
45
|
+
"Route rank must be between 0 and RouteRank.LAST (inclusive)"
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
self.selector = selector
|
|
49
|
+
self.handler = handler
|
|
50
|
+
self._is_invoke = is_invoke
|
|
51
|
+
self._rank = int(rank) # conversion from RouteRank IntEnum if necessary
|
|
52
|
+
self._is_agentic = is_agentic
|
|
53
|
+
self.auth_handlers = auth_handlers or []
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def is_invoke(self) -> bool:
|
|
57
|
+
return self._is_invoke
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def rank(self) -> int:
|
|
61
|
+
return self._rank
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def is_agentic(self) -> bool:
|
|
65
|
+
return self._is_agentic
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def priority(self) -> list[int]:
|
|
69
|
+
"""Lower "values" indicate higher priority.
|
|
70
|
+
|
|
71
|
+
Priority is determined by:
|
|
72
|
+
1. Whether the route is for an invoke activity (0) or not (1).
|
|
73
|
+
2. Whether the route is agentic (0) or not (1).
|
|
74
|
+
3. The rank of the route (lower numbers indicate higher priority).
|
|
75
|
+
|
|
76
|
+
In that order. If both are invokes, the agentic one has higher priority.
|
|
77
|
+
If both are agentic and invokes, then the rank determines priority.
|
|
78
|
+
|
|
79
|
+
priority is represented as a list of three integers for easy lexicographic comparison.
|
|
80
|
+
"""
|
|
81
|
+
return [
|
|
82
|
+
0 if self._is_invoke else 1,
|
|
83
|
+
0 if self._is_agentic else 1,
|
|
84
|
+
self._rank,
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
def __lt__(self, other: _Route) -> bool:
|
|
88
|
+
# built-in list ordering is a lexicographic comparison in Python
|
|
89
|
+
return self.priority < other.priority
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import heapq
|
|
7
|
+
from typing import Generic, TypeVar
|
|
8
|
+
|
|
9
|
+
from ..state.turn_state import TurnState
|
|
10
|
+
from ._route import _Route
|
|
11
|
+
|
|
12
|
+
StateT = TypeVar("StateT", bound=TurnState)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class _RouteList(Generic[StateT]):
|
|
16
|
+
_routes: list[_Route[StateT]]
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
) -> None:
|
|
21
|
+
# a min-heap where lower "values" indicate higher priority
|
|
22
|
+
self._routes = []
|
|
23
|
+
|
|
24
|
+
def add_route(self, route: _Route[StateT]) -> None:
|
|
25
|
+
"""Adds a route to the list."""
|
|
26
|
+
heapq.heappush(self._routes, route)
|
|
27
|
+
|
|
28
|
+
def __iter__(self):
|
|
29
|
+
# sorted will return a new list, leaving the heap intact
|
|
30
|
+
# returning an iterator over the previous list would expose
|
|
31
|
+
# internal details
|
|
32
|
+
return iter(sorted(self._routes))
|