microsoft-agents-hosting-core 0.6.0.dev1__py3-none-any.whl → 0.6.0.dev7__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.
@@ -3,6 +3,7 @@
3
3
 
4
4
  from __future__ import annotations
5
5
  from http import HTTPStatus
6
+ from typing import Awaitable
6
7
  from pydantic import BaseModel
7
8
 
8
9
  from microsoft_agents.activity import TurnContextProtocol
@@ -24,9 +25,9 @@ class ActivityHandler(Agent):
24
25
  """
25
26
  Handles activities and should be subclassed.
26
27
 
27
- .. remarks::
28
+ .. note::
28
29
  Derive from this class to handle particular activity types.
29
- Yon can add pre and post processing of activities by calling the base class
30
+ You can add pre and post processing of activities by calling the base class
30
31
  in the derived class.
31
32
  """
32
33
 
@@ -34,15 +35,16 @@ class ActivityHandler(Agent):
34
35
  self, turn_context: TurnContextProtocol
35
36
  ): # pylint: disable=arguments-differ
36
37
  """
37
- Called by the adapter (for example, :class:`ChannelAdapter`) at runtime
38
+ Called by the adapter (for example, :class:`microsoft_agents.hosting.core.channel_adapter.ChannelAdapter`) at runtime
38
39
  in order to process an inbound :class:`microsoft_agents.activity.Activity`.
39
40
 
40
41
  :param turn_context: The context object for this turn
41
42
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
42
43
 
43
44
  :returns: A task that represents the work queued to execute
45
+ :rtype: Awaitable[None]
44
46
 
45
- .. remarks::
47
+ .. note::
46
48
  It calls other methods in this class based on the type of the activity to
47
49
  process, which allows a derived class to provide type-specific logic in a controlled way.
48
50
  In a derived class, override this method to add logic that applies to all activity types.
@@ -108,6 +110,7 @@ class ActivityHandler(Agent):
108
110
  :param turn_context: The context object for this turn
109
111
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
110
112
  :returns: A task that represents the work queued to execute
113
+ :rtype: Awaitable[None]
111
114
  """
112
115
  return
113
116
 
@@ -121,6 +124,7 @@ class ActivityHandler(Agent):
121
124
  :param turn_context: The context object for this turn
122
125
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
123
126
  :returns: A task that represents the work queued to execute
127
+ :rtype: Awaitable[None]
124
128
  """
125
129
  return
126
130
 
@@ -134,6 +138,7 @@ class ActivityHandler(Agent):
134
138
  :param turn_context: The context object for this turn
135
139
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
136
140
  :returns: A task that represents the work queued to execute
141
+ :rtype: Awaitable[None]
137
142
  """
138
143
  return
139
144
 
@@ -145,17 +150,18 @@ class ActivityHandler(Agent):
145
150
  :param turn_context: The context object for this turn
146
151
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
147
152
  :returns: A task that represents the work queued to execute
153
+ :rtype: Awaitable[None]
148
154
 
149
- .. remarks::
155
+ .. note::
150
156
  When the :meth:`on_turn()` method receives a conversation update activity, it calls this
151
157
  method.
152
158
  Also
153
159
  - If the conversation update activity indicates that members other than the agent joined the conversation,
154
- it calls the :meth:`on_members_added_activity()` method.
160
+ it calls the :meth:`on_members_added_activity()` method.
155
161
  - If the conversation update activity indicates that members other than the agent left the conversation,
156
- it calls the :meth:`on_members_removed_activity()` method.
162
+ it calls the :meth:`on_members_removed_activity()` method.
157
163
  - In a derived class, override this method to add logic that applies to all conversation update activities.
158
- Add logic to apply before the member added or removed logic before the call to this base class method.
164
+ Add logic to apply before the member added or removed logic before the call to this base class method.
159
165
  """
160
166
  # TODO: confirm behavior of added and removed at the same time as C# doesn't support it
161
167
  if turn_context.activity.members_added:
@@ -175,13 +181,14 @@ class ActivityHandler(Agent):
175
181
  the conversation. You can add your agent's welcome logic.
176
182
 
177
183
  :param members_added: A list of all the members added to the conversation, as described by the
178
- conversation update activity
184
+ conversation update activity
179
185
  :type members_added: list[:class:`microsoft_agents.activity.ChannelAccount`]
180
186
  :param turn_context: The context object for this turn
181
187
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
182
188
  :returns: A task that represents the work queued to execute
189
+ :rtype: Awaitable[None]
183
190
 
184
- .. remarks::
191
+ .. note::
185
192
  When the :meth:`on_conversation_update_activity()` method receives a conversation
186
193
  update activity that indicates
187
194
  one or more users other than the agent are joining the conversation, it calls this method.
@@ -196,13 +203,14 @@ class ActivityHandler(Agent):
196
203
  the conversation. You can add your agent's good-bye logic.
197
204
 
198
205
  :param members_removed: A list of all the members removed from the conversation, as described by the
199
- conversation update activity
206
+ conversation update activity
200
207
  :type members_removed: list[:class:`microsoft_agents.activity.ChannelAccount`]
201
208
  :param turn_context: The context object for this turn
202
209
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
203
210
  :returns: A task that represents the work queued to execute
211
+ :rtype: Awaitable[None]
204
212
 
205
- .. remarks::
213
+ .. note::
206
214
  When the :meth:`on_conversation_update_activity()` method receives a conversation
207
215
  update activity that indicates one or more users other than the agent are leaving the conversation,
208
216
  it calls this method.
@@ -219,8 +227,9 @@ class ActivityHandler(Agent):
219
227
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
220
228
 
221
229
  :returns: A task that represents the work queued to execute
230
+ :rtype: Awaitable[None]
222
231
 
223
- .. remarks::
232
+ .. note::
224
233
  Message reactions correspond to the user adding a 'like' or 'sad' etc. (often an emoji) to a previously
225
234
  sent activity.
226
235
 
@@ -231,9 +240,9 @@ class ActivityHandler(Agent):
231
240
  method.
232
241
 
233
242
  - If the message reaction indicates that reactions were added to a message, it calls
234
- :meth:`on_reaction_added()`.
243
+ :meth:`on_reactions_added()`.
235
244
  - If the message reaction indicates that reactions were removed from a message, it calls
236
- :meth:`on_reaction_removed()`.
245
+ :meth:`on_reactions_removed()`.
237
246
 
238
247
  In a derived class, override this method to add logic that applies to all message reaction activities.
239
248
  Add logic to apply before the reactions added or removed logic before the call to the this base class
@@ -264,8 +273,9 @@ class ActivityHandler(Agent):
264
273
  :param turn_context: The context object for this turn
265
274
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
266
275
  :returns: A task that represents the work queued to execute
276
+ :rtype: Awaitable[None]
267
277
 
268
- .. remarks::
278
+ .. note::
269
279
  Message reactions correspond to the user adding a 'like' or 'sad' etc. (often an emoji)
270
280
  to a previously sent message on the conversation.
271
281
  Message reactions are supported by only a few channels.
@@ -290,8 +300,9 @@ class ActivityHandler(Agent):
290
300
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
291
301
 
292
302
  :returns: A task that represents the work queued to execute
303
+ :rtype: Awaitable[None]
293
304
 
294
- .. remarks::
305
+ .. note::
295
306
  Message reactions correspond to the user adding a 'like' or 'sad' etc. (often an emoji)
296
307
  to a previously sent message on the conversation. Message reactions are supported by only a few channels.
297
308
  The activity that the message is in reaction to is identified by the activity's reply to Id property.
@@ -308,8 +319,9 @@ class ActivityHandler(Agent):
308
319
  :param turn_context: The context object for this turn
309
320
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
310
321
  :returns: A task that represents the work queued to execute
322
+ :rtype: Awaitable[None]
311
323
 
312
- .. remarks::
324
+ .. note::
313
325
  When the :meth:`on_turn()` method receives an event activity, it calls this method.
314
326
  If the activity name is `tokens/response`, it calls :meth:`on_token_response_event()`;
315
327
  otherwise, it calls :meth:`on_event()`.
@@ -338,8 +350,9 @@ class ActivityHandler(Agent):
338
350
  :param turn_context: The context object for this turn
339
351
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
340
352
  :returns: A task that represents the work queued to execute
353
+ :rtype: Awaitable[None]
341
354
 
342
- .. remarks::
355
+ .. note::
343
356
  When the :meth:`on_event()` method receives an event with an activity name of
344
357
  `tokens/response`, it calls this method. If your agent uses an `oauth_prompt`, forward the incoming
345
358
  activity to the current dialog.
@@ -352,11 +365,13 @@ class ActivityHandler(Agent):
352
365
  """
