Skip to content
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

Add initial implementation of DispatcherAgent with configuration and telemetry support #59

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
**/launchSettings.json
**/launchSettings.Template.json
**/appsettings.Development.json

# Mono auto generated files
mono_crash.*
Expand Down
11 changes: 11 additions & 0 deletions samples/AssemblyInfo.Shared.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project>
<PropertyGroup>
<!--<Company Condition="'$(Company)' == ''">Microsoft</Company>--> <!-- Company Set in Nuget Properties -->
<Product Condition="'$(Product)' == ''">Microsoft Agents Sdk Samples</Product>
<Copyright Condition="'$(Copyright)' == ''">© Microsoft Corporation. All rights reserved.</Copyright>
<AssemblyVersion Condition="'$(AssemblyVersion)' == ''">0.1.0.0</AssemblyVersion>
<FileVersion Condition="'$(FileVersion)' == ''">1.0.0.0</FileVersion>
<InformationalVersion Condition="'$(InformationalVersion)' == ''">$(FileVersion)</InformationalVersion>
<PreSetAssemblyVersion>$(AssemblyVersion)</PreSetAssemblyVersion>
</PropertyGroup>
</Project>
24 changes: 24 additions & 0 deletions samples/Build.Common.core.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project>
<!-- dotnetCore specific msbuild properties: -->
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFrameworks)' == ''">
<TargetFrameworks>net8.0</TargetFrameworks>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
</PropertyGroup>

<PropertyGroup>
<Features>IOperation</Features>
</PropertyGroup>

<ItemGroup>
<Compile Remove="obj\**" />
<EmbeddedResource Remove="obj\**" />
<None Remove="obj\**" />
</ItemGroup>

<Import Project=".\Build.Shared.props" />

</Project>
63 changes: 63 additions & 0 deletions samples/Build.Shared.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<Project>
<!-- msbuild properties shared for dotnetCore and .NET classic projects: -->
<PropertyGroup>
<!--
Create a corse level define to identity .net framework vs .net core

This is to align with https://github.com/dotnet/designs/blob/main/accepted/2020/or-greater-defines/or-greater-defines.md
which pre-defines some preprocessor symbols for source files.

Also this has to be defined in Directory.build.targets to ensure it is evaluated after evaluating all properties
in .csproj files.
-->
<NETFRAMEWORK Condition="$(TargetFramework.ToLower().StartsWith('net4'))">true</NETFRAMEWORK>
<NETFRAMEWORK Condition="!$(TargetFramework.ToLower().StartsWith('net4'))">false</NETFRAMEWORK>
<NETFRAMEWORK Condition="'$(NETFRAMEWORK)'==''">true</NETFRAMEWORK>
</PropertyGroup>

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
</PropertyGroup>

<PropertyGroup>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NoWarn>$(NoWarn);CS8032;CS8002;CS1668</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>false</Optimize>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DefineConstants>TRACE</DefineConstants>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>false</Optimize>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<DefineConstants>TRACE</DefineConstants>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<!-- Common Assembly Info Properties -->
<Import Project=".\AssemblyInfo.Shared.props"/>

