microsoft-agents-hosting-core 0.4.0.dev14__tar.gz → 0.4.0.dev16__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.
Files changed (99) hide show
  1. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/PKG-INFO +2 -2
  2. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/channel_service_adapter.py +23 -26
  3. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/channel_service_client_factory_base.py +6 -1
  4. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/connector/client/connector_client.py +22 -2
  5. microsoft_agents_hosting_core-0.4.0.dev16/microsoft_agents/hosting/core/rest_channel_service_client_factory.py +159 -0
  6. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/storage/__init__.py +4 -0
  7. microsoft_agents_hosting_core-0.4.0.dev16/microsoft_agents/hosting/core/storage/transcript_file_store.py +267 -0
  8. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/storage/transcript_logger.py +12 -0
  9. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/storage/transcript_memory_store.py +9 -7
  10. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents_hosting_core.egg-info/PKG-INFO +2 -2
  11. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents_hosting_core.egg-info/SOURCES.txt +1 -0
  12. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents_hosting_core.egg-info/requires.txt +1 -1
  13. microsoft_agents_hosting_core-0.4.0.dev14/microsoft_agents/hosting/core/rest_channel_service_client_factory.py +0 -133
  14. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/__init__.py +0 -0
  15. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/_oauth/__init__.py +0 -0
  16. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/_oauth/_flow_state.py +0 -0
  17. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/_oauth/_flow_storage_client.py +0 -0
  18. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/_oauth/_oauth_flow.py +0 -0
  19. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/activity_handler.py +0 -0
  20. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/agent.py +0 -0
  21. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/__init__.py +0 -0
  22. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/agent_application.py +0 -0
  23. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/app_error.py +0 -0
  24. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/app_options.py +0 -0
  25. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/input_file.py +0 -0
  26. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/oauth/__init__.py +0 -0
  27. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/oauth/_handlers/__init__.py +0 -0
  28. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/oauth/_handlers/_authorization_handler.py +0 -0
  29. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/oauth/_handlers/_user_authorization.py +0 -0
  30. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/oauth/_handlers/agentic_user_authorization.py +0 -0
  31. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/oauth/_sign_in_response.py +0 -0
  32. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/oauth/_sign_in_state.py +0 -0
  33. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/oauth/auth_handler.py +0 -0
  34. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/oauth/authorization.py +0 -0
  35. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/query.py +0 -0
  36. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/route.py +0 -0
  37. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/state/__init__.py +0 -0
  38. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/state/conversation_state.py +0 -0
  39. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/state/state.py +0 -0
  40. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/state/temp_state.py +0 -0
  41. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/state/turn_state.py +0 -0
  42. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/app/typing_indicator.py +0 -0
  43. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/authorization/__init__.py +0 -0
  44. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/authorization/access_token_provider_base.py +0 -0
  45. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/authorization/agent_auth_configuration.py +0 -0
  46. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/authorization/anonymous_token_provider.py +0 -0
  47. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/authorization/auth_types.py +0 -0
  48. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/authorization/authentication_constants.py +0 -0
  49. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/authorization/claims_identity.py +0 -0
  50. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/authorization/connections.py +0 -0
  51. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/authorization/jwt_token_validator.py +0 -0
  52. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/card_factory.py +0 -0
  53. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/channel_adapter.py +0 -0
  54. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/channel_api_handler_protocol.py +0 -0
  55. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/client/__init__.py +0 -0
  56. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/client/agent_conversation_reference.py +0 -0
  57. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/client/channel_factory_protocol.py +0 -0
  58. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/client/channel_host_protocol.py +0 -0
  59. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/client/channel_info_protocol.py +0 -0
  60. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/client/channel_protocol.py +0 -0
  61. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/client/channels_configuration.py +0 -0
  62. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/client/configuration_channel_host.py +0 -0
  63. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/client/conversation_constants.py +0 -0
  64. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/client/conversation_id_factory.py +0 -0
  65. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/client/conversation_id_factory_options.py +0 -0
  66. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/client/conversation_id_factory_protocol.py +0 -0
  67. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/client/http_agent_channel.py +0 -0
  68. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/client/http_agent_channel_factory.py +0 -0
  69. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/connector/__init__.py +0 -0
  70. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/connector/agent_sign_in_base.py +0 -0
  71. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/connector/attachments_base.py +0 -0
  72. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/connector/client/__init__.py +0 -0
  73. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/connector/client/user_token_client.py +0 -0
  74. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/connector/connector_client_base.py +0 -0
  75. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/connector/conversations_base.py +0 -0
  76. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/connector/get_product_info.py +0 -0
  77. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/connector/teams/__init__.py +0 -0
  78. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/connector/teams/teams_connector_client.py +0 -0
  79. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/connector/user_token_base.py +0 -0
  80. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/connector/user_token_client_base.py +0 -0
  81. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/message_factory.py +0 -0
  82. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/middleware_set.py +0 -0
  83. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/state/__init__.py +0 -0
  84. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/state/agent_state.py +0 -0
  85. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/state/state_property_accessor.py +0 -0
  86. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/state/user_state.py +0 -0
  87. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/storage/_type_aliases.py +0 -0
  88. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/storage/error_handling.py +0 -0
  89. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/storage/memory_storage.py +0 -0
  90. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/storage/storage.py +0 -0
  91. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/storage/store_item.py +0 -0
  92. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/storage/transcript_info.py +0 -0
  93. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/storage/transcript_store.py +0 -0
  94. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents/hosting/core/turn_context.py +0 -0
  95. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents_hosting_core.egg-info/dependency_links.txt +0 -0
  96. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/microsoft_agents_hosting_core.egg-info/top_level.txt +0 -0
  97. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/pyproject.toml +0 -0
  98. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/setup.cfg +0 -0
  99. {microsoft_agents_hosting_core-0.4.0.dev14 → microsoft_agents_hosting_core-0.4.0.dev16}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: microsoft-agents-hosting-core
