Skip to content

Commit

Permalink
Merge pull request microsoft#99 from microsoft/users/tracyboehrer/app…
Browse files Browse the repository at this point in the history
…lication-merge

Application integration feature branch
  • Loading branch information
tracyboehrer authored Mar 4, 2025
2 parents 7f29f9d + 98e73ae commit d84d985
Show file tree
Hide file tree
Showing 1,057 changed files with 20,321 additions and 4,281 deletions.
5 changes: 4 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.6.146" />
<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="Azure.Core" Version="1.44.1" />
<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" />
Expand All @@ -45,6 +45,7 @@
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="$(Microsoft_Extentions_PkgVer)" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="$(Microsoft_Extentions_PkgVer)" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="$(Microsoft_Extentions_PkgVer)" />
<PackageVersion Include="System.Memory.Data" Version="8.0.1" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
<!-- ASP.net Core support -->
Expand Down Expand Up @@ -89,5 +90,7 @@
<PackageVersion Include="Microsoft.SemanticKernel.Agents.OpenAI" Version="1.29.0-alpha" />
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.AzureOpenAI" Version="1.29.0" />
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.OpenAI" Version="1.29.0" />
<!-- Azure OpenAI -->
<PackageVersion Include="OpenAI" Version="2.1.0" />
</ItemGroup>
</Project>
200 changes: 54 additions & 146 deletions src/Microsoft.Agents.SDK.sln

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// Licensed under the MIT License.
// Copyright (c) Microsoft Corporation. All rights reserved.

using Microsoft.Agents.Core.Interfaces;
using Microsoft.Agents.Telemetry;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Agents.Telemetry;

namespace Microsoft.Agents.BotBuilder.Dialogs
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.Agents.Core.Interfaces;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -24,7 +23,7 @@ public static class DebugSupport
/// <param name="context">turnContext.</param>
/// <returns>IDialogDebugger.</returns>
public static IDialogDebugger GetDebugger(this ITurnContext context) =>
context.TurnState.Get<IDialogDebugger>() ?? NullDialogDebugger.Instance;
context.Services.Get<IDialogDebugger>() ?? NullDialogDebugger.Instance;

/// <summary>
/// Extension method to get IDialogDebugger from DialogContext.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Agents.BotBuilder.Dialogs.Debugging;
using Microsoft.Agents.Core.Interfaces;
using Microsoft.Agents.Telemetry;

namespace Microsoft.Agents.BotBuilder.Dialogs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Agents.BotBuilder.Dialogs.Debugging;
using Microsoft.Agents.Core.Interfaces;
using Microsoft.Agents.State;
using Microsoft.Agents.BotBuilder.State;

