microsoft-agents-hosting-core 0.5.0.dev5__py3-none-any.whl → 0.5.0.dev10__py3-none-any.whl

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.
@@ -71,7 +71,7 @@ class FileTranscriptStore(TranscriptLogger):
71
71
  def _write() -> None:
72
72
  # Normalize to a dict to ensure json serializable content.
73
73
  if not activity.timestamp:
74
- activity.timestamp = _utc_iso_now()
74
+ activity.timestamp = datetime.now(timezone.utc)
75
75
 
76
76
  with open(file_path, "a", encoding="utf-8", newline="\n") as f:
77
77
  f.write(activity.model_dump_json(exclude_none=True, exclude_unset=True))
@@ -261,7 +261,3 @@ def _to_plain_dict(activity: Activity) -> Dict[str, Any]:
261
261
  "conversation": {"id": conversation_id},
262
262
  "text": getattr(activity, "text", None),
263
263
  }
264
-
265
-
266
- def _utc_iso_now() -> str:
267
- return datetime.now(timezone.utc).isoformat()
@@ -18,6 +18,7 @@ from microsoft_agents.activity import (
18
18
  ResourceResponse,
19
19
  DeliveryModes,
20
20
  )
21
+ from microsoft_agents.activity.entity.entity_types import EntityTypes
21
22
  from microsoft_agents.hosting.core.authorization.claims_identity import ClaimsIdentity
22
23
 
23
24
 
@@ -428,7 +429,7 @@ class TurnContext(TurnContextProtocol):
428
429
  result: list[Mention] = []
429
430
  if activity.entities is not None:
430
431
  for entity in activity.entities:
431
- if entity.type.lower() == "mention":
432
+ if entity.type.lower() == EntityTypes.MENTION:
432
433
  result.append(entity)
433
434
 