</Project>
88 changes: 88 additions & 0 deletions samples/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<Project>
<!-- See: https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2019#directorybuildprops-and-directorybuildtargets -->
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<!-- To avoid NU1507 we must disable library packs from getting added by the SDK.
Error:
The project E:\repos\msazure\One\PowerPlatform-ISVEx-ToolsCore\src\cli\Analyzers\bolt.Analyzers\bolt.Analyzers\bolt.Analyzers.csproj is using CentralPackageVersionManagement, a NuGet preview feature.
E:\repos\msazure\One\PowerPlatform-ISVEx-ToolsCore\src\cli\Analyzers\bolt.Analyzers\bolt.Analyzers\bolt.Analyzers.csproj : warning NU1507: There are 2 package sources defined in your configuration. When using central package management, please map your package sources with package source mapping (https://aka.ms/nuget-package-source-mapping) or specify a single package source. The following sources are defined: https://pkgs.dev.azure.com/msazure/One/_packaging/CAP_ISVExp_Tools_Upstream/nuget/v3/index.json, C:\Program Files\dotnet\library-packs
The 'library-packs' source is added by the SDK.
-->
<DisableImplicitLibraryPacksFolder>true</DisableImplicitLibraryPacksFolder>
<!-- Define no-warns for Nuget packages-->
<NoWarn>$(NoWarn);NU1701;NU1900;NU5125;NU5104</NoWarn>
</PropertyGroup>

<!-- Define the versions of the packages used in for .net SAMPLES -->
<PropertyGroup>
<Microsoft_Extensions_PkgVer>8.0.0</Microsoft_Extensions_PkgVer>
<Microsoft_AspNetCore_PkgVer>8.0.11</Microsoft_AspNetCore_PkgVer>
</PropertyGroup>
<ItemGroup>
<!-- Agent SDK Base Libs -->
<PackageVersion Include="Microsoft.Agents.Authentication.Msal" Version="0.2.58-alpha" />
<PackageVersion Include="Microsoft.Agents.CopilotStudio.Client" Version="0.2.58-alpha" />
<PackageVersion Include="Microsoft.Agents.Hosting.AspNetCore" Version="0.2.58-alpha" />
<PackageVersion Include="Microsoft.Agents.Storage" Version="0.2.58-alpha" />
<!-- End Agent SDK -->

<PackageVersion Include="Azure.AI.OpenAI" Version="2.1.0" />
<PackageVersion Include="CsvHelper" Version="33.0.1" />
<PackageVersion Include="Microsoft.Extensions.AI.OpenAI" Version="9.1.0-preview.1.25064.3" />
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.1" />
<PackageVersion Include="Microsoft.IdentityModel.Tokens" Version="8.1.2" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
<PackageVersion Include="AdaptiveCards.Rendering.Html" Version="2.7.3" />
<PackageVersion Include="Azure.Identity" Version="1.13.2" />
<PackageVersion Include="Azure.Core" Version="1.43.0" />
<PackageVersion Include="Microsoft.Identity.Client" Version="4.67.2" />
<PackageVersion Include="Microsoft.Identity.Client.Extensions.Msal" Version="4.67.2" />
<PackageVersion Include="Microsoft.IdentityModel.Abstractions" Version="8.1.2" />
<PackageVersion Include="Microsoft.IdentityModel.LoggingExtensions" Version="8.1.2" />
<PackageVersion Include="Microsoft.IdentityModel.Validators" Version="8.1.2" />
<PackageVersion Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.1.2" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.0.1" />
<PackageVersion Include="Azure.Security.KeyVault.Certificates" Version="4.6.0" />
<PackageVersion Include="Microsoft.Azure.AutoRest.CSharp" Version="3.0.0-beta.20231020.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.AzureAppServices" Version="8.0.7" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="$(Microsoft_Extensions_PkgVer)" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="$(Microsoft_Extensions_PkgVer)" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="$(Microsoft_Extensions_PkgVer)" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="$(Microsoft_Extensions_PkgVer)" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="$(Microsoft_Extensions_PkgVer)" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="$(Microsoft_Extensions_PkgVer)" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="$(Microsoft_Extensions_PkgVer)" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
<!-- ASP.net Core support -->
<PackageVersion Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="$(Microsoft_AspNetCore_PkgVer)" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(Microsoft_AspNetCore_PkgVer)" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="$(Microsoft_AspNetCore_PkgVer)" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Core" Version="$(Microsoft_AspNetCore_PkgVer)" />
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="$(Microsoft_AspNetCore_PkgVer)" />
<!-- Test nuget packages -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageVersion Include="xunit" Version="2.9.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="coverlet.collector" Version="1.2.0" />
<PackageVersion Include="Moq" Version="4.20.70" />
<PackageVersion Include="Jint" Version="4.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.10.0" />
<PackageVersion Include="Microsoft.Recognizers.Text.DataTypes.TimexExpression" Version="1.3.2" />
<PackageVersion Include="xunit.extensibility.core" Version="2.9.0" />
<!-- Teams samples -->
<PackageVersion Include="AdaptiveCards" Version="3.1.0" />
<PackageVersion Include="AdaptiveCards.Templating" Version="2.0.3" />
<PackageVersion Include="Microsoft.Graph" Version="4.47.0" />
<PackageVersion Include="Microsoft.Graph.Core" Version="2.0.14" />
<!-- Semantic Kernel Samples -->
<PackageVersion Include="Microsoft.SemanticKernel" Version="1.35.0" />
<PackageVersion Include="Microsoft.SemanticKernel.Agents.Core" Version="1.35.0-alpha" />
<PackageVersion Include="Microsoft.SemanticKernel.Agents.OpenAI" Version="1.35.0-alpha" />
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.AzureOpenAI" Version="1.35.0" />
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.OpenAI" Version="1.35.0" />
<!-- Dataverse -->
<PackageVersion Include="Microsoft.PowerPlatform.Dataverse.Client" Version="1.2.2" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.Agents.BotBuilder;
using Microsoft.Agents.Hosting.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace DispatcherAgent.Controllers
{
/// <summary>
/// ASP.Net Controller that receives incoming HTTP requests from the Azure Bot Service or other
/// configured event / activity protocol sources. When called, the request has already been
/// authorized and credentials and tokens validated.
///
/// This is the entry point for the bot to process incoming activities, such as messages.
///
/// </summary>
/// <param name="adapter"></param>
/// <param name="bot"></param>
[Authorize]
[ApiController]
[Route("api/messages")]
public class BotController(IBotHttpAdapter adapter, IBot bot) : ControllerBase
{
[HttpPost]
public async Task PostAsync(CancellationToken cancellationToken)
{
// Delegate the processing of the HTTP POST to the adapter.
// The adapter will invoke the bot.
await adapter.ProcessAsync(Request, Response, bot, cancellationToken);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<RootNamespace>DispatcherAgent</RootNamespace>

</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Agents.Authentication.Msal" />
<PackageReference Include="Microsoft.Agents.CopilotStudio.Client" />
<PackageReference Include="Microsoft.Agents.Hosting.AspNetCore" />
<PackageReference Include="Microsoft.Agents.Storage" />
<PackageReference Include="Microsoft.SemanticKernel" />
<PackageReference Include="Nerdbank.GitVersioning" />
</ItemGroup>
</Project>
Loading