namespace Microsoft.Agents.BotBuilder.Dialogs
{
Expand All @@ -32,7 +31,6 @@ public DialogContext(DialogSet dialogs, ITurnContext turnContext, DialogState st
Dialogs = dialogs ?? throw new ArgumentNullException(nameof(dialogs));
Context = turnContext ?? throw new ArgumentNullException(nameof(turnContext));
Stack = state.DialogStack;
Services = new TurnContextStateCollection();
}

/// <summary>
Expand All @@ -48,15 +46,6 @@ public DialogContext(
: this(dialogs, parentDialogContext.Context, state)
{
Parent = parentDialogContext ?? throw new ArgumentNullException(nameof(parentDialogContext));

if (Parent.Services != null)
{
// copy parent services into this dialogcontext.
foreach (var service in Parent.Services)
{
Services[service.Key] = service.Value;
}
}
}

/// <summary>
Expand Down Expand Up @@ -252,9 +241,9 @@ public DialogInstance ActiveDialog
{
// if we are continuing and haven't emitted the activityReceived event, emit it
// NOTE: This is backward compatible way for activity received to be fired even if you have legacy dialog loop
if (!this.Context.TurnState.ContainsKey("activityReceivedEmitted"))
if (!Context.StackState.Has("activityReceivedEmitted"))
{
this.Context.TurnState["activityReceivedEmitted"] = true;
Context.StackState.Set("activityReceivedEmitted", true);

// Dispatch "activityReceived" event
// - This will queue up any interruptions.
Expand Down Expand Up @@ -484,7 +473,7 @@ public DialogInstance ActiveDialog
// End the current dialog and giving the reason.
await EndActiveDialogAsync(DialogReason.ReplaceCalled, cancellationToken: cancellationToken).ConfigureAwait(false);

ObjectPath.SetPathValue(this.Context.TurnState, "turn.__repeatDialogId", dialogId);
Context.StackState.Set("turn.__repeatDialogId", dialogId);

// Start replacement dialog
return await BeginDialogAsync(dialogId, options, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
using Microsoft.Agents.Client;
using Microsoft.Agents.Authentication;
using Microsoft.Agents.Telemetry;
using Microsoft.Agents.State;
using Microsoft.Agents.Core.Interfaces;
using Microsoft.Agents.Core.Models;
using Microsoft.Agents.BotBuilder.State;

namespace Microsoft.Agents.BotBuilder.Dialogs
{
Expand All @@ -37,11 +36,11 @@ public static class DialogExtensions
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public static async Task RunAsync(this Dialog dialog, ITurnContext turnContext, BotState state, CancellationToken cancellationToken)
{
var dialogState = await state.GetPropertyAsync<DialogState>(turnContext, "DialogState", () => new DialogState(), cancellationToken);
var dialogState = state.GetValue<DialogState>("DialogState", () => new DialogState());
var dialogSet = new DialogSet(dialogState);

// look for the IBotTelemetryClient on the TurnState, if not there take it from the Dialog, if not there fall back to the "null" default
dialogSet.TelemetryClient = turnContext.TurnState.Get<IBotTelemetryClient>() ?? dialog.TelemetryClient ?? NullBotTelemetryClient.Instance;
dialogSet.TelemetryClient = turnContext.Services.Get<IBotTelemetryClient>() ?? dialog.TelemetryClient ?? NullBotTelemetryClient.Instance;

dialogSet.Add(dialog);

Expand All @@ -50,14 +49,26 @@ public static async Task RunAsync(this Dialog dialog, ITurnContext turnContext,
await InternalRunAsync(turnContext, dialog.Id, dialogContext, cancellationToken).ConfigureAwait(false);
}

internal static async Task<DialogTurnResult> InternalRunAsync(ITurnContext turnContext, string dialogId, DialogContext dialogContext, CancellationToken cancellationToken)
[Obsolete("Use the non-IStatePropertyAccessor version")]
public static async Task RunAsync(this Dialog dialog, ITurnContext turnContext, IStatePropertyAccessor<DialogState> accessor, CancellationToken cancellationToken)
{
// map TurnState into root dialog context.services
foreach (var service in turnContext.TurnState)
{
dialogContext.Services[service.Key] = service.Value;
}
var state = await accessor.GetAsync(turnContext, () => { return new DialogState(); }, cancellationToken).ConfigureAwait(false);

var dialogSet = new DialogSet(state);

// look for the IBotTelemetryClient on the TurnState, if not there take it from the Dialog, if not there fall back to the "null" default
dialogSet.TelemetryClient = turnContext.Services.Get<IBotTelemetryClient>() ?? dialog.TelemetryClient ?? NullBotTelemetryClient.Instance;

dialogSet.Add(dialog);

var dialogContext = await dialogSet.CreateContextAsync(turnContext, cancellationToken).ConfigureAwait(false);

await InternalRunAsync(turnContext, dialog.Id, dialogContext, cancellationToken).ConfigureAwait(false);
}


internal static async Task<DialogTurnResult> InternalRunAsync(ITurnContext turnContext, string dialogId, DialogContext dialogContext, CancellationToken cancellationToken)
{
DialogTurnResult dialogTurnResult = null;

// Loop as long as we are getting valid OnError handled we should continue executing the actions for the turn.
Expand Down Expand Up @@ -170,11 +181,11 @@ private static async Task<DialogTurnResult> InnerRunAsync(ITurnContext turnConte
/// </summary>
private static bool SendEoCToParent(ITurnContext turnContext)
{
if (turnContext.TurnState.Get<IIdentity>(ChannelAdapter.BotIdentityKey) is ClaimsIdentity claimIdentity && BotClaims.IsBotClaim(claimIdentity.Claims))
if (turnContext.Identity as ClaimsIdentity != null && BotClaims.IsBotClaim(turnContext.Identity))
{
// EoC Activities returned by skills are bounced back to the bot by SkillHandler.
// In those cases we will have a SkillConversationReference instance in state.
var skillConversationReference = turnContext.TurnState.Get<BotConversationReference>(BotFrameworkSkillHandler.SkillConversationReferenceKey);
var skillConversationReference = turnContext.StackState.Get<BotConversationReference>(ProxyChannelApiHandler.SkillConversationReferenceKey);
if (skillConversationReference != null)
{
// If the skillConversationReference.OAuthScope is for one of the supported channels, we are at the root and we should not send an EoC.
Expand All @@ -189,12 +200,12 @@ private static bool SendEoCToParent(ITurnContext turnContext)

private static bool IsFromParentToSkill(ITurnContext turnContext)
{
if (turnContext.TurnState.Get<BotConversationReference>(BotFrameworkSkillHandler.SkillConversationReferenceKey) != null)
if (turnContext.StackState.Get<BotConversationReference>(ProxyChannelApiHandler.SkillConversationReferenceKey) != null)
{
return false;
}

return turnContext.TurnState.Get<IIdentity>(ChannelAdapter.BotIdentityKey) is ClaimsIdentity claimIdentity && BotClaims.IsBotClaim(claimIdentity.Claims);
return turnContext.Identity as ClaimsIdentity != null && BotClaims.IsBotClaim(turnContext.Identity);
}

// Recursively walk up the DC stack to find the active DC.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Agents.State;
using Microsoft.Agents.Core.Interfaces;
using Microsoft.Agents.BotBuilder.State;
using Microsoft.Agents.Telemetry;

namespace Microsoft.Agents.BotBuilder.Dialogs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.Agents.State;
using Microsoft.Agents.BotBuilder.State;
using System.Collections.Generic;
using System.Text.Json.Serialization;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.Agents.Core.Interfaces;
using System.Threading;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Core\Microsoft.Agents.Telemetry\Microsoft.Agents.Telemetry.csproj" />
<ProjectReference Include="..\Microsoft.Agents.BotBuilder\Microsoft.Agents.BotBuilder.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.Agents.Core.Interfaces;
using Microsoft.Agents.Core.Models;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -123,7 +122,7 @@ public override async Task<DialogTurnResult> ContinueDialogAsync(DialogContext d

// Increment attempt count
// Convert.ToInt32 For issue https://github.com/Microsoft/botbuilder-dotnet/issues/1859
state[Prompt<int>.AttemptCountKey] = state[Prompt<int>.AttemptCountKey].CastTo<int>() + 1;
state[Prompt<int>.AttemptCountKey] = (int) state[Prompt<int>.AttemptCountKey] + 1;

// Validate the return value
var isValid = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.Agents.Core.Interfaces;
using Microsoft.Agents.Core.Models;
using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Agents.BotBuilder.Dialogs.Choices;
using Microsoft.Agents.Core.Interfaces;
using Microsoft.Agents.Core.Models;
using static Microsoft.Agents.BotBuilder.Dialogs.Prompts.PromptCultureModels;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Agents.BotBuilder.Dialogs.Choices;
using Microsoft.Agents.Core.Interfaces;
using Microsoft.Agents.Core.Models;
using Microsoft.Recognizers.Text.Choice;
using static Microsoft.Agents.BotBuilder.Dialogs.Prompts.PromptCultureModels;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Agents.Core.Interfaces;
using Microsoft.Agents.Core.Models;
using Microsoft.Recognizers.Text.DateTime;
using static Microsoft.Recognizers.Text.Culture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Agents.Core.Interfaces;
using Microsoft.Agents.Core.Models;
using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.Number;
Expand Down
Loading

0 comments on commit d84d985

Please sign in to comment.