3
- Version: 0.4.0.dev14
3
+ Version: 0.4.0.dev16
4
4
  Summary: Core library for Microsoft Agents
5
5
  Author: Microsoft Corporation
6
6
  Project-URL: Homepage, https://github.com/microsoft/Agents
@@ -8,7 +8,7 @@ Classifier: Programming Language :: Python :: 3
8
8
  Classifier: License :: OSI Approved :: MIT License
9
9
  Classifier: Operating System :: OS Independent
10
10
  Requires-Python: >=3.9
11
- Requires-Dist: microsoft-agents-activity==0.4.0.dev14
11
+ Requires-Dist: microsoft-agents-activity==0.4.0.dev16
12
12
  Requires-Dist: pyjwt>=2.10.1
13
13
  Requires-Dist: isodate>=0.6.1
14
14
  Requires-Dist: azure-core>=1.30.0
@@ -213,21 +213,21 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
213
213
  claims_identity = self.create_claims_identity(agent_app_id)
214
214
  claims_identity.claims[AuthenticationConstants.SERVICE_URL_CLAIM] = service_url
215
215
 
216
- # Create a UserTokenClient instance for the application to use. (For example, in the OAuthPrompt.)
217
- user_token_client: UserTokenClient = (
218
- await self._channel_service_client_factory.create_user_token_client(
219
- claims_identity
220
- )
221
- )
222
-
223
216
  # Create a turn context and run the pipeline.
224
217
  context = self._create_turn_context(
225
218
  claims_identity,
226
219
  None,
227
- user_token_client,
228
220
  callback,
229
221
  )
230
222
 
223
+ # Create a UserTokenClient instance for the application to use. (For example, in the OAuthPrompt.)
224
+ user_token_client: UserTokenClient = (
225
+ await self._channel_service_client_factory.create_user_token_client(
226
+ context, claims_identity
227
+ )
228
+ )
229
+ context.turn_state[self.USER_TOKEN_CLIENT_KEY] = user_token_client
230
+
231
231
  # Create the connector client to use for outbound requests.
