@microsoft/agents-hosting-dialogs 0.1.49
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.
- package/dist/index.js +20 -0
- package/dist/src/agentComponent.d.ts +18 -0
- package/dist/src/agentComponent.js +55 -0
- package/dist/src/agentComponent.js.map +1 -0
- package/dist/src/agentStateSet.d.ts +48 -0
- package/dist/src/agentStateSet.js +66 -0
- package/dist/src/agentStateSet.js.map +1 -0
- package/dist/src/choices/choice.d.ts +14 -0
- package/dist/src/choices/choice.js +7 -0
- package/dist/src/choices/choice.js.map +1 -0
- package/dist/src/choices/choiceFactory.d.ts +81 -0
- package/dist/src/choices/choiceFactory.js +133 -0
- package/dist/src/choices/choiceFactory.js.map +1 -0
- package/dist/src/choices/findChoices.d.ts +28 -0
- package/dist/src/choices/findChoices.js +46 -0
- package/dist/src/choices/findChoices.js.map +1 -0
- package/dist/src/choices/findValues.d.ts +36 -0
- package/dist/src/choices/findValues.js +129 -0
- package/dist/src/choices/findValues.js.map +1 -0
- package/dist/src/choices/index.d.ts +11 -0
- package/dist/src/choices/index.js +28 -0
- package/dist/src/choices/index.js.map +1 -0
- package/dist/src/choices/modelResult.d.ts +11 -0
- package/dist/src/choices/modelResult.js +3 -0
- package/dist/src/choices/modelResult.js.map +1 -0
- package/dist/src/choices/recognizeChoices.d.ts +16 -0
- package/dist/src/choices/recognizeChoices.js +81 -0
- package/dist/src/choices/recognizeChoices.js.map +1 -0
- package/dist/src/choices/tokenizer.d.ts +25 -0
- package/dist/src/choices/tokenizer.js +73 -0
- package/dist/src/choices/tokenizer.js.map +1 -0
- package/dist/src/componentDialog.d.ts +178 -0
- package/dist/src/componentDialog.js +252 -0
- package/dist/src/componentDialog.js.map +1 -0
- package/dist/src/componentRegistration.d.ts +22 -0
- package/dist/src/componentRegistration.js +32 -0
- package/dist/src/componentRegistration.js.map +1 -0
- package/dist/src/configurable.d.ts +22 -0
- package/dist/src/configurable.js +60 -0
- package/dist/src/configurable.js.map +1 -0
- package/dist/src/configuration.d.ts +11 -0
- package/dist/src/configuration.js +17 -0
- package/dist/src/configuration.js.map +1 -0
- package/dist/src/converter.d.ts +13 -0
- package/dist/src/converter.js +7 -0
- package/dist/src/converter.js.map +1 -0
- package/dist/src/dialog.d.ts +184 -0
- package/dist/src/dialog.js +201 -0
- package/dist/src/dialog.js.map +1 -0
- package/dist/src/dialogContainer.d.ts +61 -0
- package/dist/src/dialogContainer.js +82 -0
- package/dist/src/dialogContainer.js.map +1 -0
- package/dist/src/dialogContext.d.ts +272 -0
- package/dist/src/dialogContext.js +444 -0
- package/dist/src/dialogContext.js.map +1 -0
- package/dist/src/dialogContextError.d.ts +27 -0
- package/dist/src/dialogContextError.js +39 -0
- package/dist/src/dialogContextError.js.map +1 -0
- package/dist/src/dialogEvent.d.ts +20 -0
- package/dist/src/dialogEvent.js +3 -0
- package/dist/src/dialogEvent.js.map +1 -0
- package/dist/src/dialogEvents.d.ts +15 -0
- package/dist/src/dialogEvents.js +20 -0
- package/dist/src/dialogEvents.js.map +1 -0
- package/dist/src/dialogHelper.d.ts +32 -0
- package/dist/src/dialogHelper.js +116 -0
- package/dist/src/dialogHelper.js.map +1 -0
- package/dist/src/dialogInstance.d.ts +30 -0
- package/dist/src/dialogInstance.js +3 -0
- package/dist/src/dialogInstance.js.map +1 -0
- package/dist/src/dialogManager.d.ts +73 -0
- package/dist/src/dialogManager.js +156 -0
- package/dist/src/dialogManager.js.map +1 -0
- package/dist/src/dialogReason.d.ts +35 -0
- package/dist/src/dialogReason.js +40 -0
- package/dist/src/dialogReason.js.map +1 -0
- package/dist/src/dialogSet.d.ts +85 -0
- package/dist/src/dialogSet.js +138 -0
- package/dist/src/dialogSet.js.map +1 -0
- package/dist/src/dialogTurnResult.d.ts +34 -0
- package/dist/src/dialogTurnResult.js +3 -0
- package/dist/src/dialogTurnResult.js.map +1 -0
- package/dist/src/dialogTurnStateConstants.d.ts +12 -0
- package/dist/src/dialogTurnStateConstants.js +17 -0
- package/dist/src/dialogTurnStateConstants.js.map +1 -0
- package/dist/src/dialogTurnStatus.d.ts +34 -0
- package/dist/src/dialogTurnStatus.js +39 -0
- package/dist/src/dialogTurnStatus.js.map +1 -0
- package/dist/src/dialogsAgentComponent.d.ts +17 -0
- package/dist/src/dialogsAgentComponent.js +65 -0
- package/dist/src/dialogsAgentComponent.js.map +1 -0
- package/dist/src/dialogsComponentRegistration.d.ts +28 -0
- package/dist/src/dialogsComponentRegistration.js +45 -0
- package/dist/src/dialogsComponentRegistration.js.map +1 -0
- package/dist/src/i18n.d.ts +15 -0
- package/dist/src/i18n.js +28 -0
- package/dist/src/i18n.js.map +1 -0
- package/dist/src/index.d.ts +29 -0
- package/dist/src/index.js +48 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/intentScore.d.ts +11 -0
- package/dist/src/intentScore.js +3 -0
- package/dist/src/intentScore.js.map +1 -0
- package/dist/src/memory/componentMemoryScopes.d.ts +18 -0
- package/dist/src/memory/componentMemoryScopes.js +54 -0
- package/dist/src/memory/componentMemoryScopes.js.map +1 -0
- package/dist/src/memory/componentPathResolvers.d.ts +18 -0
- package/dist/src/memory/componentPathResolvers.js +52 -0
- package/dist/src/memory/componentPathResolvers.js.map +1 -0
- package/dist/src/memory/dialogPath.d.ts +17 -0
- package/dist/src/memory/dialogPath.js +30 -0
- package/dist/src/memory/dialogPath.js.map +1 -0
- package/dist/src/memory/dialogStateManager.d.ts +156 -0
- package/dist/src/memory/dialogStateManager.js +598 -0
- package/dist/src/memory/dialogStateManager.js.map +1 -0
- package/dist/src/memory/index.d.ts +12 -0
- package/dist/src/memory/index.js +29 -0
- package/dist/src/memory/index.js.map +1 -0
- package/dist/src/memory/pathResolvers/aliasPathResolver.d.ts +25 -0
- package/dist/src/memory/pathResolvers/aliasPathResolver.js +37 -0
- package/dist/src/memory/pathResolvers/aliasPathResolver.js.map +1 -0
- package/dist/src/memory/pathResolvers/atAtPathResolver.d.ts +11 -0
- package/dist/src/memory/pathResolvers/atAtPathResolver.js +18 -0
- package/dist/src/memory/pathResolvers/atAtPathResolver.js.map +1 -0
- package/dist/src/memory/pathResolvers/atPathResolver.d.ts +20 -0
- package/dist/src/memory/pathResolvers/atPathResolver.js +46 -0
- package/dist/src/memory/pathResolvers/atPathResolver.js.map +1 -0
- package/dist/src/memory/pathResolvers/dollarPathResolver.d.ts +11 -0
- package/dist/src/memory/pathResolvers/dollarPathResolver.js +18 -0
- package/dist/src/memory/pathResolvers/dollarPathResolver.js.map +1 -0
- package/dist/src/memory/pathResolvers/hashPathResolver.d.ts +11 -0
- package/dist/src/memory/pathResolvers/hashPathResolver.js +18 -0
- package/dist/src/memory/pathResolvers/hashPathResolver.js.map +1 -0
- package/dist/src/memory/pathResolvers/index.d.ts +11 -0
- package/dist/src/memory/pathResolvers/index.js +28 -0
- package/dist/src/memory/pathResolvers/index.js.map +1 -0
- package/dist/src/memory/pathResolvers/pathResolver.d.ts +13 -0
- package/dist/src/memory/pathResolvers/pathResolver.js +7 -0
- package/dist/src/memory/pathResolvers/pathResolver.js.map +1 -0
- package/dist/src/memory/pathResolvers/percentPathResolver.d.ts +11 -0
- package/dist/src/memory/pathResolvers/percentPathResolver.js +18 -0
- package/dist/src/memory/pathResolvers/percentPathResolver.js.map +1 -0
- package/dist/src/memory/scopePath.d.ts +18 -0
- package/dist/src/memory/scopePath.js +23 -0
- package/dist/src/memory/scopePath.js.map +1 -0
- package/dist/src/memory/scopes/agentStateMemoryScope.d.ts +53 -0
- package/dist/src/memory/scopes/agentStateMemoryScope.js +82 -0
- package/dist/src/memory/scopes/agentStateMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/classMemoryScope.d.ts +29 -0
- package/dist/src/memory/scopes/classMemoryScope.js +65 -0
- package/dist/src/memory/scopes/classMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/conversationMemoryScope.d.ts +15 -0
- package/dist/src/memory/scopes/conversationMemoryScope.js +23 -0
- package/dist/src/memory/scopes/conversationMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/dialogClassMemoryScope.d.ts +19 -0
- package/dist/src/memory/scopes/dialogClassMemoryScope.js +42 -0
- package/dist/src/memory/scopes/dialogClassMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/dialogContextMemoryScope.d.ts +19 -0
- package/dist/src/memory/scopes/dialogContextMemoryScope.js +48 -0
- package/dist/src/memory/scopes/dialogContextMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/dialogMemoryScope.d.ts +32 -0
- package/dist/src/memory/scopes/dialogMemoryScope.js +74 -0
- package/dist/src/memory/scopes/dialogMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/index.d.ts +15 -0
- package/dist/src/memory/scopes/index.js +32 -0
- package/dist/src/memory/scopes/index.js.map +1 -0
- package/dist/src/memory/scopes/memoryScope.d.ts +52 -0
- package/dist/src/memory/scopes/memoryScope.js +54 -0
- package/dist/src/memory/scopes/memoryScope.js.map +1 -0
- package/dist/src/memory/scopes/settingsMemoryScope.d.ts +68 -0
- package/dist/src/memory/scopes/settingsMemoryScope.js +216 -0
- package/dist/src/memory/scopes/settingsMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/thisMemoryScope.d.ts +26 -0
- package/dist/src/memory/scopes/thisMemoryScope.js +43 -0
- package/dist/src/memory/scopes/thisMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/turnMemoryScope.d.ts +29 -0
- package/dist/src/memory/scopes/turnMemoryScope.js +52 -0
- package/dist/src/memory/scopes/turnMemoryScope.js.map +1 -0
- package/dist/src/memory/scopes/userMemoryScope.d.ts +15 -0
- package/dist/src/memory/scopes/userMemoryScope.js +23 -0
- package/dist/src/memory/scopes/userMemoryScope.js.map +1 -0
- package/dist/src/memory/turnPath.d.ts +21 -0
- package/dist/src/memory/turnPath.js +38 -0
- package/dist/src/memory/turnPath.js.map +1 -0
- package/dist/src/prompts/activityPrompt.d.ts +101 -0
- package/dist/src/prompts/activityPrompt.js +166 -0
- package/dist/src/prompts/activityPrompt.js.map +1 -0
- package/dist/src/prompts/attachmentPrompt.d.ts +37 -0
- package/dist/src/prompts/attachmentPrompt.js +55 -0
- package/dist/src/prompts/attachmentPrompt.js.map +1 -0
- package/dist/src/prompts/choicePrompt.d.ts +83 -0
- package/dist/src/prompts/choicePrompt.js +116 -0
- package/dist/src/prompts/choicePrompt.js.map +1 -0
- package/dist/src/prompts/confirmPrompt.d.ts +82 -0
- package/dist/src/prompts/confirmPrompt.js +163 -0
- package/dist/src/prompts/confirmPrompt.js.map +1 -0
- package/dist/src/prompts/datetimePrompt.d.ts +65 -0
- package/dist/src/prompts/datetimePrompt.js +109 -0
- package/dist/src/prompts/datetimePrompt.js.map +1 -0
- package/dist/src/prompts/index.d.ts +13 -0
- package/dist/src/prompts/index.js +30 -0
- package/dist/src/prompts/index.js.map +1 -0
- package/dist/src/prompts/numberPrompt.d.ts +55 -0
- package/dist/src/prompts/numberPrompt.js +134 -0
- package/dist/src/prompts/numberPrompt.js.map +1 -0
- package/dist/src/prompts/prompt.d.ts +256 -0
- package/dist/src/prompts/prompt.js +260 -0
- package/dist/src/prompts/prompt.js.map +1 -0
- package/dist/src/prompts/promptCultureModels.d.ts +72 -0
- package/dist/src/prompts/promptCultureModels.js +123 -0
- package/dist/src/prompts/promptCultureModels.js.map +1 -0
- package/dist/src/prompts/textPrompt.d.ts +54 -0
- package/dist/src/prompts/textPrompt.js +72 -0
- package/dist/src/prompts/textPrompt.js.map +1 -0
- package/dist/src/recognizer.d.ts +43 -0
- package/dist/src/recognizer.js +104 -0
- package/dist/src/recognizer.js.map +1 -0
- package/dist/src/recognizerResult.d.ts +19 -0
- package/dist/src/recognizerResult.js +24 -0
- package/dist/src/recognizerResult.js.map +1 -0
- package/dist/src/serviceCollection.d.ts +112 -0
- package/dist/src/serviceCollection.js +209 -0
- package/dist/src/serviceCollection.js.map +1 -0
- package/dist/src/stringUtils.d.ts +36 -0
- package/dist/src/stringUtils.js +62 -0
- package/dist/src/stringUtils.js.map +1 -0
- package/dist/src/template.d.ts +18 -0
- package/dist/src/template.js +7 -0
- package/dist/src/template.js.map +1 -0
- package/dist/src/waterfallDialog.d.ts +101 -0
- package/dist/src/waterfallDialog.js +179 -0
- package/dist/src/waterfallDialog.js.map +1 -0
- package/dist/src/waterfallStepContext.d.ts +71 -0
- package/dist/src/waterfallStepContext.js +78 -0
- package/dist/src/waterfallStepContext.js.map +1 -0
- package/package.json +49 -0
- package/src/agentComponent.ts +23 -0
- package/src/agentStateSet.ts +75 -0
- package/src/choices/choice.ts +16 -0
- package/src/choices/choiceFactory.ts +189 -0
- package/src/choices/findChoices.ts +70 -0
- package/src/choices/findValues.ts +179 -0
- package/src/choices/index.ts +11 -0
- package/src/choices/modelResult.ts +11 -0
- package/src/choices/recognizeChoices.ts +94 -0
- package/src/choices/tokenizer.ts +93 -0
- package/src/componentDialog.ts +306 -0
- package/src/componentRegistration.ts +30 -0
- package/src/configurable.ts +55 -0
- package/src/configuration.ts +22 -0
- package/src/converter.ts +15 -0
- package/src/dialog.ts +243 -0
- package/src/dialogContainer.ts +90 -0
- package/src/dialogContext.ts +607 -0
- package/src/dialogContextError.ts +50 -0
- package/src/dialogEvent.ts +23 -0
- package/src/dialogEvents.ts +16 -0
- package/src/dialogHelper.ts +154 -0
- package/src/dialogInstance.ts +32 -0
- package/src/dialogManager.ts +202 -0
- package/src/dialogReason.ts +40 -0
- package/src/dialogSet.ts +168 -0
- package/src/dialogTurnResult.ts +37 -0
- package/src/dialogTurnStateConstants.ts +13 -0
- package/src/dialogTurnStatus.ts +38 -0
- package/src/dialogsAgentComponent.ts +71 -0
- package/src/dialogsComponentRegistration.ts +49 -0
- package/src/i18n.ts +17 -0
- package/src/index.ts +31 -0
- package/src/intentScore.ts +11 -0
- package/src/memory/componentMemoryScopes.ts +28 -0
- package/src/memory/componentPathResolvers.ts +29 -0
- package/src/memory/dialogPath.ts +33 -0
- package/src/memory/dialogStateManager.ts +661 -0
- package/src/memory/index.ts +12 -0
- package/src/memory/pathResolvers/aliasPathResolver.ts +44 -0
- package/src/memory/pathResolvers/atAtPathResolver.ts +14 -0
- package/src/memory/pathResolvers/atPathResolver.ts +45 -0
- package/src/memory/pathResolvers/dollarPathResolver.ts +14 -0
- package/src/memory/pathResolvers/hashPathResolver.ts +14 -0
- package/src/memory/pathResolvers/index.ts +11 -0
- package/src/memory/pathResolvers/pathResolver.ts +14 -0
- package/src/memory/pathResolvers/percentPathResolver.ts +14 -0
- package/src/memory/scopePath.ts +19 -0
- package/src/memory/scopes/agentStateMemoryScope.ts +92 -0
- package/src/memory/scopes/classMemoryScope.ts +71 -0
- package/src/memory/scopes/conversationMemoryScope.ts +19 -0
- package/src/memory/scopes/dialogClassMemoryScope.ts +43 -0
- package/src/memory/scopes/dialogContextMemoryScope.ts +51 -0
- package/src/memory/scopes/dialogMemoryScope.ts +79 -0
- package/src/memory/scopes/index.ts +15 -0
- package/src/memory/scopes/memoryScope.ts +70 -0
- package/src/memory/scopes/settingsMemoryScope.ts +239 -0
- package/src/memory/scopes/thisMemoryScope.ts +44 -0
- package/src/memory/scopes/turnMemoryScope.ts +54 -0
- package/src/memory/scopes/userMemoryScope.ts +19 -0
- package/src/memory/turnPath.ts +45 -0
- package/src/prompts/activityPrompt.ts +202 -0
- package/src/prompts/attachmentPrompt.ts +62 -0
- package/src/prompts/choicePrompt.ts +176 -0
- package/src/prompts/confirmPrompt.ts +182 -0
- package/src/prompts/datetimePrompt.ts +110 -0
- package/src/prompts/index.ts +13 -0
- package/src/prompts/numberPrompt.ts +117 -0
- package/src/prompts/prompt.ts +459 -0
- package/src/prompts/promptCultureModels.ts +178 -0
- package/src/prompts/textPrompt.ts +82 -0
- package/src/recognizer.ts +127 -0
- package/src/recognizerResult.ts +37 -0
- package/src/serviceCollection.ts +305 -0
- package/src/stringUtils.ts +62 -0
- package/src/template.ts +20 -0
- package/src/waterfallDialog.ts +215 -0
- package/src/waterfallStepContext.ts +96 -0
- package/vendor/cldr-data/README.md +5 -0
- package/vendor/cldr-data/main/de/numbers.json +156 -0
- package/vendor/cldr-data/main/en/numbers.json +159 -0
- package/vendor/cldr-data/main/es/numbers.json +156 -0
- package/vendor/cldr-data/main/fr/numbers.json +157 -0
- package/vendor/cldr-data/main/ja/numbers.json +120 -0
- package/vendor/cldr-data/main/nl/numbers.json +156 -0
- package/vendor/cldr-data/main/pt/numbers.json +156 -0
- package/vendor/cldr-data/main/zh/numbers.json +214 -0
- package/vendor/cldr-data/supplemental/likelySubtags.json +1844 -0
- package/vendor/cldr-data/supplemental/numberingSystems.json +343 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.runDialog = runDialog;
|
|
8
|
+
exports.internalRun = internalRun;
|
|
9
|
+
exports.getActiveDialogContext = getActiveDialogContext;
|
|
10
|
+
const agents_hosting_1 = require("@microsoft/agents-hosting");
|
|
11
|
+
const dialogEvents_1 = require("./dialogEvents");
|
|
12
|
+
const dialogSet_1 = require("./dialogSet");
|
|
13
|
+
const memory_1 = require("./memory");
|
|
14
|
+
const dialogTurnStatus_1 = require("./dialogTurnStatus");
|
|
15
|
+
/**
|
|
16
|
+
* Runs a dialog from a given context and accessor.
|
|
17
|
+
*
|
|
18
|
+
* @param dialog The Dialog to run.
|
|
19
|
+
* @param context TurnContext object for the current turn of conversation with the user.
|
|
20
|
+
* @param accessor Defined methods for accessing the state property created in a State object.
|
|
21
|
+
*/
|
|
22
|
+
async function runDialog(dialog, context, accessor) {
|
|
23
|
+
if (!dialog) {
|
|
24
|
+
throw new Error('runDialog(): missing dialog');
|
|
25
|
+
}
|
|
26
|
+
if (!context) {
|
|
27
|
+
throw new Error('runDialog(): missing context');
|
|
28
|
+
}
|
|
29
|
+
if (!context.activity) {
|
|
30
|
+
throw new Error('runDialog(): missing context.activity');
|
|
31
|
+
}
|
|
32
|
+
if (!accessor) {
|
|
33
|
+
throw new Error('runDialog(): missing accessor');
|
|
34
|
+
}
|
|
35
|
+
const dialogSet = new dialogSet_1.DialogSet(accessor);
|
|
36
|
+
dialogSet.add(dialog);
|
|
37
|
+
const dialogContext = await dialogSet.createContext(context);
|
|
38
|
+
await internalRun(context, dialog.id, dialogContext);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @param context The TurnContext for the turn.
|
|
42
|
+
* @param dialogId The dialog ID.
|
|
43
|
+
* @param dialogContext The DialogContext for the current turn of conversation.
|
|
44
|
+
* @param dialogStateManagerConfiguration Configuration for the dialog state manager.
|
|
45
|
+
* @returns {Promise<DialogTurnResult>} a promise resolving to the dialog turn result.
|
|
46
|
+
*/
|
|
47
|
+
async function internalRun(context, dialogId, dialogContext, dialogStateManagerConfiguration) {
|
|
48
|
+
// map TurnState into root dialog context.services
|
|
49
|
+
context.turnState.forEach((service, key) => {
|
|
50
|
+
dialogContext.services.push(key, service);
|
|
51
|
+
});
|
|
52
|
+
const dialogStateManager = new memory_1.DialogStateManager(dialogContext, dialogStateManagerConfiguration);
|
|
53
|
+
await dialogStateManager.loadAllScopes();
|
|
54
|
+
dialogContext.context.turnState.push('DialogStateManager', dialogStateManager);
|
|
55
|
+
let dialogTurnResult = null;
|
|
56
|
+
// Loop as long as we are getting valid OnError handled we should continue executing the actions for the turn.
|
|
57
|
+
// NOTE: We loop around this block because each pass through we either complete the turn and break out of the loop
|
|
58
|
+
// or we have had an exception AND there was an OnError action which captured the error. We need to continue the
|
|
59
|
+
// turn based on the actions the OnError handler introduced.
|
|
60
|
+
let endOfTurn = false;
|
|
61
|
+
while (!endOfTurn) {
|
|
62
|
+
try {
|
|
63
|
+
dialogTurnResult = await innerRun(context, dialogId, dialogContext);
|
|
64
|
+
// turn successfully completed, break the loop
|
|
65
|
+
endOfTurn = true;
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
// fire error event, bubbling from the leaf.
|
|
69
|
+
const handled = await dialogContext.emitEvent(dialogEvents_1.DialogEvents.error, err, true, true);
|
|
70
|
+
if (!handled) {
|
|
71
|
+
// error was NOT handled, throw the exception and end the turn.
|
|
72
|
+
// (This will trigger the Adapter.OnError handler and end the entire dialog stack)
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// save all state scopes to their respective agentState locations.
|
|
78
|
+
await dialogStateManager.saveAllChanges();
|
|
79
|
+
// return the redundant result because the DialogManager contract expects it
|
|
80
|
+
return dialogTurnResult;
|
|
81
|
+
}
|
|
82
|
+
async function innerRun(context, dialogId, dialogContext) {
|
|
83
|
+
// Continue or start the dialog.
|
|
84
|
+
let result = await dialogContext.continueDialog();
|
|
85
|
+
if (result.status === dialogTurnStatus_1.DialogTurnStatus.empty) {
|
|
86
|
+
result = await dialogContext.beginDialog(dialogId);
|
|
87
|
+
}
|
|
88
|
+
await sendStateSnapshotTrace(dialogContext);
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Recursively walk up the dialog context stack to find the active DC.
|
|
93
|
+
*
|
|
94
|
+
* @param dialogContext DialogContext for the current turn of conversation with the user.
|
|
95
|
+
* @returns Active DialogContext.
|
|
96
|
+
*/
|
|
97
|
+
function getActiveDialogContext(dialogContext) {
|
|
98
|
+
const child = dialogContext.child;
|
|
99
|
+
if (!child) {
|
|
100
|
+
return dialogContext;
|
|
101
|
+
}
|
|
102
|
+
return getActiveDialogContext(child);
|
|
103
|
+
}
|
|
104
|
+
// Helper to send a trace activity with a memory snapshot of the active dialog DC.
|
|
105
|
+
const sendStateSnapshotTrace = async (dialogContext) => {
|
|
106
|
+
const traceLabel = 'Agent State';
|
|
107
|
+
// Send trace of memory
|
|
108
|
+
const snapshot = getActiveDialogContext(dialogContext).state.getMemorySnapshot();
|
|
109
|
+
const traceActivity = new agents_hosting_1.Activity(agents_hosting_1.ActivityTypes.Trace);
|
|
110
|
+
traceActivity.name = 'AgentState';
|
|
111
|
+
traceActivity.label = 'https://www.botframework.com/schemas/botState';
|
|
112
|
+
traceActivity.value = snapshot;
|
|
113
|
+
traceActivity.label = traceLabel;
|
|
114
|
+
await dialogContext.context.sendActivity(traceActivity);
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=dialogHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogHelper.js","sourceRoot":"","sources":["../../src/dialogHelper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAuBH,8BA2BC;AASD,kCA6CC;AAwBD,wDAOC;AArID,8DAKkC;AAGlC,iDAA6C;AAC7C,2CAAuC;AACvC,qCAA8E;AAE9E,yDAAqD;AAErD;;;;;;GAMG;AACI,KAAK,UAAU,SAAS,CAC7B,MAAc,EACd,OAAoB,EACpB,QAAiD;IAEjD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;IAChD,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;IACjD,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;IAC1D,CAAC;IAED,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,QAAQ,CAAC,CAAA;IACzC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAErB,MAAM,aAAa,GAAG,MAAM,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAE5D,MAAM,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE,aAAa,CAAC,CAAA;AACtD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the stack.
|
|
3
|
+
*
|
|
4
|
+
* @template T Optional. The type that represents state information for the dialog.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This contains information for a specific instance of a dialog on a dialog stack.
|
|
8
|
+
* The dialog stack is associated with a specific dialog context and dialog set.
|
|
9
|
+
* Information about the dialog stack as a whole is persisted to storage using a dialog state object.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export interface DialogInstance<T = any> {
|
|
13
|
+
/**
|
|
14
|
+
* ID of this dialog
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* Dialog state is associated with a specific dialog set.
|
|
18
|
+
* This ID is the the dialog's Dialog.id within that dialog set.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
id: string;
|
|
22
|
+
/**
|
|
23
|
+
* The state information for this instance of this dialog.
|
|
24
|
+
*/
|
|
25
|
+
state: T;
|
|
26
|
+
/**
|
|
27
|
+
* Hash code used to detect that a dialog has changed since the curent instance was started.
|
|
28
|
+
*/
|
|
29
|
+
version?: string;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogInstance.js","sourceRoot":"","sources":["../../src/dialogInstance.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { TurnContext, AgentState, ConversationState, UserState, TurnContextStateCollection } from '@microsoft/agents-hosting';
|
|
6
|
+
import { Configurable } from './configurable';
|
|
7
|
+
import { DialogSet } from './dialogSet';
|
|
8
|
+
import { Dialog } from './dialog';
|
|
9
|
+
import { DialogStateManagerConfiguration } from './memory';
|
|
10
|
+
import { DialogTurnResult } from './dialogTurnResult';
|
|
11
|
+
export interface DialogManagerResult {
|
|
12
|
+
turnResult: DialogTurnResult;
|
|
13
|
+
}
|
|
14
|
+
export interface DialogManagerConfiguration {
|
|
15
|
+
conversationState: AgentState;
|
|
16
|
+
rootDialog: Dialog;
|
|
17
|
+
userState?: UserState;
|
|
18
|
+
expireAfter?: number;
|
|
19
|
+
stateConfiguration?: DialogStateManagerConfiguration;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Class which runs the dialog system.
|
|
23
|
+
*
|
|
24
|
+
* @deprecated This class will be deprecated.
|
|
25
|
+
*/
|
|
26
|
+
export declare class DialogManager extends Configurable {
|
|
27
|
+
private _rootDialogId;
|
|
28
|
+
private readonly _dialogStateProperty;
|
|
29
|
+
private readonly _initialTurnState;
|
|
30
|
+
/**
|
|
31
|
+
* Creates an instance of the DialogManager class.
|
|
32
|
+
*
|
|
33
|
+
* @param rootDialog Optional, root Dialog to use.
|
|
34
|
+
* @param dialogStateProperty Optional, alternate name for the dialogState property. (Default is "DialogStateProperty")
|
|
35
|
+
*/
|
|
36
|
+
constructor(rootDialog?: Dialog, dialogStateProperty?: string);
|
|
37
|
+
conversationState: ConversationState;
|
|
38
|
+
userState?: UserState;
|
|
39
|
+
/**
|
|
40
|
+
* Values that will be copied to the `TurnContext.turnState` at the beginning of each turn.
|
|
41
|
+
*
|
|
42
|
+
* @returns The turn state collection.
|
|
43
|
+
*/
|
|
44
|
+
get initialTurnState(): TurnContextStateCollection;
|
|
45
|
+
/**
|
|
46
|
+
* Root dialog to start from [onTurn()](#onturn) method.
|
|
47
|
+
*/
|
|
48
|
+
set rootDialog(value: Dialog);
|
|
49
|
+
/**
|
|
50
|
+
* Gets the root Dialog ID.
|
|
51
|
+
*
|
|
52
|
+
* @returns The root Dialog ID.
|
|
53
|
+
*/
|
|
54
|
+
get rootDialog(): Dialog;
|
|
55
|
+
dialogs: DialogSet;
|
|
56
|
+
stateConfiguration?: DialogStateManagerConfiguration;
|
|
57
|
+
expireAfter?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Set configuration settings.
|
|
60
|
+
*
|
|
61
|
+
* @param config Configuration settings to apply.
|
|
62
|
+
* @returns The cofigured DialogManager context.
|
|
63
|
+
*/
|
|
64
|
+
configure(config: Partial<DialogManagerConfiguration>): this;
|
|
65
|
+
/**
|
|
66
|
+
* Runs dialog system in the context of a TurnContext.
|
|
67
|
+
*
|
|
68
|
+
* @param context TurnContext for the current turn of conversation with the user.
|
|
69
|
+
* @returns Result of running the logic against the activity.
|
|
70
|
+
*/
|
|
71
|
+
onTurn(context: TurnContext): Promise<DialogManagerResult>;
|
|
72
|
+
private registerContainerDialogs;
|
|
73
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DialogManager = void 0;
|
|
8
|
+
const agents_hosting_1 = require("@microsoft/agents-hosting");
|
|
9
|
+
const agentStateSet_1 = require("./agentStateSet");
|
|
10
|
+
const configurable_1 = require("./configurable");
|
|
11
|
+
const dialogContainer_1 = require("./dialogContainer");
|
|
12
|
+
const dialogContext_1 = require("./dialogContext");
|
|
13
|
+
const dialogHelper_1 = require("./dialogHelper");
|
|
14
|
+
const dialogSet_1 = require("./dialogSet");
|
|
15
|
+
const dialogTurnStateConstants_1 = require("./dialogTurnStateConstants");
|
|
16
|
+
const LAST_ACCESS = '_lastAccess';
|
|
17
|
+
const CONVERSATION_STATE = 'ConversationState';
|
|
18
|
+
const USER_STATE = 'UserState';
|
|
19
|
+
/**
|
|
20
|
+
* Class which runs the dialog system.
|
|
21
|
+
*
|
|
22
|
+
* @deprecated This class will be deprecated.
|
|
23
|
+
*/
|
|
24
|
+
class DialogManager extends configurable_1.Configurable {
|
|
25
|
+
/**
|
|
26
|
+
* Creates an instance of the DialogManager class.
|
|
27
|
+
*
|
|
28
|
+
* @param rootDialog Optional, root Dialog to use.
|
|
29
|
+
* @param dialogStateProperty Optional, alternate name for the dialogState property. (Default is "DialogStateProperty")
|
|
30
|
+
*/
|
|
31
|
+
constructor(rootDialog, dialogStateProperty) {
|
|
32
|
+
super();
|
|
33
|
+
this._initialTurnState = new agents_hosting_1.TurnContextStateCollection();
|
|
34
|
+
this.dialogs = new dialogSet_1.DialogSet();
|
|
35
|
+
if (rootDialog) {
|
|
36
|
+
this.rootDialog = rootDialog;
|
|
37
|
+
}
|
|
38
|
+
this._dialogStateProperty = dialogStateProperty !== null && dialogStateProperty !== void 0 ? dialogStateProperty : 'DialogState';
|
|
39
|
+
this._initialTurnState.set(dialogTurnStateConstants_1.DialogTurnStateConstants.dialogManager, this);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Values that will be copied to the `TurnContext.turnState` at the beginning of each turn.
|
|
43
|
+
*
|
|
44
|
+
* @returns The turn state collection.
|
|
45
|
+
*/
|
|
46
|
+
get initialTurnState() {
|
|
47
|
+
return this._initialTurnState;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Root dialog to start from [onTurn()](#onturn) method.
|
|
51
|
+
*/
|
|
52
|
+
set rootDialog(value) {
|
|
53
|
+
this.dialogs = new dialogSet_1.DialogSet();
|
|
54
|
+
if (value) {
|
|
55
|
+
this._rootDialogId = value.id;
|
|
56
|
+
this.dialogs.add(value);
|
|
57
|
+
this.registerContainerDialogs(this.rootDialog, false);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this._rootDialogId = undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Gets the root Dialog ID.
|
|
65
|
+
*
|
|
66
|
+
* @returns The root Dialog ID.
|
|
67
|
+
*/
|
|
68
|
+
get rootDialog() {
|
|
69
|
+
return this._rootDialogId ? this.dialogs.find(this._rootDialogId) : undefined;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Set configuration settings.
|
|
73
|
+
*
|
|
74
|
+
* @param config Configuration settings to apply.
|
|
75
|
+
* @returns The cofigured DialogManager context.
|
|
76
|
+
*/
|
|
77
|
+
configure(config) {
|
|
78
|
+
return super.configure(config);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Runs dialog system in the context of a TurnContext.
|
|
82
|
+
*
|
|
83
|
+
* @param context TurnContext for the current turn of conversation with the user.
|
|
84
|
+
* @returns Result of running the logic against the activity.
|
|
85
|
+
*/
|
|
86
|
+
async onTurn(context) {
|
|
87
|
+
// Ensure properly configured
|
|
88
|
+
if (!this._rootDialogId) {
|
|
89
|
+
throw new Error("DialogManager.onTurn: the agent's 'rootDialog' has not been configured.");
|
|
90
|
+
}
|
|
91
|
+
// Copy initial turn state to context
|
|
92
|
+
this.initialTurnState.forEach((value, key) => {
|
|
93
|
+
context.turnState.set(key, value);
|
|
94
|
+
});
|
|
95
|
+
const agentStateSet = new agentStateSet_1.AgentStateSet();
|
|
96
|
+
if (!this.conversationState) {
|
|
97
|
+
this.conversationState = context.turnState.get(CONVERSATION_STATE);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
context.turnState.set(CONVERSATION_STATE, this.conversationState);
|
|
101
|
+
}
|
|
102
|
+
if (!this.conversationState) {
|
|
103
|
+
throw new Error("DialogManager.onTurn: the agent's 'conversationState' has not been configured.");
|
|
104
|
+
}
|
|
105
|
+
agentStateSet.add(this.conversationState);
|
|
106
|
+
if (!this.userState) {
|
|
107
|
+
this.userState = context.turnState.get(USER_STATE);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
context.turnState.set(USER_STATE, this.userState);
|
|
111
|
+
}
|
|
112
|
+
if (this.userState) {
|
|
113
|
+
agentStateSet.add(this.userState);
|
|
114
|
+
}
|
|
115
|
+
// Get last access
|
|
116
|
+
const lastAccessProperty = this.conversationState.createProperty(LAST_ACCESS);
|
|
117
|
+
const lastAccess = new Date(await lastAccessProperty.get(context, new Date().toISOString()));
|
|
118
|
+
// Check for expired conversation
|
|
119
|
+
const now = new Date();
|
|
120
|
+
if (this.expireAfter !== undefined && now.getTime() - lastAccess.getTime() >= this.expireAfter) {
|
|
121
|
+
// Clear conversation state
|
|
122
|
+
await this.conversationState.clear(context);
|
|
123
|
+
}
|
|
124
|
+
// Update last access time
|
|
125
|
+
await lastAccessProperty.set(context, lastAccess.toISOString());
|
|
126
|
+
// get dialog stack
|
|
127
|
+
const dialogsProperty = this.conversationState.createProperty(this._dialogStateProperty);
|
|
128
|
+
const dialogState = await dialogsProperty.get(context, {});
|
|
129
|
+
// Create DialogContext
|
|
130
|
+
const dc = new dialogContext_1.DialogContext(this.dialogs, context, dialogState);
|
|
131
|
+
// Call the common dialog "continue/begin" execution pattern shared with the classic RunAsync extension method
|
|
132
|
+
const turnResult = await (0, dialogHelper_1.internalRun)(context, this._rootDialogId, dc, this.stateConfiguration);
|
|
133
|
+
// Save agentState changes
|
|
134
|
+
await agentStateSet.saveAllChanges(dc.context, false);
|
|
135
|
+
return { turnResult };
|
|
136
|
+
}
|
|
137
|
+
// Recursively traverses the dialog tree and registers intances of `DialogContainer` in the `DialogSet`
|
|
138
|
+
// for this `DialogManager` instance.
|
|
139
|
+
registerContainerDialogs(dialog, registerRoot = true) {
|
|
140
|
+
if (!(dialog instanceof dialogContainer_1.DialogContainer)) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const container = dialog;
|
|
144
|
+
if (registerRoot) {
|
|
145
|
+
if (this.dialogs.getDialogs().find((dlg) => dlg === container)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this.dialogs.add(container);
|
|
149
|
+
}
|
|
150
|
+
container.dialogs.getDialogs().forEach((inner) => {
|
|
151
|
+
this.registerContainerDialogs(inner);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.DialogManager = DialogManager;
|
|
156
|
+
//# sourceMappingURL=dialogManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogManager.js","sourceRo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,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,CAAA;QAEhE,8GAA8G;QAC9G,MAAM,UAAU,GAAG,MAAM,IAAA,0BAAW,EAAC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,EAAE,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAA;QAE9F,0BAA0B;QAC1B,MAAM,aAAa,CAAC,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QAErD,OAAO,EAAE,UAAU,EAAE,CAAA;IACvB,CAAC;IAED,uGAAuG;IACvG,qCAAqC;IAC7B,wBAAwB,CAAE,MAAc,EAAE,YAAY,GAAG,IAAI;QACnE,IAAI,CAAC,CAAC,MAAM,YAAY,iCAAe,CAAC,EAAE,CAAC;YACzC,OAAM;QACR,CAAC;QACD,MAAM,SAAS,GAAG,MAAM,CAAA;QACxB,IAAI,YAAY,EAAE,CAAC;YACjB,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,SAAS,CAAC,EAAE,CAAC;gBAC/D,OAAM;YACR,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAC7B,CAAC;QAED,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC/C,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAA;QACtC,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AA7JD,sCA6JC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Indicates why a dialog method is being called.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Use a dialog context to control the dialogs in a dialog set. The dialog context will pass a reference to itself
|
|
6
|
+
* to the dialog method it calls. It also passes in the _reason_ why the specific method is being called.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export declare enum DialogReason {
|
|
10
|
+
/**
|
|
11
|
+
* The dialog is being started from DialogContext.beginDialog or DialogContext.replaceDialog.
|
|
12
|
+
*/
|
|
13
|
+
beginCalled = "beginCalled",
|
|
14
|
+
/**
|
|
15
|
+
* The dialog is being continued from DialogContext.continueDialog.
|
|
16
|
+
*/
|
|
17
|
+
continueCalled = "continueCalled",
|
|
18
|
+
/**
|
|
19
|
+
* The dialog is being ended from DialogContext.endDialog.
|
|
20
|
+
*/
|
|
21
|
+
endCalled = "endCalled",
|
|
22
|
+
/**
|
|
23
|
+
* The dialog is being ended from DialogContext.replaceDialog.
|
|
24
|
+
*/
|
|
25
|
+
replaceCalled = "replaceCalled",
|
|
26
|
+
/**
|
|
27
|
+
* The dialog is being cancelled from DialogContext.cancelAllDialogs.
|
|
28
|
+
*/
|
|
29
|
+
cancelCalled = "cancelCalled",
|
|
30
|
+
/**
|
|
31
|
+
* A step in a WaterfallDialog is being called
|
|
32
|
+
* because the previous step in the waterfall dialog called WaterfallStepContext.next.
|
|
33
|
+
*/
|
|
34
|
+
nextCalled = "nextCalled"
|
|
35
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DialogReason = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Indicates why a dialog method is being called.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Use a dialog context to control the dialogs in a dialog set. The dialog context will pass a reference to itself
|
|
9
|
+
* to the dialog method it calls. It also passes in the _reason_ why the specific method is being called.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
var DialogReason;
|
|
13
|
+
(function (DialogReason) {
|
|
14
|
+
/**
|
|
15
|
+
* The dialog is being started from DialogContext.beginDialog or DialogContext.replaceDialog.
|
|
16
|
+
*/
|
|
17
|
+
DialogReason["beginCalled"] = "beginCalled";
|
|
18
|
+
/**
|
|
19
|
+
* The dialog is being continued from DialogContext.continueDialog.
|
|
20
|
+
*/
|
|
21
|
+
DialogReason["continueCalled"] = "continueCalled";
|
|
22
|
+
/**
|
|
23
|
+
* The dialog is being ended from DialogContext.endDialog.
|
|
24
|
+
*/
|
|
25
|
+
DialogReason["endCalled"] = "endCalled";
|
|
26
|
+
/**
|
|
27
|
+
* The dialog is being ended from DialogContext.replaceDialog.
|
|
28
|
+
*/
|
|
29
|
+
DialogReason["replaceCalled"] = "replaceCalled";
|
|
30
|
+
/**
|
|
31
|
+
* The dialog is being cancelled from DialogContext.cancelAllDialogs.
|
|
32
|
+
*/
|
|
33
|
+
DialogReason["cancelCalled"] = "cancelCalled";
|
|
34
|
+
/**
|
|
35
|
+
* A step in a WaterfallDialog is being called
|
|
36
|
+
* because the previous step in the waterfall dialog called WaterfallStepContext.next.
|
|
37
|
+
*/
|
|
38
|
+
DialogReason["nextCalled"] = "nextCalled";
|
|
39
|
+
})(DialogReason || (exports.DialogReason = DialogReason = {}));
|
|
40
|
+
//# sourceMappingURL=dialogReason.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogReason.js","sourceRoot":"","sources":["../../src/dialogReason.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,IAAY,YA+BX;AA/BD,WAAY,YAAY;IACtB;;WAEO;IACP,2CAA2B,CAAA;IAE3B;;WAEO;IACP,iDAAiC,CAAA;IAEjC;;WAEO;IACP,uCAAuB,CAAA;IAEvB;;WAEO;IACP,+CAA+B,CAAA;IAE/B;;WAEO;IACP,6CAA6B,CAAA;IAE7B;;;WAGO;IACP,yCAAyB,CAAA;AAC3B,CAAC,EA/BW,YAAY,4BAAZ,YAAY,QA+BvB"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { AgentStatePropertyAccessor, TurnContext } from '@microsoft/agents-hosting';
|
|
6
|
+
import { Dialog } from './dialog';
|
|
7
|
+
import { DialogContext, DialogState } from './dialogContext';
|
|
8
|
+
export interface DialogDependencies {
|
|
9
|
+
/**
|
|
10
|
+
* Returns a dialogs child dialog dependencies so they can be added to a containers dialog set.
|
|
11
|
+
*/
|
|
12
|
+
getDependencies(): Dialog[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A related set of dialogs that can all call each other.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* The constructor for the dialog set should be passed a state property that will be used to
|
|
19
|
+
* persist the dialog stack for the set:
|
|
20
|
+
*
|
|
21
|
+
* To interact with the sets dialogs you can call createcontext with the
|
|
22
|
+
* current `TurnContext`. That will create a `DialogContext` that can be used to start or continue
|
|
23
|
+
* execution of the sets dialogs:
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export declare class DialogSet {
|
|
27
|
+
private readonly dialogs;
|
|
28
|
+
private readonly dialogState;
|
|
29
|
+
private _version;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new DialogSet instance.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* If the `dialogState` property is not passed in, calls to createcontext
|
|
35
|
+
* will return an error. You will need to create a `DialogContext` for the set manually and
|
|
36
|
+
* pass in your own state object for persisting the sets dialog stack:
|
|
37
|
+
*
|
|
38
|
+
* @param dialogState (Optional) state property used to persist the sets dialog stack.
|
|
39
|
+
*/
|
|
40
|
+
constructor(dialogState?: AgentStatePropertyAccessor<DialogState>);
|
|
41
|
+
/**
|
|
42
|
+
* Returns a 32-bit hash of the all the `Dialog.version` values in the set.
|
|
43
|
+
*
|
|
44
|
+
* @returns A version that will change when any of the child dialogs version changes.
|
|
45
|
+
* @remarks
|
|
46
|
+
* This hash is persisted to state storage and used to detect changes to a dialog set.
|
|
47
|
+
*/
|
|
48
|
+
getVersion(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Adds a new dialog or prompt to the set.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* If the `Dialog.id` being added already exists in the set, the dialogs id will be updated to
|
|
54
|
+
* include a suffix which makes it unique. So adding 2 dialogs named "duplicate" to the set
|
|
55
|
+
* would result in the first one having an id of "duplicate" and the second one having an id
|
|
56
|
+
* of "duplicate2".
|
|
57
|
+
* @param dialog The dialog or prompt to add.
|
|
58
|
+
* If a telemetryClient is present on the dialog set, it will be added to each dialog.
|
|
59
|
+
* @returns The dialog set after the operation is complete.
|
|
60
|
+
*/
|
|
61
|
+
add<T extends Dialog>(dialog: T): this;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a dialog context which can be used to work with the dialogs in the set.
|
|
64
|
+
*
|
|
65
|
+
* @param context Context for the current turn of conversation with the user.
|
|
66
|
+
* @returns A promise representing the asynchronous operation.
|
|
67
|
+
*/
|
|
68
|
+
createContext(context: TurnContext): Promise<DialogContext>;
|
|
69
|
+
/**
|
|
70
|
+
* Finds a dialog that was previously added to the set using add.
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* This example finds a dialog named "greeting":
|
|
74
|
+
*
|
|
75
|
+
* @param dialogId ID of the dialog or prompt to lookup.
|
|
76
|
+
* @returns The dialog if found; otherwise undefined.
|
|
77
|
+
*/
|
|
78
|
+
find(dialogId: string): Dialog | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Gets the Dialogs of the set.
|
|
81
|
+
*
|
|
82
|
+
* @returns {Dialog} An array of Dialog.
|
|
83
|
+
*/
|
|
84
|
+
getDialogs(): Dialog[];
|
|
85
|
+
}
|