-
Notifications
You must be signed in to change notification settings - Fork 81
Improved Teams support with microsoft-agents-hosting-msteams package #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rodrigobr-msft
wants to merge
52
commits into
main
Choose a base branch
from
users/robrandao/msteams
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
1bfd426
Updating typing annotations
rodrigobr-msft c8a4dfa
Another commit
rodrigobr-msft 05f00e7
Separating route hubs
rodrigobr-msft 4290f74
Adding file consent routes
rodrigobr-msft 7537bc2
Adding refactored configuration routes
rodrigobr-msft 50867ec
Refactor Team routes
rodrigobr-msft 130b7ab
Cleaned up TeamsAgentExtension
rodrigobr-msft f3d1b31
Removing duplicate logic
rodrigobr-msft c0ed7b0
Cleaning up extension and adding new route handler protocol for Handoff
rodrigobr-msft b04bcaa
Addressing merge conflicts
rodrigobr-msft d1a4371
Further cleanup and formatting
rodrigobr-msft 22a280e
Fixing teams models imports
rodrigobr-msft 7a37f95
Adding direct decorator support for route hooks without positional ar…
rodrigobr-msft 5758dac
Adding missing route hooks
rodrigobr-msft a11e18a
Adding _StateContra for proper route handler definitions
rodrigobr-msft 9ff8559
Revisions to TeamsInfo file
rodrigobr-msft c166ca9
Adding targeted activity functionality to TeamsTurnContext
rodrigobr-msft dc0e763
Modification to test sample
rodrigobr-msft d1f9c5d
Adding back in ActivityHandler extension and fixing TeamsInfo tests
rodrigobr-msft 97b8aed
Authorization.connection_manager
rodrigobr-msft 1981797
renaming teams to msteams
rodrigobr-msft 5fc9e37
Renaming teams to msteams
rodrigobr-msft d933753
Resolving merge conflicts
rodrigobr-msft f663e4c
Another commit
rodrigobr-msft ec17f2c
Merge branch 'main' of https://github.com/microsoft/Agents-for-python…
rodrigobr-msft 6349c6c
Revising ApiClient setting
rodrigobr-msft 0495df0
Adding TeamsActivity static helper
rodrigobr-msft 8642094
Graph service client creation
rodrigobr-msft 6bbcdc5
client getters
rodrigobr-msft 5be4b3f
Adding TeamsActivity connection
rodrigobr-msft 2390f12
Bug fixes
rodrigobr-msft 33e2bf3
Fixing unit tests
rodrigobr-msft d87e2b2
Adding routing integration tests
rodrigobr-msft f575e59
Updating package README and minor bug
rodrigobr-msft ac41caf
github workflow edit
rodrigobr-msft 633d143
Updating documentation
rodrigobr-msft 5615194
Addressing PR feedback
rodrigobr-msft e253f51
Removing test case
rodrigobr-msft 1fb93c4
Updating azdo
rodrigobr-msft 65baedc
UPdating conversation agent
rodrigobr-msft f3d0964
Reorganizing test_samples
rodrigobr-msft e629ed8
Finalizing msteams test samples
rodrigobr-msft 0165bda
another commit
rodrigobr-msft c98f732
Addressing PR feedback
rodrigobr-msft 10ec558
Potential fix for pull request finding
rodrigobr-msft b658058
Potential fix for pull request finding
rodrigobr-msft f49f748
Small fixes to typing annotations
rodrigobr-msft defde2b
Merge branch 'users/robrandao/msteams' of https://github.com/microsof…
rodrigobr-msft 4bd55eb
Better sync of TeamsTurnContext
rodrigobr-msft 26d1bbc
Merge branch 'main' into users/robrandao/msteams
rodrigobr-msft 5bcc591
Replacing ChannelData with TeamInfo and ChannelInfo in route handlers
rodrigobr-msft 908dae7
erge branch 'users/robrandao/msteams' of https://github.com/microsoft…
rodrigobr-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
libraries/microsoft-agents-activity/microsoft_agents/activity/entity/activity_treatment.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| from enum import Enum | ||
| from typing import Literal | ||
|
|
||
| from .entity import Entity | ||
| from .entity_types import EntityTypes | ||
|
|
||
|
|
||
| class ActivityTreatmentTypes(str, Enum): | ||
| """Well-known enumeration of activity treatment types.""" | ||
|
|
||
| TARGETED = "targeted" | ||
|
|
||
|
|
||
| class ActivityTreatment(Entity): | ||
| """Activity treatment information (entity type: "activityTreatment"). | ||
|
|
||
| :param treatment: The type of treatment | ||
| :type treatment: ~microsoft_agents.activity.ActivityTreatmentTypes | ||
| :param type: Type of this entity (RFC 3987 IRI) | ||
| :type type: str | ||
| """ | ||
|
|
||
| type: Literal[EntityTypes.ACTIVITY_TREATMENT] = EntityTypes.ACTIVITY_TREATMENT | ||
| treatment: ActivityTreatmentTypes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
39 changes: 39 additions & 0 deletions
39
libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| """Microsoft 365 Agents SDK -- Microsoft Teams hosting extension. | ||
|
|
||
| This package layers Teams-specific functionality on top of an | ||
| :class:`~microsoft_agents.hosting.core.AgentApplication`. Its entry point is | ||
| :class:`TeamsAgentExtension`, which exposes namespaced route registration for | ||
| Teams events (channels, teams, meetings, messages, message extensions, task | ||
| modules, configuration, and file consent). It also provides the Teams-aware | ||
| :class:`TeamsTurnContext` and :class:`TeamsActivity` helpers. | ||
| """ | ||
|
|
||
| from .teams_agent_extension import TeamsAgentExtension | ||
| from .channel import Channel | ||
| from .config import Config | ||
| from .file_consent import FileConsent | ||
| from .meeting import Meeting | ||
| from .message import Message | ||
| from .message_extension import MessageExtension | ||
| from .task_module import TaskModule | ||
| from .team import Team | ||
|
|
||
| from .teams_activity import TeamsActivity | ||
| from .teams_turn_context import TeamsTurnContext | ||
|
|
||
| __all__ = [ | ||
| "TeamsAgentExtension", | ||
| "Channel", | ||
| "Config", | ||
| "FileConsent", | ||
| "Meeting", | ||
| "Message", | ||
| "MessageExtension", | ||
| "TaskModule", | ||
| "Team", | ||
| "TeamsActivity", | ||
| "TeamsTurnContext", | ||
| ] |
86 changes: 86 additions & 0 deletions
86
libraries/microsoft-agents-hosting-msteams/microsoft_agents/hosting/msteams/_graph.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| """Microsoft Graph client integration for the Teams hosting layer. | ||
|
|
||
| Builds a :class:`msgraph.GraphServiceClient` whose requests are authenticated | ||
| with tokens obtained from the agent's configured authorization, so handlers can | ||
| call Microsoft Graph on behalf of the current turn. | ||
| """ | ||
|
|
||
| from typing import Any | ||
|
|
||
| from kiota_abstractions.request_information import RequestInformation | ||
| from kiota_abstractions.authentication import AuthenticationProvider | ||
|
|
||
| from msgraph import GraphServiceClient, GraphRequestAdapter | ||
|
|
||
| from microsoft_agents.hosting.core import ( | ||
| AgentApplication, | ||
| TurnContext, | ||
| ) | ||
|
|
||
|
|
||
| class _SDKAuthenticationProvider(AuthenticationProvider): | ||
| """Kiota authentication provider backed by the agent's authorization. | ||
|
|
||
| Acquires an access token for the current turn via | ||
| :meth:`AgentApplication.auth.get_token` and attaches it to outgoing Graph | ||
| requests as a bearer token. | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| app: AgentApplication, | ||
| context: TurnContext, | ||
| handler_name: str | None = None, | ||
| ): | ||
| """Capture the context needed to resolve a token at request time. | ||
|
|
||
| :param app: The agent application whose authorization issues tokens. | ||
| :param context: The current turn context. | ||
| :param handler_name: The auth handler name used to acquire the token. | ||
| """ | ||
| self._app = app | ||
| self._context = context | ||
| self._handler_name = handler_name | ||
|
|
||
| async def authenticate_request( | ||
| self, | ||
| request: RequestInformation, | ||
| additional_authentication_context: dict[str, Any] | None = None, | ||
| ) -> None: | ||
| """Attach a bearer token to the outgoing Graph request. | ||
|
|
||
| :param request: The request to authenticate. | ||
| :param additional_authentication_context: Optional Kiota authentication | ||
| context; unused but accepted to satisfy the provider interface. | ||
| """ | ||
| if additional_authentication_context is None: | ||
| additional_authentication_context = {} | ||
|
|
||
| token_response = await self._app.auth.get_token( | ||
| self._context, self._handler_name | ||
| ) | ||
| if token_response: | ||
| request.headers["Authorization"] = f"Bearer {token_response.token}" | ||
|
|
||
|
|
||
| def _create_graph_service_client( | ||
| app: AgentApplication, | ||
| context: TurnContext, | ||
| handler_name: str | None = None, | ||
| ) -> GraphServiceClient: | ||
| """Create a Graph client authenticated for the current turn. | ||
|
|
||
| :param app: The agent application whose authorization issues tokens. | ||
| :param context: The current turn context. | ||
| :param handler_name: Optional auth handler name used to acquire the token. | ||
| :return: A :class:`GraphServiceClient` that authenticates each request via | ||
| the agent's authorization. | ||
| """ | ||
| return GraphServiceClient( | ||
| request_adapter=GraphRequestAdapter( | ||
| _SDKAuthenticationProvider(app, context, handler_name) | ||
| ) | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.