353
366
  Invoked when an event other than `tokens/response` is received when the base behavior of
354
367
  :meth:`on_event_activity()` is used.
368
+
355
369
  :param turn_context: The context object for this turn
356
370
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
357
371
  :returns: A task that represents the work queued to execute
372
+ :rtype: Awaitable[None]
358
373
 
359
- .. remarks::
374
+ .. note::
360
375
  When the :meth:`on_event_activity()` is used method receives an event with an
361
376
  activity name other than `tokens/response`, it calls this method.
362
377
  This method could optionally be overridden if the agent is meant to handle miscellaneous events.
@@ -368,9 +383,11 @@ class ActivityHandler(Agent):
368
383
  ):
369
384
  """
370
385
  Invoked when a conversation end activity is received from the channel.
386
+
371
387
  :param turn_context: The context object for this turn
372
388
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
373
389
  :returns: A task that represents the work queued to execute
390
+ :rtype: Awaitable[None]
374
391
  """
375
392
  return
376
393
 
@@ -384,6 +401,7 @@ class ActivityHandler(Agent):
384
401
  :param turn_context: The context object for this turn
385
402
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
386
403
  :returns: A task that represents the work queued to execute
404
+ :rtype: Awaitable[None]
387
405
  """
388
406
  return
389
407
 
@@ -397,6 +415,7 @@ class ActivityHandler(Agent):
397
415
  :param turn_context: The context object for this turn
398
416
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
399
417
  :returns: A task that represents the work queued to execute
418
+ :rtype: Awaitable[None]
400
419
  """
401
420
  if turn_context.activity.action in ("add", "add-upgrade"):
402
421
  return await self.on_installation_update_add(turn_context)
@@ -414,6 +433,7 @@ class ActivityHandler(Agent):
414
433
  :param turn_context: The context object for this turn
415
434
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
416
435
  :returns: A task that represents the work queued to execute
436
+ :rtype: Awaitable[None]
417
437
  """
418
438
  return
419
439
 
@@ -427,6 +447,7 @@ class ActivityHandler(Agent):
427
447
  :param turn_context: The context object for this turn
428
448
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
429
449
  :returns: A task that represents the work queued to execute
450
+ :rtype: Awaitable[None]
430
451
  """
431
452
  return
432
453
 
@@ -440,10 +461,10 @@ class ActivityHandler(Agent):
440
461
 
441
462
  :param turn_context: The context object for this turn
442
463
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
443
-
444
464
  :returns: A task that represents the work queued to execute
465
+ :rtype: Awaitable[None]
445
466
 
446
- .. remarks::
467
+ .. note::
447
468
  When the :meth:`on_turn()` method receives an activity that is not a message,
448
469
  conversation update, message reaction, or event activity, it calls this method.
449
470
  """
@@ -494,8 +515,8 @@ class ActivityHandler(Agent):
494
515
 
495
516
  :param turn_context: The context object for this turn
496
517
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
497
-
498
518
  :returns: A task that represents the work queued to execute
519
+ :rtype: Awaitable[None]
499
520
  """
500
521
  raise _InvokeResponseException(HTTPStatus.NOT_IMPLEMENTED)
501
522
 
@@ -512,7 +533,7 @@ class ActivityHandler(Agent):
512
533
  :type turn_context: :class:`microsoft_agents.activity.TurnContextProtocol`
513
534
  :param invoke_value: A string-typed object from the incoming activity's value.
514
535
  :type invoke_value: :class:`microsoft_agents.activity.AdaptiveCardInvokeValue`
515
- :return: The HealthCheckResponse object
536
+ :returns: The HealthCheckResponse object
516
537
  :rtype: :class:`microsoft_agents.activity.AdaptiveCardInvokeResponse`
517
538
  """
518
539
  raise _InvokeResponseException(HTTPStatus.NOT_IMPLEMENTED)
@@ -236,7 +236,7 @@ class AgentApplication(Agent, Generic[StateT]):
236
236
  Routes are ordered by: is_agentic, is_invoke, rank (lower is higher priority), in that order.
237
237
 
238
238
  :param selector: A function that takes a TurnContext and returns a boolean indicating whether the route should be selected.
239
- :type selector: :class:`microsoft_agents.hosting.core.app._type_defs.RouteSelector`
239
+ :type selector: Callable[[:class:`microsoft_agents.hosting.core.turn_context.TurnContext`], bool]
240
240
  :param handler: A function that takes a TurnContext and a TurnState and returns an Awaitable.
241
241
  :type handler: :class:`microsoft_agents.hosting.core.app._type_defs.RouteHandler`[StateT]
242
242
  :param is_invoke: Whether the route is for an invoke activity, defaults to False
@@ -245,7 +245,7 @@ class AgentApplication(Agent, Generic[StateT]):
245
245
  the selector will include a new check for `context.activity.is_agentic_request()`.
246
246
  :type is_agentic: bool, Optional
247
247
  :param rank: The rank of the route, defaults to RouteRank.DEFAULT
248
- :type rank: :class:`microsoft_agents.hosting.core.app._routes.RouteRank`, Optional
248
+ :type rank: :class:`microsoft_agents.hosting.core.app._routes.route_rank.RouteRank`, Optional
249
249
  :param auth_handlers: A list of authentication handler IDs to use for this route, defaults to None
250
250
  :type auth_handlers: Optional[list[str]], Optional
251
251
  :raises ApplicationError: If the selector or handler are not valid.
@@ -272,19 +272,21 @@ class AgentApplication(Agent, Generic[StateT]):
272
272
  **kwargs,
273
273
  ) -> Callable[[RouteHandler[StateT]], RouteHandler[StateT]]:
274
274
  """
275
- Registers a new activity event listener. This method can be used as either
276
- a decorator or a method.
277
-
278
- ```python
279
- # Use this method as a decorator
280
- @app.activity("event")
281
- async def on_event(context: TurnContext, state: TurnState):
282
- print("hello world!")
283
- return True
284
- ```
285
-
286
- #### Args:
287
- - `type`: The type of the activity
275
+ Register a new activity event listener as either a decorator or a method.
276
+
277
+ Example:
278
+ .. code-block:: python
279
+
280
+ @app.activity("event")
281
+ async def on_event(context: TurnContext, state: TurnState):
282
+ print("hello world!")
283
+ return True
284
+
285
+ :param activity_type: Activity type or collection of types that should trigger the handler.
286
+ :type activity_type: Union[str, microsoft_agents.activity.ActivityTypes, list[Union[str, microsoft_agents.activity.ActivityTypes]]]
287
+ :param auth_handlers: Optional list of authorization handler IDs for the route.
288
+ :type auth_handlers: Optional[list[str]]
289
+ :param kwargs: Additional route configuration passed to :meth:`add_route`.
288
290
  """
289
291
 
290
292
  def __selector(context: TurnContext):
@@ -307,18 +309,21 @@ class AgentApplication(Agent, Generic[StateT]):
307
309
  **kwargs,
308
310
  ) -> Callable[[RouteHandler[StateT]], RouteHandler[StateT]]:
309
311
  """
