@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,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComponentDialog = void 0;
|
|
4
|
+
const dialog_1 = require("./dialog");
|
|
5
|
+
const dialogContext_1 = require("./dialogContext");
|
|
6
|
+
const dialogContainer_1 = require("./dialogContainer");
|
|
7
|
+
const dialogReason_1 = require("./dialogReason");
|
|
8
|
+
const dialogTurnStatus_1 = require("./dialogTurnStatus");
|
|
9
|
+
const PERSISTED_DIALOG_STATE = 'dialogs';
|
|
10
|
+
/**
|
|
11
|
+
* Base class for a dialog that contains other child dialogs.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* Component dialogs let you break your agent's logic up into components that can themselves be added
|
|
15
|
+
* as a dialog to another `ComponentDialog` or `DialogSet`. Components can also be exported as part
|
|
16
|
+
* of a node package and used within other agents.
|
|
17
|
+
*
|
|
18
|
+
* @param O (Optional) options that can be passed into the `DialogContext.beginDialog()` method.
|
|
19
|
+
*/
|
|
20
|
+
class ComponentDialog extends dialogContainer_1.DialogContainer {
|
|
21
|
+
/**
|
|
22
|
+
* Called when the dialog is started and pushed onto the parent's dialog stack.
|
|
23
|
+
* By default, this calls the
|
|
24
|
+
* Dialog.BeginDialogAsync(DialogContext, object, CancellationToken) method
|
|
25
|
+
* of the component dialog's initial dialog, as defined by InitialDialogId.
|
|
26
|
+
* Override this method in a derived class to implement interrupt logic.
|
|
27
|
+
*
|
|
28
|
+
* @param outerDialogContext The parent DialogContext for the current turn of conversation.
|
|
29
|
+
* @param options Optional, initial information to pass to the dialog.
|
|
30
|
+
* @returns A Promise representing the asynchronous operation.
|
|
31
|
+
* @remarks
|
|
32
|
+
* If the task is successful, the result indicates whether the dialog is still
|
|
33
|
+
* active after the turn has been processed by the dialog.
|
|
34
|
+
*/
|
|
35
|
+
async beginDialog(outerDialogContext, options) {
|
|
36
|
+
await this.checkForVersionChange(outerDialogContext);
|
|
37
|
+
// Start the inner dialog.
|
|
38
|
+
const innerDC = this.createChildContext(outerDialogContext);
|
|
39
|
+
const turnResult = await this.onBeginDialog(innerDC, options);
|
|
40
|
+
// Check for end of inner dialog
|
|
41
|
+
if (turnResult.status !== dialogTurnStatus_1.DialogTurnStatus.waiting) {
|
|
42
|
+
if (turnResult.status === dialogTurnStatus_1.DialogTurnStatus.cancelled) {
|
|
43
|
+
await this.endComponent(outerDialogContext, turnResult.result);
|
|
44
|
+
const cancelledTurnResult = {
|
|
45
|
+
status: dialogTurnStatus_1.DialogTurnStatus.cancelled,
|
|
46
|
+
result: turnResult.result,
|
|
47
|
+
};
|
|
48
|
+
return cancelledTurnResult;
|
|
49
|
+
}
|
|
50
|
+
// Return result to calling dialog
|
|
51
|
+
return await this.endComponent(outerDialogContext, turnResult.result);
|
|
52
|
+
}
|
|
53
|
+
// Just signal end of turn
|
|
54
|
+
return dialog_1.Dialog.EndOfTurn;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Called when the dialog is _continued_, where it is the active dialog and the
|
|
58
|
+
* user replies with a new Activity.
|
|
59
|
+
* If this method is *not* overridden, the dialog automatically ends when the user replies.
|
|
60
|
+
*
|
|
61
|
+
* @param outerDialogContext The parent DialogContext for the current turn of conversation.
|
|
62
|
+
* @returns A Promise representing the asynchronous operation.
|
|
63
|
+
* @remarks
|
|
64
|
+
* If the task is successful, the result indicates whether the dialog is still
|
|
65
|
+
* active after the turn has been processed by the dialog. The result may also contain a
|
|
66
|
+
* return value.
|
|
67
|
+
*/
|
|
68
|
+
async continueDialog(outerDialogContext) {
|
|
69
|
+
await this.checkForVersionChange(outerDialogContext);
|
|
70
|
+
// Continue execution of inner dialog.
|
|
71
|
+
const innerDC = this.createChildContext(outerDialogContext);
|
|
72
|
+
const turnResult = await this.onContinueDialog(innerDC);
|
|
73
|
+
// Check for end of inner dialog
|
|
74
|
+
if (turnResult.status !== dialogTurnStatus_1.DialogTurnStatus.waiting) {
|
|
75
|
+
// Return result to calling dialog
|
|
76
|
+
return await this.endComponent(outerDialogContext, turnResult.result);
|
|
77
|
+
}
|
|
78
|
+
// Just signal end of turn
|
|
79
|
+
return dialog_1.Dialog.EndOfTurn;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Called when a child dialog on the parent's dialog stack completed this turn, returning
|
|
83
|
+
* control to this dialog component.
|
|
84
|
+
*
|
|
85
|
+
* @param outerDialogContext The DialogContext for the current turn of conversation.
|
|
86
|
+
* @param _reason Reason why the dialog resumed.
|
|
87
|
+
* @param _result Optional, value returned from the dialog that was called. The type
|
|
88
|
+
* of the value returned is dependent on the child dialog.
|
|
89
|
+
* @returns A Promise representing the asynchronous operation.
|
|
90
|
+
* @remarks
|
|
91
|
+
* If the task is successful, the result indicates whether this dialog is still
|
|
92
|
+
* active after this dialog turn has been processed.
|
|
93
|
+
* Generally, the child dialog was started with a call to
|
|
94
|
+
* beginDialog(DialogContext, object) in the parent's
|
|
95
|
+
* context. However, if the DialogContext.replaceDialog(string, object) method
|
|
96
|
+
* is called, the logical child dialog may be different than the original.
|
|
97
|
+
* If this method is *not* overridden, the dialog automatically calls its
|
|
98
|
+
* RepromptDialog(ITurnContext, DialogInstance) when the user replies.
|
|
99
|
+
*/
|
|
100
|
+
async resumeDialog(outerDialogContext, _reason, _result) {
|
|
101
|
+
await this.checkForVersionChange(outerDialogContext);
|
|
102
|
+
// Containers are typically leaf nodes on the stack but the dev is free to push other dialogs
|
|
103
|
+
// on top of the stack which will result in the container receiving an unexpected call to
|
|
104
|
+
// resumeDialog() when the pushed on dialog ends.
|
|
105
|
+
// To avoid the container prematurely ending we need to implement this method and simply
|
|
106
|
+
// ask our inner dialog stack to re-prompt.
|
|
107
|
+
await this.repromptDialog(outerDialogContext.context, outerDialogContext.activeDialog);
|
|
108
|
+
return dialog_1.Dialog.EndOfTurn;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Called when the dialog should re-prompt the user for input.
|
|
112
|
+
*
|
|
113
|
+
* @param context The TurnContext object for this turn.
|
|
114
|
+
* @param instance State information for this dialog.
|
|
115
|
+
* @returns A Promise representing the asynchronous operation.
|
|
116
|
+
*/
|
|
117
|
+
async repromptDialog(context, instance) {
|
|
118
|
+
// Forward to inner dialogs
|
|
119
|
+
const innerDC = this.createInnerDC(context, instance);
|
|
120
|
+
await innerDC.repromptDialog();
|
|
121
|
+
// Notify component.
|
|
122
|
+
await this.onRepromptDialog(context, instance);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Called when the Dialog is ending.
|
|
126
|
+
*
|
|
127
|
+
* @param context The TurnContext object for this turn.
|
|
128
|
+
* @param instance State information associated with the instance of this component Dialog on its parent's dialog stack.
|
|
129
|
+
* @param reason Reason why the Dialog ended.
|
|
130
|
+
* @returns A Promise representing the asynchronous operation.
|
|
131
|
+
* @remarks When this method is called from the parent dialog's context, the component Dialog
|
|
132
|
+
* cancels all of the dialogs on its inner dialog stack before ending.
|
|
133
|
+
*/
|
|
134
|
+
async endDialog(context, instance, reason) {
|
|
135
|
+
// Forward cancel to inner dialogs
|
|
136
|
+
if (reason === dialogReason_1.DialogReason.cancelCalled) {
|
|
137
|
+
const innerDC = this.createInnerDC(context, instance);
|
|
138
|
+
await innerDC.cancelAllDialogs();
|
|
139
|
+
}
|
|
140
|
+
// Notify component
|
|
141
|
+
await this.onEndDialog(context, instance, reason);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Adds a child Dialog or prompt to the components internal DialogSet.
|
|
145
|
+
*
|
|
146
|
+
* @param dialog The child Dialog or prompt to add.
|
|
147
|
+
* @returns The ComponentDialog after the operation is complete.
|
|
148
|
+
* @remarks
|
|
149
|
+
* The Dialog.id of the first child added to the component will be assigned to the initialDialogId property.
|
|
150
|
+
*/
|
|
151
|
+
addDialog(dialog) {
|
|
152
|
+
this.dialogs.add(dialog);
|
|
153
|
+
if (this.initialDialogId === undefined) {
|
|
154
|
+
this.initialDialogId = dialog.id;
|
|
155
|
+
}
|
|
156
|
+
return this;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Creates the inner dialog context
|
|
160
|
+
*
|
|
161
|
+
* @param outerDialogContext the outer dialog context
|
|
162
|
+
* @returns The created Dialog Context.
|
|
163
|
+
*/
|
|
164
|
+
createChildContext(outerDialogContext) {
|
|
165
|
+
return this.createInnerDC(outerDialogContext, outerDialogContext.activeDialog);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Called anytime an instance of the component has been started.
|
|
169
|
+
*
|
|
170
|
+
* @remarks
|
|
171
|
+
* SHOULD be overridden by components that wish to perform custom interruption logic. The
|
|
172
|
+
* default implementation calls `innerDC.beginDialog()` with the dialog assigned to
|
|
173
|
+
* initialdialogid.
|
|
174
|
+
* @param innerDialogContext Dialog context for the components internal `DialogSet`.
|
|
175
|
+
* @param options (Optional) options that were passed to the component by its parent.
|
|
176
|
+
* @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
|
|
177
|
+
*/
|
|
178
|
+
onBeginDialog(innerDialogContext, options) {
|
|
179
|
+
return innerDialogContext.beginDialog(this.initialDialogId, options);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Called anytime a multi-turn component receives additional activities.
|
|
183
|
+
*
|
|
184
|
+
* @remarks
|
|
185
|
+
* SHOULD be overridden by components that wish to perform custom interruption logic. The
|
|
186
|
+
* default implementation calls `innerDC.continueDialog()`.
|
|
187
|
+
* @param innerDC Dialog context for the components internal `DialogSet`.
|
|
188
|
+
* @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
|
|
189
|
+
*/
|
|
190
|
+
onContinueDialog(innerDC) {
|
|
191
|
+
return innerDC.continueDialog();
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Called when the component is ending.
|
|
195
|
+
*
|
|
196
|
+
* @remarks
|
|
197
|
+
* If the `reason` code is equal to `DialogReason.cancelCalled`, then any active child dialogs
|
|
198
|
+
* will be cancelled before this method is called.
|
|
199
|
+
* @param _context Context for the current turn of conversation.
|
|
200
|
+
* @param _instance The components instance data within its parents dialog stack.
|
|
201
|
+
* @param _reason The reason the component is ending.
|
|
202
|
+
* @returns A promise representing the asynchronous operation.
|
|
203
|
+
*/
|
|
204
|
+
onEndDialog(_context, _instance, _reason) {
|
|
205
|
+
return Promise.resolve();
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Called when the component has been requested to re-prompt the user for input.
|
|
209
|
+
*
|
|
210
|
+
* @remarks
|
|
211
|
+
* The active child dialog will have already been asked to reprompt before this method is called.
|
|
212
|
+
* @param _context Context for the current turn of conversation.
|
|
213
|
+
* @param _instance The instance of the current dialog.
|
|
214
|
+
* @returns A promise representing the asynchronous operation.
|
|
215
|
+
*/
|
|
216
|
+
onRepromptDialog(_context, _instance) {
|
|
217
|
+
return Promise.resolve();
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Called when the components last active child dialog ends and the component is ending.
|
|
221
|
+
*
|
|
222
|
+
* @remarks
|
|
223
|
+
* SHOULD be overridden by components that wish to perform custom logic before the component
|
|
224
|
+
* ends. The default implementation calls `outerDC.endDialog()` with the `result` returned
|
|
225
|
+
* from the last active child dialog.
|
|
226
|
+
* @param outerDC Dialog context for the parents `DialogSet`.
|
|
227
|
+
* @param result Result returned by the last active child dialog. Can be a value of `undefined`.
|
|
228
|
+
* @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
|
|
229
|
+
*/
|
|
230
|
+
endComponent(outerDC, result) {
|
|
231
|
+
return outerDC.endDialog(result);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* @private
|
|
235
|
+
* @param context TurnContext or DialogContext for the current turn of conversation with the user.
|
|
236
|
+
* @param instance DialogInstance which contains the current state information for this dialog.
|
|
237
|
+
* @returns A new DialogContext instance.
|
|
238
|
+
* @remarks
|
|
239
|
+
* You should only call this if you don't have a dc to work with (such as OnResume())
|
|
240
|
+
*/
|
|
241
|
+
createInnerDC(context, instance) {
|
|
242
|
+
if (!instance) {
|
|
243
|
+
const dialogInstance = { state: {} };
|
|
244
|
+
instance = dialogInstance;
|
|
245
|
+
}
|
|
246
|
+
const dialogState = instance.state[PERSISTED_DIALOG_STATE] || { dialogStack: [] };
|
|
247
|
+
instance.state[PERSISTED_DIALOG_STATE] = dialogState;
|
|
248
|
+
return new dialogContext_1.DialogContext(this.dialogs, context, dialogState);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
exports.ComponentDialog = ComponentDialog;
|
|
252
|
+
//# sourceMappingURL=componentDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentDialog.js","sourceRoot":"","sources":["../../src/componentDialog.ts"],"names":[],"mappings":";;;AAKA,qCAAiC;AACjC,mDAA+C;AAC/C,uDAAmD;AAEnD,iDAA6C;AAE7C,yDAAqD;AAErD,MAAM,sBAAsB,GAAG,SAAS,CAAA;AAExC;;;;;;;;;GASG;AACH,MAAa,eAAuC,SAAQ,iCAAkB;IAS5E;;;;;;;;;;;;;SAaK;IACL,KAAK,CAAC,WAAW,CAAE,kBAAiC,EAAE,OAAW;QAC/D,MAAM,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,CAAA;QAEpD,0BAA0B;QAC1B,MAAM,OAAO,GAAkB,IAAI,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAA;QAC1E,MAAM,UAAU,GAA0B,MAAM,IAA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C,CAAA;IAC7E,CAAC;CACF;AAxRD,0CAwRC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* ComponentRegistration is a signature class for discovering assets from components.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ComponentRegistration {
|
|
9
|
+
private static readonly _components;
|
|
10
|
+
/**
|
|
11
|
+
* Gets list of all ComponentRegistration objects registered.
|
|
12
|
+
*
|
|
13
|
+
* @returns A list of ComponentRegistration objects.
|
|
14
|
+
*/
|
|
15
|
+
static get components(): ComponentRegistration[];
|
|
16
|
+
/**
|
|
17
|
+
* Add a component, only one instance per type is allowed for components.
|
|
18
|
+
*
|
|
19
|
+
* @param componentRegistration The component to be registered.
|
|
20
|
+
*/
|
|
21
|
+
static add(componentRegistration: ComponentRegistration): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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.ComponentRegistration = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* ComponentRegistration is a signature class for discovering assets from components.
|
|
10
|
+
*/
|
|
11
|
+
class ComponentRegistration {
|
|
12
|
+
/**
|
|
13
|
+
* Gets list of all ComponentRegistration objects registered.
|
|
14
|
+
*
|
|
15
|
+
* @returns A list of ComponentRegistration objects.
|
|
16
|
+
*/
|
|
17
|
+
static get components() {
|
|
18
|
+
return Array.from(ComponentRegistration._components.values());
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Add a component, only one instance per type is allowed for components.
|
|
22
|
+
*
|
|
23
|
+
* @param componentRegistration The component to be registered.
|
|
24
|
+
*/
|
|
25
|
+
static add(componentRegistration) {
|
|
26
|
+
const name = componentRegistration.constructor.name;
|
|
27
|
+
ComponentRegistration._components.set(name, componentRegistration);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.ComponentRegistration = ComponentRegistration;
|
|
31
|
+
ComponentRegistration._components = new Map();
|
|
32
|
+
//# sourceMappingURL=componentRegistration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentRegistration.js","sourceRoot":"","sources":["../../src/componentRegistration.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AACH,MAAa,qBAAqB;IAGhC;;;;SAIK;IACL,MAAM,KAAK,UAAU;QACnB,OAAO,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAA;IAC/D,CAAC;IAED;;;;SAIK;IACL,MAAM,CAAC,GAAG,CAAE,qBAA4C;QACtD,MAAM,IAAI,GAAG,qBAAqB,CAAC,WAAW,CAAC,IAAI,CAAA;QACnD,qBAAqB,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAA;IACpE,CAAC;;AApBH,sDAqBC;AApByB,iCAAW,GAAuC,IAAI,GAAG,EAAiC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { Converter, ConverterFactory } from './converter';
|
|
6
|
+
/**
|
|
7
|
+
* Base class for all configurable classes.
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class Configurable {
|
|
10
|
+
/**
|
|
11
|
+
* Fluent method for configuring the object.
|
|
12
|
+
*
|
|
13
|
+
* @param config Configuration settings to apply.
|
|
14
|
+
* @returns The Configurable after the operation is complete.
|
|
15
|
+
*/
|
|
16
|
+
configure(config: Record<string, unknown>): this;
|
|
17
|
+
/**
|
|
18
|
+
* @param _property The key of the conditional selector configuration.
|
|
19
|
+
* @returns The converter for the selector configuration.
|
|
20
|
+
*/
|
|
21
|
+
getConverter(_property: string): Converter | ConverterFactory;
|
|
22
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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.Configurable = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Base class for all configurable classes.
|
|
10
|
+
*/
|
|
11
|
+
class Configurable {
|
|
12
|
+
/**
|
|
13
|
+
* Fluent method for configuring the object.
|
|
14
|
+
*
|
|
15
|
+
* @param config Configuration settings to apply.
|
|
16
|
+
* @returns The Configurable after the operation is complete.
|
|
17
|
+
*/
|
|
18
|
+
configure(config) {
|
|
19
|
+
for (const key in config) {
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(config, key)) {
|
|
21
|
+
const setting = config[`${key}`];
|
|
22
|
+
const converter = this.getConverter(key);
|
|
23
|
+
if (converter && typeof converter === 'object') {
|
|
24
|
+
this[`${key}`] = converter.convert(setting);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
if (Array.isArray(setting)) {
|
|
28
|
+
this[`${key}`] = setting;
|
|
29
|
+
}
|
|
30
|
+
else if (typeof setting === 'object') {
|
|
31
|
+
if (typeof this[`${key}`] === 'object') {
|
|
32
|
+
// Apply as a map update
|
|
33
|
+
for (const child in setting) {
|
|
34
|
+
if (Object.prototype.hasOwnProperty.call(setting, child)) {
|
|
35
|
+
this[`${key}`][`${child}`] = setting[`${child}`];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this[`${key}`] = setting;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else if (setting !== undefined) {
|
|
44
|
+
this[`${key}`] = setting;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @param _property The key of the conditional selector configuration.
|
|
53
|
+
* @returns The converter for the selector configuration.
|
|
54
|
+
*/
|
|
55
|
+
getConverter(_property) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.Configurable = Configurable;
|
|
60
|
+
//# sourceMappingURL=configurable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configurable.js","sourceRoot":"","sources":["../../src/configurable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;GAEG;AACH,MAAsB,YAAY;IAChC;;;;;SAKK;IACL,SAAS,CAAE,MAA+B;QACxC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACzB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;gBACtD,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC,CAAA;gBAChC,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;gBACxC,IAAI,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;oBAC/C,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;gBAC7C,CAAC;qBAAM,CAAC;oBACN,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;wBAC3B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,OAAO,CAAA;oBAC1B,CAAC;yBAAM,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;wBACvC,IAAI,OAAO,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,KAAK,QAAQ,EAAE,CAAC;4BACvC,wBAAwB;4BACxB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gCAC5B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;oCACzD,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,KAAK,EAAE,CAAC,CAAA;gCAClD,CAAC;4BACH,CAAC;wBACH,CAAC;6BAAM,CAAC;4BACN,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,OAAO,CAAA;wBAC1B,CAAC;oBACH,CAAC;yBAAM,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;wBACjC,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,OAAO,CAAA;oBAC1B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;SAGK;IACL,YAAY,CAAE,SAAiB;QAC7B,OAAO,SAAS,CAAA;IAClB,CAAC;CACF;AA5CD,oCA4CC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration is an interface that is used to obtain configurable values
|
|
3
|
+
*/
|
|
4
|
+
export interface Configuration {
|
|
5
|
+
get<T = unknown>(path?: string[]): T | undefined;
|
|
6
|
+
set(path: string[], value: unknown): void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Useful for shimming Components into ComponentRegistrations
|
|
10
|
+
*/
|
|
11
|
+
export declare const noOpConfiguration: Configuration;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.noOpConfiguration = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* Useful for shimming Components into ComponentRegistrations
|
|
8
|
+
*/
|
|
9
|
+
exports.noOpConfiguration = {
|
|
10
|
+
get(_path) {
|
|
11
|
+
return undefined;
|
|
12
|
+
},
|
|
13
|
+
set(_path, _value) {
|
|
14
|
+
// no-op
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/configuration.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAUlC;;GAEG;AACU,QAAA,iBAAiB,GAAkB;IAC9C,GAAG,CAAE,KAAK;QACR,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,GAAG,CAAE,KAAK,EAAE,MAAM;QAChB,QAAQ;IACV,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The converter converts object from one type to another.
|
|
7
|
+
*/
|
|
8
|
+
export interface Converter<From = unknown, To = unknown> {
|
|
9
|
+
convert(value: From | To): To;
|
|
10
|
+
}
|
|
11
|
+
export type ConverterFactory<From = unknown, To = unknown> = {
|
|
12
|
+
new (...args: unknown[]): Converter<From, To>;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../../src/converter.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { TurnContext } from '@microsoft/agents-hosting';
|
|
6
|
+
import { DialogContext } from './dialogContext';
|
|
7
|
+
import { Configurable } from './configurable';
|
|
8
|
+
import { DialogTurnResult } from './dialogTurnResult';
|
|
9
|
+
import { DialogEvent } from './dialogEvent';
|
|
10
|
+
import { DialogReason } from './dialogReason';
|
|
11
|
+
import { DialogInstance } from './dialogInstance';
|
|
12
|
+
/**
|
|
13
|
+
* Defines the core behavior for all dialogs.
|
|
14
|
+
*/
|
|
15
|
+
export declare abstract class Dialog<O extends object = {}> extends Configurable {
|
|
16
|
+
private _id;
|
|
17
|
+
/**
|
|
18
|
+
* Gets a default end-of-turn result.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* This result indicates that a dialog (or a logical step within a dialog) has completed
|
|
22
|
+
* processing for the current turn, is still active, and is waiting for more input.
|
|
23
|
+
*/
|
|
24
|
+
static EndOfTurn: DialogTurnResult;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new instance of the Dialog class.
|
|
27
|
+
*
|
|
28
|
+
* @param dialogId Optional. unique ID of the dialog.
|
|
29
|
+
*/
|
|
30
|
+
constructor(dialogId?: string);
|
|
31
|
+
/**
|
|
32
|
+
* Unique ID of the dialog.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* This will be automatically generated if not specified.
|
|
36
|
+
* @returns The Id for the dialog.
|
|
37
|
+
*/
|
|
38
|
+
get id(): string;
|
|
39
|
+
/**
|
|
40
|
+
* Sets the unique ID of the dialog.
|
|
41
|
+
*/
|
|
42
|
+
set id(value: string);
|
|
43
|
+
/**
|
|
44
|
+
* An encoded string used to aid in the detection of agent changes on re-deployment.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* This defaults to returning the dialogs [id](#id) but can be overridden to provide more
|
|
48
|
+
* precise change detection logic. Any dialog on the stack that has its version change will
|
|
49
|
+
* result in a `versionChanged` event will be raised. If this event is not handled by the agent,
|
|
50
|
+
* an error will be thrown resulting in the agent error handler logic being run.
|
|
51
|
+
*
|
|
52
|
+
* Returning an empty string will disable version tracking for the component all together.
|
|
53
|
+
* @returns Unique string which should only change when dialog has changed in a way that should restart the dialog.
|
|
54
|
+
*/
|
|
55
|
+
getVersion(): string;
|
|
56
|
+
/**
|
|
57
|
+
* When overridden in a derived class, starts the dialog.
|
|
58
|
+
*
|
|
59
|
+
* @param dc The context for the current dialog turn.
|
|
60
|
+
* @param options Optional. Arguments to use when the dialog starts.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* Derived dialogs must override this method.
|
|
64
|
+
*
|
|
65
|
+
* The DialogContext calls this method when it creates
|
|
66
|
+
* a new DialogInstance for this dialog, pushes it
|
|
67
|
+
* onto the dialog stack, and starts the dialog.
|
|
68
|
+
*
|
|
69
|
+
* A dialog that represents a single-turn conversation should await
|
|
70
|
+
* DialogContext.endDialog before exiting this method.
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
73
|
+
abstract beginDialog(dc: DialogContext, options?: O): Promise<DialogTurnResult>;
|
|
74
|
+
/**
|
|
75
|
+
* When overridden in a derived class, continues the dialog.
|
|
76
|
+
*
|
|
77
|
+
* @param dc The context for the current dialog turn.
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* Derived dialogs that support multiple-turn conversations should override this method.
|
|
81
|
+
* By default, this method signals that the dialog is complete and returns.
|
|
82
|
+
*
|
|
83
|
+
* The DialogContext calls this method when it continues
|
|
84
|
+
* the dialog.
|
|
85
|
+
*
|
|
86
|
+
* To signal to the dialog context that this dialog has completed, await
|
|
87
|
+
* DialogContext.endDialog before exiting this method.
|
|
88
|
+
*
|
|
89
|
+
* @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
|
|
90
|
+
*/
|
|
91
|
+
continueDialog(dc: DialogContext): Promise<DialogTurnResult>;
|
|
92
|
+
/**
|
|
93
|
+
* When overridden in a derived class, resumes the dialog after the dialog above it on the stack completes.
|
|
94
|
+
*
|
|
95
|
+
* @param dc The context for the current dialog turn.
|
|
96
|
+
* @param reason The reason the dialog is resuming. This will typically be DialogReason.endCalled
|
|
97
|
+
* @param result Optional. The return value, if any, from the dialog that ended.
|
|
98
|
+
*
|
|
99
|
+
* @remarks
|
|
100
|
+
* Derived dialogs that support multiple-turn conversations should override this method.
|
|
101
|
+
* By default, this method signals that the dialog is complete and returns.
|
|
102
|
+
*
|
|
103
|
+
* The DialogContext calls this method when it resumes
|
|
104
|
+
* the dialog. If the previous dialog on the stack returned a value, that value is in the `result`
|
|
105
|
+
* parameter.
|
|
106
|
+
*
|
|
107
|
+
* To start a _child_ dialog, use DialogContext.beginDialog or DialogContext.prompt; however, this dialog will not
|
|
108
|
+
* necessarily be the one that started the child dialog.
|
|
109
|
+
* To signal to the dialog context that this dialog has completed, await DialogContext.endDialog before exiting this method.
|
|
110
|
+
*
|
|
111
|
+
* @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
|
|
112
|
+
*/
|
|
113
|
+
resumeDialog(dc: DialogContext, reason: DialogReason, result?: any): Promise<DialogTurnResult>;
|
|
114
|
+
/**
|
|
115
|
+
* When overridden in a derived class, reprompts the user for input.
|
|
116
|
+
*
|
|
117
|
+
* @param _context The context object for the turn.
|
|
118
|
+
* @param _instance Current state information for this dialog.
|
|
119
|
+
*
|
|
120
|
+
* @remarks
|
|
121
|
+
* Derived dialogs that support validation and re-prompt logic should override this method.
|
|
122
|
+
* By default, this method has no effect.
|
|
123
|
+
*
|
|
124
|
+
* The DialogContext calls this method when the current
|
|
125
|
+
* dialog should re-request input from the user. This method is implemented for prompt dialogs.
|
|
126
|
+
*
|
|
127
|
+
*/
|
|
128
|
+
repromptDialog(_context: TurnContext, _instance: DialogInstance): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* When overridden in a derived class, performs clean up for the dialog before it ends.
|
|
131
|
+
*
|
|
132
|
+
* @param _context The context object for the turn.
|
|
133
|
+
* @param _instance Current state information for this dialog.
|
|
134
|
+
* @param _reason The reason the dialog is ending.
|
|
135
|
+
*
|
|
136
|
+
* @remarks
|
|
137
|
+
* Derived dialogs that need to perform logging or cleanup before ending should override this method.
|
|
138
|
+
* By default, this method has no effect.
|
|
139
|
+
*
|
|
140
|
+
* The DialogContext calls this method when the current
|
|
141
|
+
* dialog is ending.
|
|
142
|
+
*
|
|
143
|
+
*/
|
|
144
|
+
endDialog(_context: TurnContext, _instance: DialogInstance, _reason: DialogReason): Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Called when an event has been raised, using `DialogContext.emitEvent()`, by either the current dialog or a dialog that the current dialog started.
|
|
147
|
+
*
|
|
148
|
+
* @param dialogContext - The dialog context for the current turn of conversation.
|
|
149
|
+
* @param event - The event being raised.
|
|
150
|
+
* @returns True if the event is handled by the current dialog and bubbling should stop.
|
|
151
|
+
*/
|
|
152
|
+
onDialogEvent(dialogContext: DialogContext, event: DialogEvent): Promise<boolean>;
|
|
153
|
+
/**
|
|
154
|
+
* Called before an event is bubbled to its parent.
|
|
155
|
+
*
|
|
156
|
+
* @remarks
|
|
157
|
+
* This is a good place to perform interception of an event as returning `true` will prevent
|
|
158
|
+
* any further bubbling of the event to the dialogs parents and will also prevent any child
|
|
159
|
+
* dialogs from performing their default processing.
|
|
160
|
+
* @param _dc The dialog context for the current turn of conversation.
|
|
161
|
+
* @param _e The event being raised.
|
|
162
|
+
* @returns Whether the event is handled by the current dialog and further processing should stop.
|
|
163
|
+
*/
|
|
164
|
+
protected onPreBubbleEvent(_dc: DialogContext, _e: DialogEvent): Promise<boolean>;
|
|
165
|
+
/**
|
|
166
|
+
* Called after an event was bubbled to all parents and wasn't handled.
|
|
167
|
+
*
|
|
168
|
+
* @remarks
|
|
169
|
+
* This is a good place to perform default processing logic for an event. Returning `true` will
|
|
170
|
+
* prevent any processing of the event by child dialogs.
|
|
171
|
+
* @param _dc The dialog context for the current turn of conversation.
|
|
172
|
+
* @param _e The event being raised.
|
|
173
|
+
* @returns Whether the event is handled by the current dialog and further processing should stop.
|
|
174
|
+
*/
|
|
175
|
+
protected onPostBubbleEvent(_dc: DialogContext, _e: DialogEvent): Promise<boolean>;
|
|
176
|
+
/**
|
|
177
|
+
* Called when a unique ID needs to be computed for a dialog.
|
|
178
|
+
*
|
|
179
|
+
* @remarks
|
|
180
|
+
* SHOULD be overridden to provide a more contextually relevant ID. The preferred pattern for
|
|
181
|
+
* ID's is `<dialog type>(this.hashedLabel('<dialog args>'))`.
|
|
182
|
+
*/
|
|
183
|
+
protected onComputeId(): string;
|
|
184
|
+
}
|