232
232
  connector_client: ConnectorClient = (
233
233
  await self._channel_service_client_factory.create_connector_client(
@@ -264,22 +264,21 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
264
264
  callback: Callable[[TurnContext], Awaitable],
265
265
  ):
266
266
 
267
- # Create a UserTokenClient instance for the application to use. (For example, in the OAuthPrompt.)
268
- user_token_client: UserTokenClient = (
269
- await self._channel_service_client_factory.create_user_token_client(
270
- claims_identity
271
- )
272
- )
273
-
274
267
  # Create a turn context and run the pipeline.
275
268
  context = self._create_turn_context(
276
269
  claims_identity,
277
270
  audience,
278
- user_token_client,
279
271
  callback,
280
272
  activity=continuation_activity,
281
273
  )
282
274
 
275
+ user_token_client: UserTokenClient = (
276
+ await self._channel_service_client_factory.create_user_token_client(
277
+ context, claims_identity
278
+ )
279
+ )
280
+ context.turn_state[self.USER_TOKEN_CLIENT_KEY] = user_token_client
281
+
283
282
  # Create the connector client to use for outbound requests.
284
283
  connector_client: ConnectorClient = (
285
284
  await self._channel_service_client_factory.create_connector_client(
@@ -338,22 +337,22 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
338
337
  ):
339
338
  use_anonymous_auth_callback = True
340
339
 
341
- # Create a UserTokenClient instance for the OAuth flow.
342
- user_token_client: UserTokenClient = (
343
- await self._channel_service_client_factory.create_user_token_client(
344
- claims_identity, use_anonymous_auth_callback
345
- )
346
- )
347
-
348
340
  # Create a turn context and run the pipeline.
349
341
  context = self._create_turn_context(
350
342
  claims_identity,
351
343
  outgoing_audience,
352
- user_token_client,
353
344
  callback,
354
345
  activity=activity,
355
346
  )
356
347
 
348
+ # Create a UserTokenClient instance for the OAuth flow.
349
+ user_token_client: UserTokenClient = (
350
+ await self._channel_service_client_factory.create_user_token_client(
351
+ context, claims_identity, use_anonymous_auth_callback
352
+ )
353
+ )
354
+ context.turn_state[self.USER_TOKEN_CLIENT_KEY] = user_token_client
355
+
357
356
  # Create the connector client to use for outbound requests.
358
357
  connector_client: ConnectorClient = (
359
358
  await self._channel_service_client_factory.create_connector_client(
@@ -425,14 +424,12 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
425
424
  self,
426
425
  claims_identity: ClaimsIdentity,
427
426
  oauth_scope: str,
428
- user_token_client: UserTokenClientBase,
429
427
  callback: Callable[[TurnContext], Awaitable],
430
428
  activity: Optional[Activity] = None,
431
429
  ) -> TurnContext:
432
430
  context = TurnContext(self, activity, claims_identity)
433
431
 
434
432
  context.turn_state[self.AGENT_IDENTITY_KEY] = claims_identity
435
- context.turn_state[self.USER_TOKEN_CLIENT_KEY] = user_token_client
436
433
  context.turn_state[self.AGENT_CALLBACK_HANDLER_KEY] = callback
437
434
  context.turn_state[self.CHANNEL_SERVICE_FACTORY_KEY] = (
438
435
  self._channel_service_client_factory
@@ -6,12 +6,14 @@ from microsoft_agents.hosting.core.connector import (
6
6
  ConnectorClientBase,
7
7
  UserTokenClientBase,
8
8
  )
9
+ from microsoft_agents.hosting.core.turn_context import TurnContext
9
10
 
10
11
 
11
12
  class ChannelServiceClientFactoryBase(Protocol):
12
13
  @abstractmethod
13
14
  async def create_connector_client(
14
15
  self,
16
+ context: TurnContext,
15
17
  claims_identity: ClaimsIdentity,
16
18
  service_url: str,
17
19
  audience: str,
@@ -32,7 +34,10 @@ class ChannelServiceClientFactoryBase(Protocol):
32
34
 
33
35
  @abstractmethod
34
36
  async def create_user_token_client(
35
- self, claims_identity: ClaimsIdentity, use_anonymous: bool = False
37
+ self,
38
+ context: TurnContext,
39
+ claims_identity: ClaimsIdentity,
40
+ use_anonymous: bool = False,
36
41
  ) -> UserTokenClientBase:
37
42
  """
38
43
  Creates the appropriate UserTokenClientBase instance.
@@ -122,8 +122,12 @@ class AttachmentsOperations(AttachmentsBase):
122
122
 
123
123
  class ConversationsOperations(ConversationsBase):
124
124
 
125
- def __init__(self, client: ClientSession):
125
+ def __init__(self, client: ClientSession, **kwargs):
126
126
  self.client = client
127
+ self._max_conversation_id_length = kwargs.get("max_conversation_id_length", 200)
128
+
129
+ def _normalize_conversation_id(self, conversation_id: str) -> str:
130
+ return conversation_id[: self._max_conversation_id_length]
127
131
 
128
132
  async def get_conversations(
129
133
  self, continuation_token: Optional[str] = None
@@ -193,11 +197,16 @@ class ConversationsOperations(ConversationsBase):
193
197
  )
194
198
  raise ValueError("conversationId and activityId are required")
195
199
 
200
+ print("\n*3")
201
+ print(conversation_id)
202
+ print("\n*3")
203
+ conversation_id = self._normalize_conversation_id(conversation_id)
196
204
  url = f"v3/conversations/{conversation_id}/activities/{activity_id}"
197
205
 
198
206
  logger.info(
199
207
  f"Replying to activity: {activity_id} in conversation: {conversation_id}. Activity type is {body.type}"
200
208
  )
209
+
201
210
  async with self.client.post(
202
211
  url,
203
212
  json=body.model_dump(
@@ -216,7 +225,8 @@ class ConversationsOperations(ConversationsBase):
216
225
  logger.info(
217
226
  f"Reply to conversation/activity: {result.get('id')}, {activity_id}"
218
227
  )
219
- return ResourceResponse.model_validate(result)
228
+
229
+ return ResourceResponse.model_validate(result)
220
230
 
221
231
  async def send_to_conversation(
222
232
  self, conversation_id: str, body: Activity
@@ -235,6 +245,7 @@ class ConversationsOperations(ConversationsBase):
235
245
  )
236
246
  raise ValueError("conversationId is required")
237
247
 
248
+ conversation_id = self._normalize_conversation_id(conversation_id)
238
249
  url = f"v3/conversations/{conversation_id}/activities"
239
250
 
240
251
  logger.info(
@@ -271,6 +282,7 @@ class ConversationsOperations(ConversationsBase):
271
282
  )
272
283
  raise ValueError("conversationId and activityId are required")
273
284
 
285
+ conversation_id = self._normalize_conversation_id(conversation_id)
274
286
  url = f"v3/conversations/{conversation_id}/activities/{activity_id}"
275
287
 
276
288
  logger.info(
@@ -303,6 +315,7 @@ class ConversationsOperations(ConversationsBase):
303
315
  )
304
316
  raise ValueError("conversationId and activityId are required")
305
317
 
318
+ conversation_id = self._normalize_conversation_id(conversation_id)
306
319
  url = f"v3/conversations/{conversation_id}/activities/{activity_id}"
307
320
 
308
321
  logger.info(
@@ -332,6 +345,7 @@ class ConversationsOperations(ConversationsBase):
332
345
  )
333
346
  raise ValueError("conversationId is required")
334
347
 
348
+ conversation_id = self._normalize_conversation_id(conversation_id)
335
349
  url = f"v3/conversations/{conversation_id}/attachments"
336
350
 
337
351
  # Convert the AttachmentData to a dictionary
@@ -371,6 +385,7 @@ class ConversationsOperations(ConversationsBase):
371
385
  )
372
386
  raise ValueError("conversationId is required")
373
387
 
388
+ conversation_id = self._normalize_conversation_id(conversation_id)
374
389
  url = f"v3/conversations/{conversation_id}/members"
375
390
 
376
391
  logger.info(f"Getting conversation members for conversation: {conversation_id}")
@@ -402,6 +417,7 @@ class ConversationsOperations(ConversationsBase):
402
417
  )
403
418
  raise ValueError("conversationId and memberId are required")
404
419
 
420
+ conversation_id = self._normalize_conversation_id(conversation_id)
405
421
  url = f"v3/conversations/{conversation_id}/members/{member_id}"
406
422
 
407
423
  logger.info(
@@ -434,6 +450,7 @@ class ConversationsOperations(ConversationsBase):
434
450
  )
435
451
  raise ValueError("conversationId and memberId are required")
436
452
 
453
+ conversation_id = self._normalize_conversation_id(conversation_id)
437
454
  url = f"v3/conversations/{conversation_id}/members/{member_id}"
438
455
 
439
456
  logger.info(
@@ -464,6 +481,7 @@ class ConversationsOperations(ConversationsBase):
464
481
  )
465
482
  raise ValueError("conversationId and activityId are required")
466
483
 
484
+ conversation_id = self._normalize_conversation_id(conversation_id)
467
485
  url = f"v3/conversations/{conversation_id}/activities/{activity_id}/members"
468
486
 
469
487
  logger.info(
@@ -507,6 +525,7 @@ class ConversationsOperations(ConversationsBase):
507
525
  if continuation_token is not None:
508
526
  params["continuationToken"] = continuation_token
509
527
 
528
+ conversation_id = self._normalize_conversation_id(conversation_id)
510
529
  url = f"v3/conversations/{conversation_id}/pagedmembers"
511
530
 
512
531
  logger.info(
@@ -540,6 +559,7 @@ class ConversationsOperations(ConversationsBase):
540
559
  )
541
560
  raise ValueError("conversationId is required")
542
561
 
562
+ conversation_id = self._normalize_conversation_id(conversation_id)
543
563
  url = f"v3/conversations/{conversation_id}/activities/history"
544
564
 
545
565
  logger.info(f"Sending conversation history to conversation: {conversation_id}")
@@ -0,0 +1,159 @@
1
+ from typing import Optional
2
+ import logging
3
+
4
+ from microsoft_agents.activity import RoleTypes
5
+ from microsoft_agents.hosting.core.authorization import (
6
+ AuthenticationConstants,
7
+ AnonymousTokenProvider,
8
+ ClaimsIdentity,
9
+ Connections,
10
+ )
11
+ from microsoft_agents.hosting.core.authorization import AccessTokenProviderBase
12
+ from microsoft_agents.hosting.core.connector import ConnectorClientBase
13
+ from microsoft_agents.hosting.core.connector.client import UserTokenClient
14
+ from microsoft_agents.hosting.core.connector.teams import TeamsConnectorClient
15
+
16
+ from .channel_service_client_factory_base import ChannelServiceClientFactoryBase
17
+ from .turn_context import TurnContext
18
+
19
+ logger = logging.getLogger(__name__)
20
+
21
+
22
+ class RestChannelServiceClientFactory(ChannelServiceClientFactoryBase):
23
+ _ANONYMOUS_TOKEN_PROVIDER = AnonymousTokenProvider()
24
+
25
+ def __init__(
26
+ self,
27
+ connection_manager: Connections,
28
+ token_service_endpoint=AuthenticationConstants.AGENTS_SDK_OAUTH_URL,
29
+ token_service_audience=AuthenticationConstants.AGENTS_SDK_SCOPE,
30
+ ) -> None:
31
+ self._connection_manager = connection_manager
32
+ self._token_service_endpoint = token_service_endpoint
33
+ self._token_service_audience = token_service_audience
34
+
35
+ async def _get_agentic_token(self, context: TurnContext, service_url: str) -> str:
36
+ logger.info(
37
+ "Creating connector client for agentic request to service_url: %s",
38
+ service_url,
39
+ )
40
+
41
+ if not context.identity:
42
+ raise ValueError("context.identity is required for agentic activities")
43
+
44
+ connection = self._connection_manager.get_token_provider(
45
+ context.identity, service_url
46
+ )
47
+ if not hasattr(connection, "_msal_configuration"):
48
+ raise TypeError(
49
+ "Connection does not support MSAL configuration for agentic token retrieval"
50
+ )
51
+
52
+ if connection._msal_configuration.ALT_BLUEPRINT_ID:
53
+ logger.debug(
54
+ "Using alternative blueprint ID for agentic token retrieval: %s",
55
+ connection._msal_configuration.ALT_BLUEPRINT_ID,
56
+ )
57
+ connection = self._connection_manager.get_connection(
58
+ connection._msal_configuration.ALT_BLUEPRINT_ID
59
+ )
60
+
61
+ agent_instance_id = context.activity.get_agentic_instance_id()
62
+ if not agent_instance_id:
63
+ raise ValueError("Agent instance ID is required for agentic identity role")
64
+
65
+ if context.activity.recipient.role == RoleTypes.agentic_identity:
66
+ token, _ = await connection.get_agentic_instance_token(agent_instance_id)
67
+ else:
68
+ agentic_user = context.activity.get_agentic_user()
69
+ if not agentic_user:
70
+ raise ValueError("Agentic user is required for agentic user role")
71
+ token = await connection.get_agentic_user_token(
72
+ agent_instance_id,
73
+ agentic_user,
74
+ [AuthenticationConstants.APX_PRODUCTION_SCOPE],
75
+ )
76
+
77
+ if not token:
78
+ raise ValueError("Failed to obtain token for agentic activity")
79
+ return token
80
+
81
+ async def create_connector_client(
82
+ self,
83
+ context: TurnContext,
84
+ claims_identity: ClaimsIdentity,
85
+ service_url: str,
86
+ audience: str,
87
+ scopes: Optional[list[str]] = None,
88
+ use_anonymous: bool = False,
89
+ ) -> ConnectorClientBase:
90
+ if not context or not claims_identity:
91
+ raise TypeError("context and claims_identity are required")
92
+ if not service_url:
93
+ raise TypeError(
94
+ "RestChannelServiceClientFactory.create_connector_client: service_url can't be None or Empty"
95
+ )
96
+ if not audience:
97
+ raise TypeError(
98
+ "RestChannelServiceClientFactory.create_connector_client: audience can't be None or Empty"
99
+ )
100
+
101
+ if context.activity.is_agentic_request():
102
+ token = await self._get_agentic_token(context, service_url)
103
+ else:
104
+ token_provider: AccessTokenProviderBase = (
105
+ self._connection_manager.get_token_provider(
106
+ claims_identity, service_url
107
+ )
108
+ if not use_anonymous
109
+ else self._ANONYMOUS_TOKEN_PROVIDER
110
+ )
111
+
112
+ token = await token_provider.get_access_token(
113
+ audience, scopes or [f"{audience}/.default"]
114
+ )
115
+
116
+ return TeamsConnectorClient(
117
+ endpoint=service_url,
118
+ token=token,
119
+ )
120
+
121
+ async def create_user_token_client(
122
+ self,
123
+ context: TurnContext,
124
+ claims_identity: ClaimsIdentity,
125
+ use_anonymous: bool = False,
126
+ ) -> UserTokenClient:
127
+ """Create a UserTokenClient for the given context and claims identity.
128
+
129
+ :param context: The TurnContext for the current turn of conversation.
130
+ :param claims_identity: The ClaimsIdentity of the user.
131
+ :param use_anonymous: Whether to use an anonymous token provider.
132
+ """
133
+ if not context or not claims_identity:
134
+ raise ValueError("context and claims_identity are required")
135
+
136
+ if use_anonymous:
137
+ return UserTokenClient(endpoint=self._token_service_endpoint, token="")
138
+
139
+ if context.activity.is_agentic_request():
140
+ token = await self._get_agentic_token(context, self._token_service_endpoint)
141
+ else:
142
+ scopes = [f"{self._token_service_audience}/.default"]
143
+
144
+ token_provider = self._connection_manager.get_token_provider(
145
+ claims_identity, self._token_service_endpoint
146
+ )
147
+
148
+ token = await token_provider.get_access_token(
149
+ self._token_service_audience, scopes
150
+ )
151
+
152
+ if not token:
153
+ logger.error("Failed to obtain token for user token client")
154
+ raise ValueError("Failed to obtain token for user token client")
155
+
156
+ return UserTokenClient(
157
+ endpoint=self._token_service_endpoint,
158
+ token=token,
159
+ )
@@ -7,8 +7,10 @@ from .transcript_logger import (
7
7
  ConsoleTranscriptLogger,
8
8
  TranscriptLoggerMiddleware,
9
9
  FileTranscriptLogger,
10
+ PagedResult,
10
11
  )
11
12
  from .transcript_store import TranscriptStore
13
+ from .transcript_file_store import FileTranscriptStore
12
14
 
13
15
  __all__ = [
14
16
  "StoreItem",
@@ -21,4 +23,6 @@ __all__ = [
21
23
  "TranscriptLoggerMiddleware",
22
24
  "TranscriptStore",
23
25
  "FileTranscriptLogger",
26
+ "FileTranscriptStore",
27
+ "PagedResult",
24
28
  ]