310
- Registers a new message activity event listener. This method can be used as either
311
- a decorator or a method.
312
-
313
- ```python
314
- # Use this method as a decorator
315
- @app.message("hi")
316
- async def on_hi_message(context: TurnContext, state: TurnState):
317
- print("hello!")
318
- return True
319
-
320
- #### Args:
321
- - `select`: a string or regex pattern
312
+ Register a new message activity event listener as either a decorator or a method.
313
+
314
+ Example:
315
+ .. code-block:: python
316
+
317
+ @app.message("hi")
318
+ async def on_hi_message(context: TurnContext, state: TurnState):
319
+ print("hello!")
320
+ return True
321
+
322
+ :param select: Literal text, compiled regex, or list of either used to match the incoming message.
323
+ :type select: Union[str, Pattern[str], list[Union[str, Pattern[str]]]]
324
+ :param auth_handlers: Optional list of authorization handler IDs for the route.
325
+ :type auth_handlers: Optional[list[str]]
326
+ :param kwargs: Additional route configuration passed to :meth:`add_route`.
322
327
  """
323
328
 
324
329
  def __selector(context: TurnContext):
@@ -349,20 +354,21 @@ class AgentApplication(Agent, Generic[StateT]):
349
354
  **kwargs,
350
355
  ) -> Callable[[RouteHandler[StateT]], RouteHandler[StateT]]:
351
356
  """
352
- Registers a new message activity event listener. This method can be used as either
353
- a decorator or a method.
357
+ Register a handler for conversation update activities as either a decorator or a method.
354
358
 
355
- ```python
356
- # Use this method as a decorator
357
- @app.conversation_update("channelCreated")
358
- async def on_channel_created(context: TurnContext, state: TurnState):
359
- print("a new channel was created!")
360
- return True
359
+ Example:
360
+ .. code-block:: python
361
361
 