434
435
  return result
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.4
2
+ Name: microsoft-agents-hosting-core
3
+ Version: 0.5.0.dev10
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: Operating System :: OS Independent
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: microsoft-agents-activity==0.5.0.dev10
14
+ Requires-Dist: pyjwt>=2.10.1
15
+ Requires-Dist: isodate>=0.6.1
16
+ Requires-Dist: azure-core>=1.30.0
17
+ Requires-Dist: python-dotenv>=1.1.1
18
+ Dynamic: license-file
19
+ Dynamic: requires-dist
20
+
21
+ # Microsoft Agents Hosting Core
22
+
23
+ [![PyPI version](https://img.shields.io/pypi/v/microsoft-agents-hosting-core)](https://pypi.org/project/microsoft-agents-hosting-core/)
24
+
25
+ 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.
26
+
27
+ 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.
28
+
29
+ # What is this?
30
+ 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.
31
+
32
+ ## Packages Overview
33
+
34
+ We offer the following PyPI packages to create conversational experiences based on Agents:
35
+
36
+ | Package Name | PyPI Version | Description |
37
+ |--------------|-------------|-------------|
38
+ | `microsoft-agents-activity` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-activity)](https://pypi.org/project/microsoft-agents-activity/) | Types and validators implementing the Activity protocol spec. |
39
+ | `microsoft-agents-hosting-core` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-hosting-core)](https://pypi.org/project/microsoft-agents-hosting-core/) | Core library for Microsoft Agents hosting. |
40
+ | `microsoft-agents-hosting-aiohttp` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-hosting-aiohttp)](https://pypi.org/project/microsoft-agents-hosting-aiohttp/) | Configures aiohttp to run the Agent. |
41
+ | `microsoft-agents-hosting-teams` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-hosting-teams)](https://pypi.org/project/microsoft-agents-hosting-teams/) | Provides classes to host an Agent for Teams. |
42
+ | `microsoft-agents-storage-blob` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-storage-blob)](https://pypi.org/project/microsoft-agents-storage-blob/) | Extension to use Azure Blob as storage. |
43
+ | `microsoft-agents-storage-cosmos` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-storage-cosmos)](https://pypi.org/project/microsoft-agents-storage-cosmos/) | Extension to use CosmosDB as storage. |
44
+ | `microsoft-agents-authentication-msal` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-authentication-msal)](https://pypi.org/project/microsoft-agents-authentication-msal/) | MSAL-based authentication for Microsoft Agents. |
45
+
46
+ Additionally we provide a Copilot Studio Client, to interact with Agents created in CopilotStudio:
47
+
48
+ | Package Name | PyPI Version | Description |
49
+ |--------------|-------------|-------------|
50
+ | `microsoft-agents-copilotstudio-client` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-copilotstudio-client)](https://pypi.org/project/microsoft-agents-copilotstudio-client/) | Direct to Engine client to interact with Agents created in CopilotStudio |
51
+
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ pip install microsoft-agents-hosting-core
57
+ ```
58
+ ## Simple Echo Agent
59
+ See the [Quickstart sample](https://github.com/microsoft/Agents/tree/main/samples/python/quickstart) for full working code.
60
+
61
+ ```python
62
+ agents_sdk_config = load_configuration_from_env(environ)
63
+
64
+ STORAGE = MemoryStorage()
65
+ CONNECTION_MANAGER = MsalConnectionManager(**agents_sdk_config)
66
+ ADAPTER = CloudAdapter(connection_manager=CONNECTION_MANAGER)
67
+ AUTHORIZATION = Authorization(STORAGE, CONNECTION_MANAGER, **agents_sdk_config)
68
+
69
+ AGENT_APP = AgentApplication[TurnState](
70
+ storage=STORAGE, adapter=ADAPTER, authorization=AUTHORIZATION, **agents_sdk_config
71
+ )
72
+
73
+ @AGENT_APP.activity("message")
74
+ async def on_message(context: TurnContext, state: TurnState):
75
+ await context.send_activity(f"You said: {context.activity.text}")
76
+
77
+ ...
78
+
79
+ start_server(
80
+ agent_application=AGENT_APP,
81
+ auth_configuration=CONNECTION_MANAGER.get_default_connection_configuration(),
82
+ )
83
+ ```
84
+
85
+ ## Core Concepts
86
+
87
+ ### AgentApplication vs ActivityHandler
88
+
89
+ **AgentApplication** - Modern, fluent API for building agents:
90
+ - Decorator-based routing (`@agent_app.activity("message")`)
91
+ - Built-in state management and middleware
92
+ - AI-ready with authorization support
93
+ - Type-safe with generics
94
+
95
+ **ActivityHandler** - Traditional inheritance-based approach:
96
+ - Override methods for different activity types
97
+ - More familiar to Bot Framework developers
98
+ - Lower-level control over activity processing
99
+
100
+ ### Route-based Message Handling
101
+
102
+ ```python
103
+ @AGENT_APP.message(re.compile(r"^hello$"))
104
+ async def on_hello(context: TurnContext, _state: TurnState):
105
+ await context.send_activity("Hello!")
106
+
107
+
108
+ @AGENT_APP.activity("message")
109
+ async def on_message(context: TurnContext, _state: TurnState):
110
+ await context.send_activity(f"you said: {context.activity.text}")
111
+ ```
112
+
113
+ ### Error Handling
114
+
115
+ ```python
116
+ @AGENT_APP.error
117
+ async def on_error(context: TurnContext, error: Exception):
118
+ # NOTE: In production environment, you should consider logging this to Azure
119
+ # application insights.
120
+ print(f"\n [on_turn_error] unhandled error: {error}", file=sys.stderr)
121
+ traceback.print_exc()
122
+
123
+ # Send a message to the user
124
+ await context.send_activity("The bot encountered an error or bug.")
125
+ ```
126
+
127
+
128
+ ## Key Classes Reference
129
+
130
+ ### Core Classes
131
+ - **`AgentApplication`** - Main application class with fluent API
132
+ - **`ActivityHandler`** - Base class for inheritance-based agents
133
+ - **`TurnContext`** - Context for each conversation turn
134
+ - **`TurnState`** - State management across conversation turns
135
+
136
+ ### State Management
137
+ - **`ConversationState`** - Conversation-scoped state
138
+ - **`UserState`** - User-scoped state across conversations
139
+ - **`TempState`** - Temporary state for current turn
140
+ - **`MemoryStorage`** - In-memory storage (development)
141
+
142
+ ### Messaging
143
+ - **`MessageFactory`** - Create different types of messages
144
+ - **`CardFactory`** - Create rich card attachments
145
+ - **`InputFile`** - Handle file attachments
146
+
147
+ ### Authorization
148
+ - **`Authorization`** - Authentication and authorization manager
149
+ - **`ClaimsIdentity`** - User identity and claims
150
+
151
+ # Quick Links
152
+
153
+ - 📦 [All SDK Packages on PyPI](https://pypi.org/search/?q=microsoft-agents)
154
+ - 📖 [Complete Documentation](https://aka.ms/agents)
155
+ - 💡 [Python Samples Repository](https://github.com/microsoft/Agents/tree/main/samples/python)
156
+ - 🐛 [Report Issues](https://github.com/microsoft/Agents-for-python/issues)
157
+
158
+ # Sample Applications
159
+
160
+ |Name|Description|README|
161
+ |----|----|----|
162
+ |Quickstart|Simplest agent|[Quickstart](https://github.com/microsoft/Agents/blob/main/samples/python/quickstart/README.md)|
163
+ |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)|
164
+ |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)|
165
+ |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)|
166
+ |Streaming Agent|Streams OpenAI responses|[azure-ai-streaming](https://github.com/microsoft/Agents/blob/main/samples/python/azureai-streaming/README.md)|
167
+ |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)|
168
+ |Cards Agent|Agent that uses rich cards to enhance conversation design |[cards](https://github.com/microsoft/Agents/blob/main/samples/python/cards/README.md)|
@@ -9,7 +9,7 @@ microsoft_agents/hosting/core/channel_service_client_factory_base.py,sha256=ArMA
9
9
  microsoft_agents/hosting/core/message_factory.py,sha256=F9QJBF4yBupHXxOW984ZzZomVEG57t9IUnTHwub-lX0,7822
10
10
  microsoft_agents/hosting/core/middleware_set.py,sha256=TBsBs4KwAfKyHlQTlG4bl1y5UjkBzeMDs5w7LNB-Bi4,2585
11
11
  microsoft_agents/hosting/core/rest_channel_service_client_factory.py,sha256=afLeWgLz9N417Egc_6LBfnYNiuuwTEcSBefeOvTQ_H4,6217
12
- microsoft_agents/hosting/core/turn_context.py,sha256=df7TB1uXurgoAk338OF6taVfVgS58v662A9D9-GLP64,14794
12
+ microsoft_agents/hosting/core/turn_context.py,sha256=muA8S4R6Xxja5it7DiFqr5J5zmttwDN-Mj5_SDdxZ4A,14874
13
13
  microsoft_agents/hosting/core/_oauth/__init__.py,sha256=sU1HsIXbETRYwnudtFc6GrNbM6C3oYjmruqXc6kIAFw,405
14
14
  microsoft_agents/hosting/core/_oauth/_flow_state.py,sha256=BQbXn0a3Fw4aozS-WSjL0Y7vEdb4eua1ZitSr0qZ6bE,2207
15
15
  microsoft_agents/hosting/core/_oauth/_flow_storage_client.py,sha256=1MLD8m_qw0jSLqsyNaaWHm7aFkdjNWOE7xhV1rfbU64,3413
@@ -86,13 +86,13 @@ microsoft_agents/hosting/core/storage/error_handling.py,sha256=kTMQ68GxL4GgVKpo3
86
86
  microsoft_agents/hosting/core/storage/memory_storage.py,sha256=5AZ2QQ3TagVCHCKp0GEVAIuDswDGHgbgnUZgS9YbPAI,2448
87
87
  microsoft_agents/hosting/core/storage/storage.py,sha256=bt93jItMQKC9NJlcmxPtcE67MvnibolcFwvV1LFwliI,3322
88
88
  microsoft_agents/hosting/core/storage/store_item.py,sha256=rjtzB5yufsKuY1O5PjCqWHjjmO6UiORwkzpwbsaxp_4,371
89
- microsoft_agents/hosting/core/storage/transcript_file_store.py,sha256=7-ngOW5AuVPEHiAZJeZe_a5Qn4lQxlAiexjAwPiOJJU,10112
89
+ microsoft_agents/hosting/core/storage/transcript_file_store.py,sha256=eJdcU6BgMbvFYunWul2CZURH762HmUr11iUN7NgvZek,10045
90
90
  microsoft_agents/hosting/core/storage/transcript_info.py,sha256=5VN32j99tshChAffvuZ6D3GH3ABCZsQGHC_bYDAwFOk,328
91
91
  microsoft_agents/hosting/core/storage/transcript_logger.py,sha256=_atDk3CJ05fIVMhlWGNa91IiM9bGLmOhasFko8Lxjhk,8237
92
92
  microsoft_agents/hosting/core/storage/transcript_memory_store.py,sha256=v1Ud9LSs8m5c9_Fa8i49SuAjw80dX1hDciqbRduDEOE,6444
93
93
  microsoft_agents/hosting/core/storage/transcript_store.py,sha256=ka74o0WvI5GhMZcFqSxVdamBhGzZcDZe6VNkG-sMy74,1944
94
- microsoft_agents_hosting_core-0.5.0.dev5.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
95
- microsoft_agents_hosting_core-0.5.0.dev5.dist-info/METADATA,sha256=c-kSClZjsayfITF3XRRBmTLexiS-EbOnBFA4roHLfDc,601
96
- microsoft_agents_hosting_core-0.5.0.dev5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
97
- microsoft_agents_hosting_core-0.5.0.dev5.dist-info/top_level.txt,sha256=lWKcT4v6fTA_NgsuHdNvuMjSrkiBMXohn64ApY7Xi8A,17
98
- microsoft_agents_hosting_core-0.5.0.dev5.dist-info/RECORD,,
94
+ microsoft_agents_hosting_core-0.5.0.dev10.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
95
+ microsoft_agents_hosting_core-0.5.0.dev10.dist-info/METADATA,sha256=SIakmKCc52nErP4ninQsGSqwDQ6cH3JNlpP5s42P26M,8596
96
+ microsoft_agents_hosting_core-0.5.0.dev10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
97
+ microsoft_agents_hosting_core-0.5.0.dev10.dist-info/top_level.txt,sha256=lWKcT4v6fTA_NgsuHdNvuMjSrkiBMXohn64ApY7Xi8A,17
98
+ microsoft_agents_hosting_core-0.5.0.dev10.dist-info/RECORD,,
@@ -1,18 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: microsoft-agents-hosting-core
3
- Version: 0.5.0.dev5
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: Operating System :: OS Independent
10
- Requires-Python: >=3.9
11
- License-File: LICENSE
12
- Requires-Dist: microsoft-agents-activity==0.5.0.dev5
13
- Requires-Dist: pyjwt>=2.10.1
14
- Requires-Dist: isodate>=0.6.1
15
- Requires-Dist: azure-core>=1.30.0
16
- Requires-Dist: python-dotenv>=1.1.1
17
- Dynamic: license-file
18
- Dynamic: requires-dist