362
- ```
362
+ @app.conversation_update("channelCreated")
363
+ async def on_channel_created(context: TurnContext, state: TurnState):
364
+ print("a new channel was created!")
365
+ return True
363
366
 
364
- #### Args:
365
- - `type`: a string or regex pattern
367
+ :param type: Conversation update category that must match the incoming activity.
368
+ :type type: microsoft_agents.activity.ConversationUpdateTypes
369
+ :param auth_handlers: Optional list of authorization handler IDs for the route.
370
+ :type auth_handlers: Optional[list[str]]
371
+ :param kwargs: Additional route configuration passed to :meth:`add_route`.
366
372
  """
367
373
 
368
374
  def __selector(context: TurnContext):
@@ -402,19 +408,21 @@ class AgentApplication(Agent, Generic[StateT]):
402
408
  **kwargs,
403
409
  ) -> Callable[[RouteHandler[StateT]], RouteHandler[StateT]]:
404
410
  """
405
- Registers a new message activity event listener. This method can be used as either
406
- a decorator or a method.
407
-
408
- ```python
409
- # Use this method as a decorator
410
- @app.message_reaction("reactionsAdded")
411
- async def on_reactions_added(context: TurnContext, state: TurnState):
412
- print("reactions was added!")
413
- return True
414
- ```
415
-
416
- #### Args:
417
- - `type`: a string or regex pattern
411
+ Register a handler for message reaction activities as either a decorator or a method.
412
+
413
+ Example:
414
+ .. code-block:: python
415
+
416
+ @app.message_reaction("reactionsAdded")
417
+ async def on_reactions_added(context: TurnContext, state: TurnState):
418
+ print("reaction was added!")
419
+ return True
420
+
421
+ :param type: Reaction category that must match the incoming activity.
422
+ :type type: microsoft_agents.activity.MessageReactionTypes
423
+ :param auth_handlers: Optional list of authorization handler IDs for the route.
424
+ :type auth_handlers: Optional[list[str]]
425
+ :param kwargs: Additional route configuration passed to :meth:`add_route`.
418
426
  """
419
427
 
420
428
  def __selector(context: TurnContext):
@@ -450,19 +458,21 @@ class AgentApplication(Agent, Generic[StateT]):
450
458
  **kwargs,
451
459
  ) -> Callable[[RouteHandler[StateT]], RouteHandler[StateT]]:
452
460
  """
453
- Registers a new message activity event listener. This method can be used as either
454
- a decorator or a method.
455
-
456
- ```python
457
- # Use this method as a decorator
458
- @app.message_update("editMessage")
459
- async def on_edit_message(context: TurnContext, state: TurnState):
460
- print("message was edited!")
461
- return True
462
- ```
463
-
464
- #### Args:
465
- - `type`: a string or regex pattern
461
+ Register a handler for message update activities as either a decorator or a method.
462
+
463
+ Example:
464
+ .. code-block:: python
465
+
466
+ @app.message_update("editMessage")
467
+ async def on_edit_message(context: TurnContext, state: TurnState):
468
+ print("message was edited!")
469
+ return True
470
+
471
+ :param type: Message update category that must match the incoming activity.
472
+ :type type: microsoft_agents.activity.MessageUpdateTypes
473
+ :param auth_handlers: Optional list of authorization handler IDs for the route.
474
+ :type auth_handlers: Optional[list[str]]
475
+ :param kwargs: Additional route configuration passed to :meth:`add_route`.
466
476
  """
467
477
 
468
478
  def __selector(context: TurnContext):
@@ -510,15 +520,18 @@ class AgentApplication(Agent, Generic[StateT]):
510
520
  Callable[[TurnContext, StateT, str], Awaitable[None]],
511
521
  ]:
512
522
  """
513
- Registers a handler to handoff conversations from one copilot to another.
514
- ```python
515
- # Use this method as a decorator
516
- @app.handoff
517
- async def on_handoff(
518
- context: TurnContext, state: TurnState, continuation: str
519
- ):
520
- print(query)
521
- ```
523
+ Register a handler to hand off conversations from one copilot to another.
524
+
525
+ Example:
526
+ .. code-block:: python
527
+
528
+ @app.handoff
529
+ async def on_handoff(context: TurnContext, state: TurnState, continuation: str):
530
+ print(continuation)
531
+
532
+ :param auth_handlers: Optional list of authorization handler IDs for the route.
533
+ :type auth_handlers: Optional[list[str]]
534
+ :param kwargs: Additional route configuration passed to :meth:`add_route`.
522
535
  """
523
536
 
524
537
  def __selector(context: TurnContext) -> bool:
@@ -555,15 +568,18 @@ class AgentApplication(Agent, Generic[StateT]):
555
568
  self, func: Callable[[TurnContext, StateT, Optional[str]], Awaitable[None]]
556
569
  ) -> Callable[[TurnContext, StateT, Optional[str]], Awaitable[None]]:
557
570
  """
558
- Registers a new event listener that will be executed when a user successfully signs in.
559
-
560
- ```python
561
- # Use this method as a decorator
562
- @app.on_sign_in_success
563
- async def sign_in_success(context: TurnContext, state: TurnState):
564
- print("hello world!")
565
- return True
566
- ```
571
+ Register a callback that executes when a user successfully signs in.
572
+
573
+ Example:
574
+ .. code-block:: python
575
+
576
+ @app.on_sign_in_success
577
+ async def sign_in_success(context: TurnContext, state: TurnState, connection_id: str | None):
578
+ print("sign-in succeeded")
579
+
580
+ :param func: Callable that handles the sign-in success event.
581
+ :type func: Callable[[TurnContext, StateT, Optional[str]], Awaitable[None]]
582
+ :raises ApplicationError: If authorization services are not configured.
567
583
  """
568
584
 
569
585
  if self._auth:
@@ -588,15 +604,18 @@ class AgentApplication(Agent, Generic[StateT]):
588
604
  self, func: Callable[[TurnContext, StateT, Optional[str]], Awaitable[None]]
589
605
  ) -> Callable[[TurnContext, StateT, Optional[str]], Awaitable[None]]:
590
606
  """
591
- Registers a new event listener that will be executed when a user fails to sign in.
592
-
593
- ```python
594
- # Use this method as a decorator
595
- @app.on_sign_in_failure
596
- async def sign_in_failure(context: TurnContext, state: TurnState):
597
- print("hello world!")
598
- return True
599
- ```
607
+ Register a callback that executes when a user fails to sign in.
608
+
609
+ Example:
610
+ .. code-block:: python
611
+
612
+ @app.on_sign_in_failure
613
+ async def sign_in_failure(context: TurnContext, state: TurnState, connection_id: str | None):
614
+ print("sign-in failed")
615
+
616
+ :param func: Callable that handles the sign-in failure event.
617
+ :type func: Callable[[TurnContext, StateT, Optional[str]], Awaitable[None]]
618
+ :raises ApplicationError: If authorization services are not configured.
600
619
  """
601
620
 
602
621
  if self._auth:
@@ -621,15 +640,17 @@ class AgentApplication(Agent, Generic[StateT]):
621
640
  self, func: Callable[[TurnContext, Exception], Awaitable[None]]
622
641
  ) -> Callable[[TurnContext, Exception], Awaitable[None]]:
623
642
  """
624
- Registers an error handler that will be called anytime
625
- the app throws an Exception
626
-
627
- ```python
628
- # Use this method as a decorator
629
- @app.error
630
- async def on_error(context: TurnContext, err: Exception):
631
- print(err.message)
632
- ```
643
+ Register an error handler that is invoked whenever the application raises an exception.
644
+
645
+ Example:
646
+ .. code-block:: python
647
+
648
+ @app.error
649
+ async def on_error(context: TurnContext, err: Exception):
650
+ print(err)
651
+
652
+ :param func: Callable executed when an uncaught exception occurs during a turn.
653
+ :type func: Callable[[TurnContext, Exception], Awaitable[None]]
633
654
  """
634
655
 
635
656
  logger.debug(f"Registering the error handler {func.__name__} ")
@@ -109,7 +109,7 @@ class State(dict[str, StoreItem], ABC):
109
109
  data = self.copy()
110
110
  del data["__key__"]
111
111
 
112
- logger.info(f"Saving state {self.__key__}")
112
+ logger.info("Saving state %s", self.__key__)
113
113
  await storage.delete(self.__deleted__)
114
114
  await storage.write(
115
115
  {
@@ -76,4 +76,3 @@ class TypingIndicator:
76
76
  await asyncio.sleep(self._intervalSeconds)
77
77
  except asyncio.CancelledError:
78
78
  logger.debug("Typing indicator loop cancelled")
79
- raise
@@ -42,8 +42,9 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
42
42
  :param context: The context object for the turn.
43
43
  :type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
44
44
  :param activities: The activities to send.
45
- :type activities: list[Activity]
46
- :return:
45
+ :type activities: list[microsoft_agents.activity.Activity]
46
+ :return: Channel responses produced by the adapter.
47
+ :rtype: list[microsoft_agents.activity.ResourceResponse]
47
48
  """
48
49
  raise NotImplementedError()
49
50
 
@@ -56,7 +57,8 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
56
57
  :type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
57
58
  :param activity: New replacement activity.
58
59
  :type activity: :class:`microsoft_agents.activity.Activity`
59
- :return:
60
+ :return: None
61
+ :rtype: None
60
62
  """
61
63
  raise NotImplementedError()
62
64
 
@@ -71,7 +73,8 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
71
73
  :type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
72
74
  :param reference: Conversation reference for the activity to delete.
73
75
  :type reference: :class:`microsoft_agents.activity.ConversationReference`
74
- :return:
76
+ :return: None
77
+ :rtype: None
75
78
  """
76
79
  raise NotImplementedError()
77
80
 
@@ -80,7 +83,9 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
80
83
  Registers a middleware handler with the adapter.
81
84
 
82
85
  :param middleware: The middleware to register.
83
- :return:
86
+ :type middleware: object
87
+ :return: The current adapter instance to support fluent calls.
88
+ :rtype: ChannelAdapter
84
89
  """
85
90
  self.middleware_set.use(middleware)
86
91
  return self
@@ -97,16 +102,14 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
97
102
  to the user.
98
103
 
99
104
  :param agent_id: The application ID of the agent. This parameter is ignored in
100
- single tenant the Adapters (Console, Test, etc) but is critical to the ChannelAdapter
101
- which is multi-tenant aware.
105
+ single-tenant adapters (Console, Test, etc.) but is required for multi-tenant adapters.
106
+ :type agent_id: str
102
107
  :param reference: A reference to the conversation to continue.
103
108
  :type reference: :class:`microsoft_agents.activity.ConversationReference`
104
109
  :param callback: The method to call for the resulting agent turn.
105
110
  :type callback: Callable[[microsoft_agents.hosting.core.turn_context.TurnContext], Awaitable]
106
- :param claims_identity: A :class:`microsoft_agents.hosting.core.ClaimsIdentity` for the conversation.
107
- :type claims_identity: :class:`microsoft_agents.hosting.core.ClaimsIdentity`
108
- :param audience:A value signifying the recipient of the proactive message.
109
- :type audience: str
111
+ :return: Result produced by the adapter pipeline.
112
+ :rtype: typing.Any
110
113
  """
111
114
  context = TurnContext(self, reference.get_continuation_activity())
112
115
  return await self.run_pipeline(context, callback)
@@ -123,7 +126,7 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
123
126
  Most channels require a user to initiate a conversation with an agent before the agent can send activities
124
127
  to the user.
125
128
 
126
- :param claims_identity: A :class:`microsoft_agents.hosting.core.ClaimsIdentity` for the conversation.
129
+ :param claims_identity: A :class:`microsoft_agents.hosting.core.authorization.ClaimsIdentity` for the conversation.
127
130
  :type claims_identity: :class:`microsoft_agents.hosting.core.authorization.ClaimsIdentity`
128
131
  :param continuation_activity: The activity to send.
129
132
  :type continuation_activity: :class:`microsoft_agents.activity.Activity`
@@ -131,6 +134,8 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
131
134
  :type callback: Callable[[microsoft_agents.hosting.core.turn_context.TurnContext], Awaitable]
132
135
  :param audience: A value signifying the recipient of the proactive message.
133
136
  :type audience: str
137
+ :return: Result produced by the adapter pipeline.
138
+ :rtype: typing.Any
134
139
  """
135
140
  raise NotImplementedError()
136
141
 
@@ -154,16 +159,17 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
154
159
  :type service_url: str
155
160
  :param audience: A value signifying the recipient of the proactive message.
156
161
  :type audience: str
157
- :param conversation_parameters: The information to use to create the conversation
162
+ :param conversation_parameters: The information to use to create the conversation.
158
163
  :type conversation_parameters: :class:`microsoft_agents.activity.ConversationParameters`
159
164
  :param callback: The method to call for the resulting agent turn.
160
165
  :type callback: Callable[[microsoft_agents.hosting.core.turn_context.TurnContext], Awaitable]
161
166
 
162
- :raises: Exception - Not implemented or when the implementation fails.
167
+ :raises Exception: Not implemented or when the implementation fails.
163
168
 
164
169
  :return: A task representing the work queued to execute.
170
+ :rtype: typing.Any
165
171
 
166
- .. remarks::
172
+ .. note::
167
173
  To start a conversation, your agent must know its account information and the user's
168
174
  account information on that channel.
169
175
  Most channels only support initiating a direct message (non-group) conversation.
@@ -225,7 +231,8 @@ class ChannelAdapter(ABC, ChannelAdapterProtocol):
225
231
  :type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
226
232
  :param callback: A callback method to run at the end of the pipeline.
227
233
  :type callback: Callable[[TurnContext], Awaitable]
228
- :return:
234
+ :return: Result produced by the middleware pipeline.
235
+ :rtype: typing.Any
229
236
  """
230
237
  if context is None:
231
238
  raise TypeError(context.__class__.__name__)
@@ -358,13 +358,13 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
358
358
  :return: A task that represents the work queued to execute.
359
359
  :rtype: Optional[:class:`microsoft_agents.activity.InvokeResponse`]
360
360
 
361
- .. remarks::
361
+ .. note::
362
362
  This class processes an activity received by the agents web server. This includes any messages
363
363
  sent from a user and is the method that drives what's often referred to as the
364
364
  agent *reactive messaging* flow.
365
365
  Call this method to reactively send a message to a conversation.
366
- If the task completes successfully, then an :class:`InvokeResponse` is returned;
367
- otherwise, `null` is returned.
366
+ If the task completes successfully, then an :class:`microsoft_agents.activity.InvokeResponse` is returned;
367
+ otherwise, `None` is returned.
368
368
  """
369
369
  scopes: list[str] = None
370
370
  outgoing_audience: str = None
@@ -493,7 +493,14 @@ class ChannelServiceAdapter(ChannelAdapter, ABC):
493
493
 
494
494
  return context
495
495
 
496
- def _process_turn_results(self, context: TurnContext) -> InvokeResponse:
496
+ def _process_turn_results(self, context: TurnContext) -> Optional[InvokeResponse]:
497
+ """Process the results of a turn and return the appropriate response.
498
+
499
+ :param context: The turn context
500
+ :type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
501
+ :return: The invoke response, if applicable
502
+ :rtype: Optional[:class:`microsoft_agents.activity.InvokeResponse`]
503
+ """
497
504
  # Handle ExpectedReplies scenarios where all activities have been
498
505
  # buffered and sent back at once in an invoke response.
499
506
  if context.activity.delivery_mode == DeliveryModes.expect_replies:
@@ -74,11 +74,13 @@ class AttachmentsOperations(AttachmentsBase):
74
74
 
75
75
  url = f"v3/attachments/{attachment_id}"
76
76
 
77
- logger.info(f"Getting attachment info for ID: {attachment_id}")
77
+ logger.info("Getting attachment info for ID: %s", attachment_id)
78
78
  async with self.client.get(url) as response:
79
- if response.status >= 400:
79
+ if response.status >= 300:
80
80
  logger.error(
81
- f"Error getting attachment info: {response.status}", stack_info=True
81
+ "Error getting attachment info: %s",
82
+ response.status,
83
+ stack_info=True,
82
84
  )
83
85
  response.raise_for_status()
84
86
 
@@ -108,11 +110,13 @@ class AttachmentsOperations(AttachmentsBase):
108
110
 
109
111
  url = f"v3/attachments/{attachment_id}/views/{view_id}"
110
112
 
111
- logger.info(f"Getting attachment for ID: {attachment_id}, View ID: {view_id}")
113
+ logger.info(
114
+ "Getting attachment for ID: %s, View ID: %s", attachment_id, view_id
115
+ )
112
116
  async with self.client.get(url) as response:
113
- if response.status >= 400:
117
+ if response.status >= 300:
114
118
  logger.error(
115
- f"Error getting attachment: {response.status}", stack_info=True
119
+ "Error getting attachment: %s", response.status, stack_info=True
116
120
  )
117
121
  response.raise_for_status()
118
122
 
@@ -143,12 +147,12 @@ class ConversationsOperations(ConversationsBase):
143
147
  )
144
148
 
145
149
  logger.info(
146
- f"Getting conversations with continuation token: {continuation_token}"
150
+ "Getting conversations with continuation token: %s", continuation_token
147
151
  )
148
152
  async with self.client.get("v3/conversations", params=params) as response:
149
- if response.status >= 400:
153
+ if response.status >= 300:
150
154
  logger.error(
151
- f"Error getting conversations: {response.status}", stack_info=True
155
+ "Error getting conversations: %s", response.status, stack_info=True
152
156
  )
153
157
  response.raise_for_status()
154
158
 
@@ -170,9 +174,9 @@ class ConversationsOperations(ConversationsBase):
170
174
  "v3/conversations",
171
175
  json=body.model_dump(by_alias=True, exclude_unset=True, mode="json"),
172
176
  ) as response:
173
- if response.status >= 400:
177
+ if response.status >= 300:
174
178
  logger.error(
175
- f"Error creating conversation: {response.status}", stack_info=True
179
+ "Error creating conversation: %s", response.status, stack_info=True
176
180
  )
177
181
  response.raise_for_status()
178
182
 
@@ -201,7 +205,10 @@ class ConversationsOperations(ConversationsBase):
201
205
  url = f"v3/conversations/{conversation_id}/activities/{activity_id}"
202
206
 
203
207
  logger.info(
204
- f"Replying to activity: {activity_id} in conversation: {conversation_id}. Activity type is {body.type}"
208
+ "Replying to activity: %s in conversation: %s. Activity type is %s",
209
+ activity_id,
210
+ conversation_id,
211
+ body.type,
205
212
  )
206
213
 
207
214
  async with self.client.post(
@@ -212,15 +219,16 @@ class ConversationsOperations(ConversationsBase):
212
219
  ) as response:
213
220
  result = await response.json() if response.content_length else {}
214
221
 
215
- if response.status >= 400:
222
+ if response.status >= 300:
216
223
  logger.error(
217
- f"Error replying to activity: {result or response.status}",
224
+ "Error replying to activity: %s",
225
+ result or response.status,
218
226
  stack_info=True,
219
227
  )
220
228
  response.raise_for_status()
221
229
 
222
230
  logger.info(
223
- f"Reply to conversation/activity: {result.get('id')}, {activity_id}"
231
+ "Reply to conversation/activity: %s, %s", result.get("id"), activity_id
224
232
  )
225
233
 
226
234
  return ResourceResponse.model_validate(result)
@@ -246,15 +254,19 @@ class ConversationsOperations(ConversationsBase):
246
254
  url = f"v3/conversations/{conversation_id}/activities"
247
255
 
248
256
  logger.info(
249
- f"Sending to conversation: {conversation_id}. Activity type is {body.type}"
257
+ "Sending to conversation: %s. Activity type is %s",
258
+ conversation_id,
259
+ body.type,
250
260
  )
251
261
  async with self.client.post(
252
262
  url,
253
263
  json=body.model_dump(by_alias=True, exclude_unset=True, mode="json"),
254
264
  ) as response:
255
- if response.status >= 400:
265
+ if response.status >= 300:
256
266
  logger.error(
257
- f"Error sending to conversation: {response.status}", stack_info=True
267
+ "Error sending to conversation: %s",
268
+ response.status,
269
+ stack_info=True,
258
270
  )
259
271
  response.raise_for_status()
260
272
 
@@ -283,15 +295,18 @@ class ConversationsOperations(ConversationsBase):
283
295
  url = f"v3/conversations/{conversation_id}/activities/{activity_id}"
284
296
 
285
297
  logger.info(
286
- f"Updating activity: {activity_id} in conversation: {conversation_id}. Activity type is {body.type}"
298
+ "Updating activity: %s in conversation: %s. Activity type is %s",
299
+ activity_id,
300
+ conversation_id,
301
+ body.type,
287
302
  )
288
303
  async with self.client.put(
289
304
  url,
290
305
  json=body.model_dump(by_alias=True, exclude_unset=True),
291
306
  ) as response:
292
- if response.status >= 400:
307
+ if response.status >= 300:
293
308
  logger.error(
294
- f"Error updating activity: {response.status}", stack_info=True
309
+ "Error updating activity: %s", response.status, stack_info=True
295
310
  )
296
311
  response.raise_for_status()
297
312
 
@@ -316,12 +331,14 @@ class ConversationsOperations(ConversationsBase):
316
331
  url = f"v3/conversations/{conversation_id}/activities/{activity_id}"
317
332
 
318
333
  logger.info(
319
- f"Deleting activity: {activity_id} from conversation: {conversation_id}"
334
+ "Deleting activity: %s from conversation: %s",
335
+ activity_id,
336
+ conversation_id,
320
337
  )
321
338
  async with self.client.delete(url) as response:
322
- if response.status >= 400:
339
+ if response.status >= 300:
323
340
  logger.error(
324
- f"Error deleting activity: {response.status}", stack_info=True
341
+ "Error deleting activity: %s", response.status, stack_info=True
325
342
  )
326
343
  response.raise_for_status()
327
344
 
@@ -354,12 +371,14 @@ class ConversationsOperations(ConversationsBase):
354
371
  }
355
372
 
356
373
  logger.info(
357
- f"Uploading attachment to conversation: {conversation_id}, Attachment name: {body.name}"
374
+ "Uploading attachment to conversation: %s, Attachment name: %s",
375
+ conversation_id,
376
+ body.name,
358
377
  )
359
378
  async with self.client.post(url, json=attachment_dict) as response:
360
- if response.status >= 400:
379
+ if response.status >= 300:
361
380
  logger.error(
362
- f"Error uploading attachment: {response.status}", stack_info=True
381
+ "Error uploading attachment: %s", response.status, stack_info=True
363
382
  )
364
383
  response.raise_for_status()
365
384
 
@@ -385,11 +404,14 @@ class ConversationsOperations(ConversationsBase):
385
404
  conversation_id = self._normalize_conversation_id(conversation_id)
386
405
  url = f"v3/conversations/{conversation_id}/members"
387
406
 
388
- logger.info(f"Getting conversation members for conversation: {conversation_id}")
407
+ logger.info(
408
+ "Getting conversation members for conversation: %s", conversation_id
409
+ )
389
410
  async with self.client.get(url) as response:
390
- if response.status >= 400:
411
+ if response.status >= 300:
391
412
  logger.error(
392
- f"Error getting conversation members: {response.status}",
413
+ "Error getting conversation members: %s",
414
+ response.status,
393
415
  stack_info=True,
394
416
  )
395
417
  response.raise_for_status()
@@ -418,12 +440,15 @@ class ConversationsOperations(ConversationsBase):
418
440
  url = f"v3/conversations/{conversation_id}/members/{member_id}"
419
441
 
420
442
  logger.info(
421
- f"Getting conversation member: {member_id} from conversation: {conversation_id}"
443
+ "Getting conversation member: %s from conversation: %s",
444
+ member_id,
445
+ conversation_id,
422
446
  )
423
447
  async with self.client.get(url) as response:
424
- if response.status >= 400:
448
+ if response.status >= 300:
425
449
  logger.error(
426
- f"Error getting conversation member: {response.status}",
450
+ "Error getting conversation member: %s",
451
+ response.status,
427
452
  stack_info=True,
428
453
  )
429
454
  response.raise_for_status()
@@ -451,12 +476,15 @@ class ConversationsOperations(ConversationsBase):
451
476
  url = f"v3/conversations/{conversation_id}/members/{member_id}"
452
477
 
453
478
  logger.info(
454
- f"Deleting conversation member: {member_id} from conversation: {conversation_id}"
479
+ "Deleting conversation member: %s from conversation: %s",
480
+ member_id,
481
+ conversation_id,
455
482
  )
456
483
  async with self.client.delete(url) as response:
457
- if response.status >= 400 and response.status != 204:
484
+ if response.status >= 300:
458
485
  logger.error(
459
- f"Error deleting conversation member: {response.status}",
486
+ "Error deleting conversation member: %s",
487
+ response.status,
460
488
  stack_info=True,
461
489
  )
462
490
  response.raise_for_status()
@@ -482,12 +510,15 @@ class ConversationsOperations(ConversationsBase):
482
510
  url = f"v3/conversations/{conversation_id}/activities/{activity_id}/members"
483
511
 
484
512
  logger.info(
485
- f"Getting activity members for conversation: {conversation_id}, Activity ID: {activity_id}"
513
+ "Getting activity members for conversation: %s, Activity ID: %s",
514
+ conversation_id,
515
+ activity_id,
486
516
  )
487
517
  async with self.client.get(url) as response:
488
- if response.status >= 400:
518
+ if response.status >= 300:
489
519
  logger.error(
490
- f"Error getting activity members: {response.status}",
520
+ "Error getting activity members: %s",
521
+ response.status,
491
522
  stack_info=True,
492
523
  )
493
524
  response.raise_for_status()
@@ -526,12 +557,16 @@ class ConversationsOperations(ConversationsBase):
526
557
  url = f"v3/conversations/{conversation_id}/pagedmembers"
527
558
 
528
559
  logger.info(
529
- f"Getting paged members for conversation: {conversation_id}, Page Size: {page_size}, Continuation Token: {continuation_token}"
560
+ "Getting paged members for conversation: %s, Page Size: %s, Continuation Token: %s",
561
+ conversation_id,
562
+ page_size,
563
+ continuation_token,
530
564
  )
531
565
  async with self.client.get(url, params=params) as response:
532
- if response.status >= 400:
566
+ if response.status >= 300:
533
567
  logger.error(
534
- f"Error getting conversation paged members: {response.status}",
568
+ "Error getting conversation paged members: %s",
569
+ response.status,
535
570
  stack_info=True,
536
571
  )
537
572
  response.raise_for_status()
@@ -559,15 +594,12 @@ class ConversationsOperations(ConversationsBase):
559
594
  conversation_id = self._normalize_conversation_id(conversation_id)
560
595
  url = f"v3/conversations/{conversation_id}/activities/history"
561
596
 
562
- logger.info(f"Sending conversation history to conversation: {conversation_id}")
597
+ logger.info("Sending conversation history to conversation: %s", conversation_id)
563
598
  async with self.client.post(url, json=body) as response:
564
- if (
565
- response.status >= 400
566
- and response.status != 201
567
- and response.status != 202
568
- ):
599
+ if response.status >= 300:
569
600
  logger.error(
570
- f"Error sending conversation history: {response.status}",
601
+ "Error sending conversation history: %s",
602
+ response.status,
571
603
  stack_info=True,
572
604
  )
573
605
  response.raise_for_status()
@@ -602,7 +634,9 @@ class ConnectorClient(ConnectorClientBase):
602
634
  headers=headers,
603
635
  )
604
636
  logger.debug(
605
- f"ConnectorClient initialized with endpoint: {endpoint} and headers: {headers}"
637
+ "ConnectorClient initialized with endpoint: %s and headers: %s",
638
+ endpoint,
639
+ headers,
606
640
  )
607
641
 
608
642
  if len(token) > 1:
@@ -53,13 +53,14 @@ class AgentSignIn(AgentSignInBase):
53
53
  params["finalRedirect"] = final_redirect
54
54
 
55
55
  logger.info(
56
- f"AgentSignIn.get_sign_in_url(): Getting sign-in URL with params: {params}"
56
+ "AgentSignIn.get_sign_in_url(): Getting sign-in URL with params: %s",
57
+ params,
57
58
  )
58
59
  async with self.client.get(
59
60
  "api/agentsignin/getSignInUrl", params=params
60
61
  ) as response:
61
- if response.status >= 400:
62
- logger.error(f"Error getting sign-in URL: {response.status}")
62
+ if response.status >= 300:
63
+ logger.error("Error getting sign-in URL: %s", response.status)
63
64
  response.raise_for_status()
64
65
 
65
66
  return await response.text()
@@ -89,13 +90,14 @@ class AgentSignIn(AgentSignInBase):
89
90
  params["finalRedirect"] = final_redirect
90
91
 
91
92
  logger.info(
92
- f"AgentSignIn.get_sign_in_resource(): Getting sign-in resource with params: {params}"
93
+ "AgentSignIn.get_sign_in_resource(): Getting sign-in resource with params: %s",
94
+ params,
93
95
  )
94
96
  async with self.client.get(
95
97
  "api/botsignin/getSignInResource", params=params
96
98
  ) as response:
97
- if response.status >= 400:
98
- logger.error(f"Error getting sign-in resource: {response.status}")
99
+ if response.status >= 300:
100
+ logger.error("Error getting sign-in resource: %s", response.status)
99
101
  response.raise_for_status()
100
102
 
101
103
  data = await response.json()
@@ -122,12 +124,10 @@ class UserToken(UserTokenBase):
122
124
  if code:
123
125
  params["code"] = code
124
126
 
125
- logger.info(f"User_token.get_token(): Getting token with params: {params}")
127
+ logger.info("User_token.get_token(): Getting token with params: %s", params)
126
128
  async with self.client.get("api/usertoken/GetToken", params=params) as response:
127
- if response.status == 404:
128
- return TokenResponse(model_validate={})
129
- if response.status >= 400:
130
- logger.error(f"Error getting token: {response.status}")
129
+ if response.status >= 300:
130
+ logger.error("Error getting token: %s", response.status)
131
131
  response.raise_for_status()
132
132
 
133
133
  data = await response.json()
@@ -179,12 +179,12 @@ class UserToken(UserTokenBase):
179
179
  if channel_id:
180
180
  params["channelId"] = channel_id
181
181
 
182
- logger.info(f"Getting AAD tokens with params: {params} and body: {body}")
182
+ logger.info("Getting AAD tokens with params: %s and body: %s", params, body)
183
183
  async with self.client.post(
184
184
  "api/usertoken/GetAadTokens", params=params, json=body
185
185
  ) as response:
186
- if response.status >= 400:
187
- logger.error(f"Error getting AAD tokens: {response.status}")
186
+ if response.status >= 300:
187
+ logger.error("Error getting AAD tokens: %s", response.status)
188
188
  response.raise_for_status()
189
189
 
190
190
  data = await response.json()
@@ -203,12 +203,12 @@ class UserToken(UserTokenBase):
203
203
  if channel_id:
204
204
  params["channelId"] = channel_id
205
205
 
206
- logger.info(f"Signing out user {user_id} with params: {params}")
206
+ logger.info("Signing out user %s with params: %s", user_id, params)
207
207
  async with self.client.delete(
208
208
  "api/usertoken/SignOut", params=params
209
209
  ) as response:
210
- if response.status >= 400 and response.status != 204:
211
- logger.error(f"Error signing out: {response.status}")
210
+ if response.status >= 300:
211
+ logger.error("Error signing out: %s", response.status)
212
212
  response.raise_for_status()
213
213
 
214
214
  async def get_token_status(
@@ -224,12 +224,12 @@ class UserToken(UserTokenBase):
224
224
  if include:
225
225
  params["include"] = include
226
226
 
227
- logger.info(f"Getting token status for user {user_id} with params: {params}")
227
+ logger.info("Getting token status for user %s with params: %s", user_id, params)
228
228
  async with self.client.get(
229
229
  "api/usertoken/GetTokenStatus", params=params
230
230
  ) as response:
231
- if response.status >= 400:
232
- logger.error(f"Error getting token status: {response.status}")
231
+ if response.status >= 300:
232
+ logger.error("Error getting token status: %s", response.status)
233
233
  response.raise_for_status()
234
234
 
235
235
  data = await response.json()
@@ -248,12 +248,12 @@ class UserToken(UserTokenBase):
248
248
  "channelId": channel_id,
249
249
  }
250
250
 
251
- logger.info(f"Exchanging token with params: {params} and body: {body}")
251
+ logger.info("Exchanging token with params: %s and body: %s", params, body)
252
252
  async with self.client.post(
253
253
  "api/usertoken/exchange", params=params, json=body
254
254
  ) as response:
255
- if response.status >= 400 and response.status != 404:
256
- logger.error(f"Error exchanging token: {response.status}")
255
+ if response.status >= 300:
256
+ logger.error("Error exchanging token: %s", response.status)
257
257
  response.raise_for_status()
258
258
 
259
259
  data = await response.json()
@@ -289,7 +289,9 @@ class UserTokenClient(UserTokenClientBase):
289
289
  headers=headers,
290
290
  )
291
291
  logger.debug(
292
- f"Creating UserTokenClient with endpoint: {endpoint} and headers: {headers}"
292
+ "Creating UserTokenClient with endpoint: %s and headers: %s",
293
+ endpoint,
294
+ headers,
293
295
  )
294
296
 
295
297
  if len(token) > 1:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: microsoft-agents-hosting-core
3
- Version: 0.6.0.dev1
3
+ Version: 0.6.0.dev7
4
4
  Summary: Core library for Microsoft Agents
5
5
  Author: Microsoft Corporation
6
6
  License-Expression: MIT
@@ -15,7 +15,7 @@ Classifier: Operating System :: OS Independent
15
15
  Requires-Python: >=3.10
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
- Requires-Dist: microsoft-agents-activity==0.6.0.dev1
18
+ Requires-Dist: microsoft-agents-activity==0.6.0.dev7
19
19
  Requires-Dist: pyjwt>=2.10.1
20
20
  Requires-Dist: isodate>=0.6.1
21
21
  Requires-Dist: azure-core>=1.30.0
@@ -1,10 +1,10 @@
1
1
  microsoft_agents/hosting/core/__init__.py,sha256=EN6Et-e7n5n_nhXy5ZKNiRtjMfEgWkoNri_gk8KEYLw,4862
2
- microsoft_agents/hosting/core/activity_handler.py,sha256=JTzKnT-9yJpTQpiCxJNXrXe1Z9NKt0egofV0NLlJZy0,27082
2
+ microsoft_agents/hosting/core/activity_handler.py,sha256=1hsSmVCnQLS44RK05v8j6mlmV38_JGmJTPR9LkogQuc,27779
3
3
  microsoft_agents/hosting/core/agent.py,sha256=K8v84y8ULP7rbcMKg8LxaM3haAq7f1oHFCLy3AAphQE,574
4
4
  microsoft_agents/hosting/core/card_factory.py,sha256=UDmPEpOk2SpEr9ShN9Q0CiaI_GTD3qjHgkDMOWinW9I,6926
5
- microsoft_agents/hosting/core/channel_adapter.py,sha256=LVHSueET6kzv-N_OCdl3F0yL4-OvZCMKMsj5tpPzZD0,10396
5
+ microsoft_agents/hosting/core/channel_adapter.py,sha256=MqES9gHGS0nrKBR7u8zLQCsuIksl-hScZy_jg4LTTHo,10669
6
6
  microsoft_agents/hosting/core/channel_api_handler_protocol.py,sha256=RO59hiOYx7flQVWhX6VGvfpFPoKVkdT_la-7WhUl8UM,4506
7
- microsoft_agents/hosting/core/channel_service_adapter.py,sha256=MmnEy4350udEffCNfr8foE8VScKmrYnSmoXh_Ghoqvg,20480
7
+ microsoft_agents/hosting/core/channel_service_adapter.py,sha256=dd3hKtU23V0D3HLpERTVJejGRZZ7CksFLjRB7FrurmQ,20860
8
8
  microsoft_agents/hosting/core/channel_service_client_factory_base.py,sha256=ArMAUt84Kzq17Oyqz6o8HZrc01UqAAmNCSBTShv3rgk,1704
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
@@ -16,12 +16,12 @@ microsoft_agents/hosting/core/_oauth/_flow_storage_client.py,sha256=1MLD8m_qw0jS
16
16
  microsoft_agents/hosting/core/_oauth/_oauth_flow.py,sha256=vgg_sQLYr83YA0F7aQ1K5j8vEATw7ZS151ODkpCGYAM,12211
17
17
  microsoft_agents/hosting/core/app/__init__.py,sha256=GZQdog7BBMA8uD9iaRMNeRJf12rJZB3bAKFAD8Y8dVo,1228
18
18
  microsoft_agents/hosting/core/app/_type_defs.py,sha256=b5VZFWnQ5ONUZMtFxw7Q-mbbxIUSJ7RXcCXjqdHwSQw,438
19
- microsoft_agents/hosting/core/app/agent_application.py,sha256=yYAVFkn4VWO5ZzrXdGFR4UheYMD5xP28HCxWPeJz8wA,31560
19
+ microsoft_agents/hosting/core/app/agent_application.py,sha256=HEOYRgpT9iN_YRu8MbV--O8yoOiz3CquB9ZGjQ1_fX0,33996
20
20
  microsoft_agents/hosting/core/app/app_error.py,sha256=JgYBgv2EKe9Q2TFi5FeG_RneulBEa5SyBpWSF-duBzE,301
21
21
  microsoft_agents/hosting/core/app/app_options.py,sha256=P3XTFFuQCnEcHixfdmr5RPG-Wli4c1VSmCMRKVBBLsw,2792
22
22
  microsoft_agents/hosting/core/app/input_file.py,sha256=AEzVAnAPO1V7MWDI_uoZfcYY8Oog3XgvEpAeO-tATeY,1546
23
23
  microsoft_agents/hosting/core/app/query.py,sha256=lToDWFG7exUyPC5zxvna89013fDPKrUGOI8jyWFoUYk,328
24
- microsoft_agents/hosting/core/app/typing_indicator.py,sha256=LwwuSJC2KXclO6GkSg0P80MUsf6ClQFzOyx3SSI9Yd0,2460
24
+ microsoft_agents/hosting/core/app/typing_indicator.py,sha256=L4zEqDHeu_0JmpDQwaB-j84TFLYzUAH0-tFUEfOxD0g,2442
25
25
  microsoft_agents/hosting/core/app/_routes/__init__.py,sha256=faz05Hk5Z1IGIXUwXljohym0lzE8nW3CbTpXlE-VcB0,300
26
26
  microsoft_agents/hosting/core/app/_routes/_route.py,sha256=gs5XVi74H1wzDShpZd9ZXVDrREjricFYVPz10XrK06c,2669
27
27
  microsoft_agents/hosting/core/app/_routes/_route_list.py,sha256=fe1-wmFaJJqYkWFcbNhJ9OMH954TneQR0-uoxyKQVlU,874
@@ -37,7 +37,7 @@ microsoft_agents/hosting/core/app/oauth/_handlers/_user_authorization.py,sha256=
37
37
  microsoft_agents/hosting/core/app/oauth/_handlers/agentic_user_authorization.py,sha256=4EgZxSMoymgap54xhoEQH0UIEBap-mMCiP6eFeanr3A,7253
38
38
  microsoft_agents/hosting/core/app/state/__init__.py,sha256=aL_8GB7_de8LUSEOgTJQFRx1kvgvJHHJVv7nWAoRPmU,331
39
39
  microsoft_agents/hosting/core/app/state/conversation_state.py,sha256=LfcSwvhaU0JeAahwg9YA9uz0kKHa9c6Y3XBAWqwuMg0,1593
40
- microsoft_agents/hosting/core/app/state/state.py,sha256=Q1GMGTdIGpu5Z4_6HPCfhJaD265oBlv6DMNNBCUyG3U,7372
40
+ microsoft_agents/hosting/core/app/state/state.py,sha256=mbNrHuAc7d9vJep3PtExbLFtfKxZoAUX3Jr45GT3SuA,7373
41
41
  microsoft_agents/hosting/core/app/state/temp_state.py,sha256=Oh7K5-uYf50Z-lBXqttSMl2N1lRakktOmjLlIAKcEsM,3501
42
42
  microsoft_agents/hosting/core/app/state/turn_state.py,sha256=rEIRkwBsn3MPbrfKNjX8XqqbF-4THepMXU75KvDsBvM,9868
43
43
  microsoft_agents/hosting/core/authorization/__init__.py,sha256=pOTmTJFS5CMPEcHRadBTgrbWUP5lOIxsPMgTreFq7mw,634
@@ -72,8 +72,8 @@ microsoft_agents/hosting/core/connector/get_product_info.py,sha256=SDxPqBCzzQLEU
72
72
  microsoft_agents/hosting/core/connector/user_token_base.py,sha256=h_l5D1SghN2RrUkFcKWQhCHlO9r7akMbzsm2x8MvomI,3639
73
73
  microsoft_agents/hosting/core/connector/user_token_client_base.py,sha256=dfUTUsBNOzWze9_JldAeLe73sydSDzlKyMKMvj48g2E,471
74
74
  microsoft_agents/hosting/core/connector/client/__init__.py,sha256=6JdKhmm7btmo0omxMBd8PJbtGFk0cnMwVUoStyW7Ft0,143
75
- microsoft_agents/hosting/core/connector/client/connector_client.py,sha256=nnKlXw98lB_eoTYMaHKc7PtxSKW3G6jUxCPFe4pdjSI,23398
76
- microsoft_agents/hosting/core/connector/client/user_token_client.py,sha256=1ey1mqV7pkC94Xl36PVrx5TOyumJQbpscbm2W9uvpHs,10609
75
+ microsoft_agents/hosting/core/connector/client/connector_client.py,sha256=9oF_x_LffOIKjTLMdPf3Biq3vvWn8r8e0NBJkHBn684,23866
76
+ microsoft_agents/hosting/core/connector/client/user_token_client.py,sha256=qxYxvdUcvYinCzaR4YiIucEEAb8TjYYtPsmXKZRbxv4,10536
77
77
  microsoft_agents/hosting/core/connector/teams/__init__.py,sha256=3ZMPGYyZ15EwvfQzfJJQy1J58oIt4InSxibl3BN6R54,100
78
78
  microsoft_agents/hosting/core/connector/teams/teams_connector_client.py,sha256=XGQDTYHrA_I9n9JlxGST5eesjsFhz2dnSaMSuyoFnKU,12676
79
79
  microsoft_agents/hosting/core/state/__init__.py,sha256=yckKi1wg_86ng-DL9Q3R49QiWKvNjPkVNk6HClWgVrY,208
@@ -91,8 +91,8 @@ microsoft_agents/hosting/core/storage/transcript_info.py,sha256=5VN32j99tshChAff
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.6.0.dev1.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
95
- microsoft_agents_hosting_core-0.6.0.dev1.dist-info/METADATA,sha256=GRwuK6xdOr9EXJkpShfKkQtqJEVaK7tH9N8OsRzHCdc,9242
96
- microsoft_agents_hosting_core-0.6.0.dev1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
97
- microsoft_agents_hosting_core-0.6.0.dev1.dist-info/top_level.txt,sha256=lWKcT4v6fTA_NgsuHdNvuMjSrkiBMXohn64ApY7Xi8A,17
98
- microsoft_agents_hosting_core-0.6.0.dev1.dist-info/RECORD,,
94
+ microsoft_agents_hosting_core-0.6.0.dev7.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
95
+ microsoft_agents_hosting_core-0.6.0.dev7.dist-info/METADATA,sha256=rle5DL5vG-Pep7T_qcZN8hahOZjzqUxK3NeS_4KfwMQ,9242
96
+ microsoft_agents_hosting_core-0.6.0.dev7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
97
+ microsoft_agents_hosting_core-0.6.0.dev7.dist-info/top_level.txt,sha256=lWKcT4v6fTA_NgsuHdNvuMjSrkiBMXohn64ApY7Xi8A,17
98
+ microsoft_agents_hosting_core-0.6.0.dev7.dist-info/RECORD,,