@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,216 @@
|
|
|
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.SettingsMemoryScope = void 0;
|
|
8
|
+
const dialogTurnStateConstants_1 = require("../../dialogTurnStateConstants");
|
|
9
|
+
const memoryScope_1 = require("./memoryScope");
|
|
10
|
+
const scopePath_1 = require("../scopePath");
|
|
11
|
+
/**
|
|
12
|
+
* The setting node.
|
|
13
|
+
*/
|
|
14
|
+
class Node {
|
|
15
|
+
constructor(value) {
|
|
16
|
+
this.value = value;
|
|
17
|
+
this.children = [];
|
|
18
|
+
}
|
|
19
|
+
isLeaf() {
|
|
20
|
+
return this.children.length === 0;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
class SettingsMemoryScope extends memoryScope_1.MemoryScope {
|
|
24
|
+
/**
|
|
25
|
+
* Initializes a new instance of the SettingsMemoryScope class.
|
|
26
|
+
*
|
|
27
|
+
* @param initialSettings initial set of settings to supply
|
|
28
|
+
*/
|
|
29
|
+
constructor(initialSettings) {
|
|
30
|
+
super(scopePath_1.ScopePath.settings, false);
|
|
31
|
+
this.initialSettings = initialSettings;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Gets the backing memory for this scope.
|
|
35
|
+
*
|
|
36
|
+
* @param {DialogContext} dialogContext The DialogContext object for this turn.
|
|
37
|
+
* @returns {Record<string, ?>} The memory for the scope.
|
|
38
|
+
*/
|
|
39
|
+
getMemory(dialogContext) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
if (dialogContext.context.turnState.has(scopePath_1.ScopePath.settings)) {
|
|
42
|
+
return (_a = dialogContext.context.turnState.get(scopePath_1.ScopePath.settings)) !== null && _a !== void 0 ? _a : {};
|
|
43
|
+
}
|
|
44
|
+
const configuration = (_b = dialogContext.context.turnState.get(dialogTurnStateConstants_1.DialogTurnStateConstants.configuration)) !== null && _b !== void 0 ? _b : {};
|
|
45
|
+
Object.entries(process.env).reduce((result, [key, value]) => {
|
|
46
|
+
result[`${key}`] = value;
|
|
47
|
+
return result;
|
|
48
|
+
}, configuration);
|
|
49
|
+
const settings = SettingsMemoryScope.loadSettings(configuration);
|
|
50
|
+
dialogContext.context.turnState.set(scopePath_1.ScopePath.settings, settings);
|
|
51
|
+
return settings;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @param dialogContext Current dialog context.
|
|
55
|
+
*/
|
|
56
|
+
async load(dialogContext) {
|
|
57
|
+
if (this.initialSettings) {
|
|
58
|
+
// filter initialSettings
|
|
59
|
+
const filteredSettings = SettingsMemoryScope.filterSettings(this.initialSettings);
|
|
60
|
+
dialogContext.context.turnState.set(scopePath_1.ScopePath.settings, filteredSettings);
|
|
61
|
+
}
|
|
62
|
+
await super.load(dialogContext);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Build a dictionary view of configuration providers.
|
|
66
|
+
*
|
|
67
|
+
* @param {Record<string, string>} configuration The configuration that we are running with.
|
|
68
|
+
* @returns {Record<string, ?>} Projected dictionary for settings.
|
|
69
|
+
*/
|
|
70
|
+
static loadSettings(configuration) {
|
|
71
|
+
let settings = {};
|
|
72
|
+
if (configuration) {
|
|
73
|
+
// load configuration into settings
|
|
74
|
+
const root = this.convertFlattenSettingToNode(Object.entries(configuration));
|
|
75
|
+
settings = root.children.reduce((acc, child) => { var _a; return ({ ...acc, [(_a = child.value) !== null && _a !== void 0 ? _a : '']: this.convertNodeToObject(child) }); }, settings);
|
|
76
|
+
}
|
|
77
|
+
// filter env configuration settings
|
|
78
|
+
return this.filterSettings(settings);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Generate a node tree with the flatten settings.
|
|
82
|
+
* For example:
|
|
83
|
+
* {
|
|
84
|
+
* "array":["item1", "item2"],
|
|
85
|
+
* "object":{"array":["item1"], "2":"numberkey"}
|
|
86
|
+
* }
|
|
87
|
+
*
|
|
88
|
+
* Would generate a flatten settings like:
|
|
89
|
+
* array:0 item1
|
|
90
|
+
* array:1 item2
|
|
91
|
+
* object:array:0 item1
|
|
92
|
+
* object:2 numberkey
|
|
93
|
+
*
|
|
94
|
+
* After Converting it from flatten settings into node tree, would get:
|
|
95
|
+
*
|
|
96
|
+
* null
|
|
97
|
+
* | |
|
|
98
|
+
* array object
|
|
99
|
+
* | | | |
|
|
100
|
+
* 0 1 array 2
|
|
101
|
+
* | | | |
|
|
102
|
+
* item1 item2 0 numberkey
|
|
103
|
+
* |
|
|
104
|
+
* item1
|
|
105
|
+
* The result is a Tree.
|
|
106
|
+
*
|
|
107
|
+
* @param {Array<[string, string]>} kvs Configurations with key value pairs.
|
|
108
|
+
* @returns {Node} The root node of the tree.
|
|
109
|
+
*/
|
|
110
|
+
static convertFlattenSettingToNode(kvs) {
|
|
111
|
+
const root = new Node();
|
|
112
|
+
kvs.forEach(([key, value]) => {
|
|
113
|
+
const keyChain = key.split(':');
|
|
114
|
+
let currentNode = root;
|
|
115
|
+
keyChain.forEach((item) => {
|
|
116
|
+
const matchItem = currentNode.children.find((u) => (u === null || u === void 0 ? void 0 : u.value) === item);
|
|
117
|
+
if (!matchItem) {
|
|
118
|
+
// Remove all the leaf children
|
|
119
|
+
currentNode.children = currentNode.children.filter((u) => u.children.length !== 0);
|
|
120
|
+
// Append new child into current node
|
|
121
|
+
const node = new Node(item);
|
|
122
|
+
currentNode.children.push(node);
|
|
123
|
+
currentNode = node;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
currentNode = matchItem;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
currentNode.children.push(new Node(value));
|
|
130
|
+
});
|
|
131
|
+
return root;
|
|
132
|
+
}
|
|
133
|
+
static convertNodeToObject(node) {
|
|
134
|
+
if (!node.children.length) {
|
|
135
|
+
return {};
|
|
136
|
+
}
|
|
137
|
+
// If the child is leaf node, return its value directly.
|
|
138
|
+
if (node.children.length === 1 && node.children[0].isLeaf()) {
|
|
139
|
+
return node.children[0].value;
|
|
140
|
+
}
|
|
141
|
+
// check if all the children are number format.
|
|
142
|
+
let pureNumberIndex = true;
|
|
143
|
+
const indexArray = [];
|
|
144
|
+
let indexMax = -1;
|
|
145
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
146
|
+
const child = node.children[Number(i)];
|
|
147
|
+
if (child.value && /^-?\d+$/.test(child.value)) {
|
|
148
|
+
const num = parseInt(child.value, 10);
|
|
149
|
+
if (!isNaN(num) && num >= 0) {
|
|
150
|
+
indexArray.push(num);
|
|
151
|
+
if (num > indexMax) {
|
|
152
|
+
indexMax = num;
|
|
153
|
+
}
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
pureNumberIndex = false;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
if (pureNumberIndex) {
|
|
161
|
+
// all children are int numbers, treat it as array.
|
|
162
|
+
const listResult = new Array(indexMax + 1);
|
|
163
|
+
node.children.forEach((child, index) => {
|
|
164
|
+
listResult[indexArray[Number(index)]] = this.convertNodeToObject(child);
|
|
165
|
+
});
|
|
166
|
+
return listResult;
|
|
167
|
+
}
|
|
168
|
+
// Convert all child into dictionary
|
|
169
|
+
return node.children.reduce((result, child) => {
|
|
170
|
+
if (child.value) {
|
|
171
|
+
result[child.value] = this.convertNodeToObject(child);
|
|
172
|
+
}
|
|
173
|
+
return result;
|
|
174
|
+
}, {});
|
|
175
|
+
}
|
|
176
|
+
static filterSettings(settings) {
|
|
177
|
+
const result = Object.assign({}, settings);
|
|
178
|
+
this.blockingList.forEach((path) => this.deletePropertyPath(result, path));
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
static deletePropertyPath(obj, path) {
|
|
182
|
+
var _a;
|
|
183
|
+
if (!obj || !(path === null || path === void 0 ? void 0 : path.length)) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const pathArray = path.split(':');
|
|
187
|
+
for (let i = 0; i < pathArray.length - 1; i++) {
|
|
188
|
+
const realKey = Object.keys(obj).find((key) => key.toLowerCase() === pathArray[i].toLowerCase());
|
|
189
|
+
if (realKey) {
|
|
190
|
+
obj = obj[realKey];
|
|
191
|
+
}
|
|
192
|
+
if (!obj) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const lastPath = (_a = pathArray.pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
197
|
+
const lastKey = Object.keys(obj).find((key) => key.toLowerCase() === lastPath);
|
|
198
|
+
if (lastKey) {
|
|
199
|
+
delete obj[lastKey];
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
exports.SettingsMemoryScope = SettingsMemoryScope;
|
|
204
|
+
SettingsMemoryScope.blockingList = [
|
|
205
|
+
'MicrosoftAppPassword',
|
|
206
|
+
'cosmosDb:authKey',
|
|
207
|
+
'blobStorage:connectionString',
|
|
208
|
+
'BlobsStorage:connectionString',
|
|
209
|
+
'CosmosDbPartitionedStorage:authKey',
|
|
210
|
+
'applicationInsights:connectionString',
|
|
211
|
+
'applicationInsights:InstrumentationKey',
|
|
212
|
+
'runtimeSettings:telemetry:options:connectionString',
|
|
213
|
+
'runtimeSettings:telemetry:options:instrumentationKey',
|
|
214
|
+
'runtimeSettings:features:blobTranscript:connectionString',
|
|
215
|
+
];
|
|
216
|
+
//# sourceMappingURL=settingsMemoryScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settingsMemoryScope.js","sourceRoot":"","sources":["../../../../src/memory/scopes/settingsMemoryScope.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6EAAyE;AACzE,+CAA2C;AAC3C,4CAAwC;AAExC;;GAEG;AACH,MAAM,IAAI;IACR,YAAoB,KAAc;QAAd,UAAK,GAAL,KAAK,CAAS;QAClC,aAAQ,GAAW,EAAE,CAAA;IADgB,CAAC;IAEtC,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAA;IACnC,CAAC;CACF;AAED,MAAa,mBAAoB,SAAQ,yBAAW;IAclD;;;;SAIK;IACL,YAA8B,eAAyC;QACrE,KAAK,CAAC,qBAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;QADJ,oBAAe,GAAf,eAAe,CAA0B;IAEvE,CAAC;IAED;;;;;SAKK;IACL,SAAS,CAAE,aAA4B;;QACrC,IAAI,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,qBAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5D,OAAO,MAAA,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,qBAAS,CAAC,QAAQ,CAAC,mCAAI,EAAE,CAAA;QACtE,CAAC;QAED,MAAM,aAAa,GAAG,MAAA,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,mDAAwB,CAAC,aAAa,CAAC,mCAAI,EAAE,CAAA;QAEvG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC1D,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,KAAK,CAAA;YACxB,OAAO,MAAM,CA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MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;YAChG,IAAI,OAAO,EAAE,CAAC;gBACZ,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,CAAA;YACpB,CAAC;YAED,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,OAAM;YACR,CAAC;QACH,CAAC;QAED,MAAM,QAAQ,GAAG,MAAA,SAAS,CAAC,GAAG,EAAE,0CAAE,WAAW,EAAE,CAAA;QAC/C,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,CAAA;QAC9E,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,GAAG,CAAC,OAAO,CAAC,CAAA;QACrB,CAAC;IACH,CAAC;;AAxNH,kDAyNC;AAxNyB,gCAAY,GAAG;IACrC,sBAAsB;IACtB,kBAAkB;IAClB,8BAA8B;IAC9B,+BAA+B;IAC/B,oCAAoC;IACpC,sCAAsC;IACtC,wCAAwC;IACxC,oDAAoD;IACpD,sDAAsD;IACtD,0DAA0D;CAC3D,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { MemoryScope } from './memoryScope';
|
|
6
|
+
import { DialogContext } from '../../dialogContext';
|
|
7
|
+
export declare class ThisMemoryScope extends MemoryScope {
|
|
8
|
+
/**
|
|
9
|
+
* Initializes a new instance of the ThisMemoryScope class.
|
|
10
|
+
*/
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Gets the backing memory for this scope.
|
|
14
|
+
*
|
|
15
|
+
* @param dialogContext The DialogContext object for this turn.
|
|
16
|
+
* @returns The memory for the scope.
|
|
17
|
+
*/
|
|
18
|
+
getMemory(dialogContext: DialogContext): object;
|
|
19
|
+
/**
|
|
20
|
+
* Changes the backing object for the memory scope.
|
|
21
|
+
*
|
|
22
|
+
* @param dialogContext The DialogContext object for this turn.
|
|
23
|
+
* @param memory Memory object to set for the scope.
|
|
24
|
+
*/
|
|
25
|
+
setMemory(dialogContext: DialogContext, memory: object): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThisMemoryScope = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6
|
+
* Licensed under the MIT License.
|
|
7
|
+
*/
|
|
8
|
+
const memoryScope_1 = require("./memoryScope");
|
|
9
|
+
const scopePath_1 = require("../scopePath");
|
|
10
|
+
class ThisMemoryScope extends memoryScope_1.MemoryScope {
|
|
11
|
+
/**
|
|
12
|
+
* Initializes a new instance of the ThisMemoryScope class.
|
|
13
|
+
*/
|
|
14
|
+
constructor() {
|
|
15
|
+
super(scopePath_1.ScopePath.this);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Gets the backing memory for this scope.
|
|
19
|
+
*
|
|
20
|
+
* @param dialogContext The DialogContext object for this turn.
|
|
21
|
+
* @returns The memory for the scope.
|
|
22
|
+
*/
|
|
23
|
+
getMemory(dialogContext) {
|
|
24
|
+
return dialogContext.activeDialog ? dialogContext.activeDialog.state : {};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Changes the backing object for the memory scope.
|
|
28
|
+
*
|
|
29
|
+
* @param dialogContext The DialogContext object for this turn.
|
|
30
|
+
* @param memory Memory object to set for the scope.
|
|
31
|
+
*/
|
|
32
|
+
setMemory(dialogContext, memory) {
|
|
33
|
+
if (memory === undefined) {
|
|
34
|
+
throw new Error('ThisMemoryScope.setMemory: undefined memory object passed in.');
|
|
35
|
+
}
|
|
36
|
+
if (!dialogContext.activeDialog) {
|
|
37
|
+
throw new Error('ThisMemoryScope.setMemory: no active dialog found.');
|
|
38
|
+
}
|
|
39
|
+
dialogContext.activeDialog.state = memory;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.ThisMemoryScope = ThisMemoryScope;
|
|
43
|
+
//# sourceMappingURL=thisMemoryScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thisMemoryScope.js","sourceRoot":"","sources":["../../../../src/memory/scopes/thisMemoryScope.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+CAA2C;AAC3C,4CAAwC;AAGxC,MAAa,eAAgB,SAAQ,yBAAW;IAC9C;;SAEK;IACL;QACE,KAAK,CAAC,qBAAS,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAED;;;;;SAKK;IACL,SAAS,CAAE,aAA4B;QACrC,OAAO,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;IAC3E,CAAC;IAED;;;;;SAKK;IACL,SAAS,CAAE,aAA4B,EAAE,MAAc;QACrD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;QAClF,CAAC;QAED,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;QACvE,CAAC;QAED,aAAa,CAAC,YAAY,CAAC,KAAK,GAAG,MAAM,CAAA;IAC3C,CAAC;CACF;AAnCD,0CAmCC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { MemoryScope } from './memoryScope';
|
|
6
|
+
import { DialogContext } from '../../dialogContext';
|
|
7
|
+
/**
|
|
8
|
+
* TurnMemoryScope represents memory scoped to the current turn.
|
|
9
|
+
*/
|
|
10
|
+
export declare class TurnMemoryScope extends MemoryScope {
|
|
11
|
+
/**
|
|
12
|
+
* Initializes a new instance of the TurnMemoryScope class.
|
|
13
|
+
*/
|
|
14
|
+
constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Get the backing memory for this scope.
|
|
17
|
+
*
|
|
18
|
+
* @param dialogContext The DialogContext for this turn.
|
|
19
|
+
* @returns The memory for the scope.
|
|
20
|
+
*/
|
|
21
|
+
getMemory(dialogContext: DialogContext): object;
|
|
22
|
+
/**
|
|
23
|
+
* Changes the backing object for the memory scope.
|
|
24
|
+
*
|
|
25
|
+
* @param dialogContext The DialogContext for this turn.
|
|
26
|
+
* @param memory Memory object to set for the scope.
|
|
27
|
+
*/
|
|
28
|
+
setMemory(dialogContext: DialogContext, memory: object): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TurnMemoryScope = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6
|
+
* Licensed under the MIT License.
|
|
7
|
+
*/
|
|
8
|
+
const memoryScope_1 = require("./memoryScope");
|
|
9
|
+
const scopePath_1 = require("../scopePath");
|
|
10
|
+
/**
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
13
|
+
const TURN_STATE = 'turn';
|
|
14
|
+
/**
|
|
15
|
+
* TurnMemoryScope represents memory scoped to the current turn.
|
|
16
|
+
*/
|
|
17
|
+
class TurnMemoryScope extends memoryScope_1.MemoryScope {
|
|
18
|
+
/**
|
|
19
|
+
* Initializes a new instance of the TurnMemoryScope class.
|
|
20
|
+
*/
|
|
21
|
+
constructor() {
|
|
22
|
+
super(scopePath_1.ScopePath.turn, true);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get the backing memory for this scope.
|
|
26
|
+
*
|
|
27
|
+
* @param dialogContext The DialogContext for this turn.
|
|
28
|
+
* @returns The memory for the scope.
|
|
29
|
+
*/
|
|
30
|
+
getMemory(dialogContext) {
|
|
31
|
+
let memory = dialogContext.context.turnState.get(TURN_STATE);
|
|
32
|
+
if (typeof memory !== 'object') {
|
|
33
|
+
memory = {};
|
|
34
|
+
dialogContext.context.turnState.set(TURN_STATE, memory);
|
|
35
|
+
}
|
|
36
|
+
return memory;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Changes the backing object for the memory scope.
|
|
40
|
+
*
|
|
41
|
+
* @param dialogContext The DialogContext for this turn.
|
|
42
|
+
* @param memory Memory object to set for the scope.
|
|
43
|
+
*/
|
|
44
|
+
setMemory(dialogContext, memory) {
|
|
45
|
+
if (memory === undefined) {
|
|
46
|
+
throw new Error('TurnMemoryScope.setMemory: undefined memory object passed in.');
|
|
47
|
+
}
|
|
48
|
+
dialogContext.context.turnState.set(TURN_STATE, memory);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.TurnMemoryScope = TurnMemoryScope;
|
|
52
|
+
//# sourceMappingURL=turnMemoryScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turnMemoryScope.js","sourceRoot":"","sources":["../../../../src/memory/scopes/turnMemoryScope.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+CAA2C;AAC3C,4CAAwC;AAGxC;;GAEG;AACH,MAAM,UAAU,GAAG,MAAM,CAAA;AAEzB;;GAEG;AACH,MAAa,eAAgB,SAAQ,yBAAW;IAC9C;;SAEK;IACL;QACE,KAAK,CAAC,qBAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC7B,CAAC;IAED;;;;;SAKK;IACL,SAAS,CAAE,aAA4B;QACrC,IAAI,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QAC5D,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,GAAG,EAAE,CAAA;YACX,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;QACzD,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;;;SAKK;IACL,SAAS,CAAE,aAA4B,EAAE,MAAc;QACrD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;QAClF,CAAC;QAED,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;IACzD,CAAC;CACF;AArCD,0CAqCC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { AgentStateMemoryScope } from './agentStateMemoryScope';
|
|
6
|
+
/**
|
|
7
|
+
* Memory that's scoped to the current user.
|
|
8
|
+
*/
|
|
9
|
+
export declare class UserMemoryScope extends AgentStateMemoryScope {
|
|
10
|
+
protected stateKey: string;
|
|
11
|
+
/**
|
|
12
|
+
* Initializes a new instance of the UserMemoryScope class.
|
|
13
|
+
*/
|
|
14
|
+
constructor();
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserMemoryScope = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6
|
+
* Licensed under the MIT License.
|
|
7
|
+
*/
|
|
8
|
+
const agentStateMemoryScope_1 = require("./agentStateMemoryScope");
|
|
9
|
+
const scopePath_1 = require("../scopePath");
|
|
10
|
+
/**
|
|
11
|
+
* Memory that's scoped to the current user.
|
|
12
|
+
*/
|
|
13
|
+
class UserMemoryScope extends agentStateMemoryScope_1.AgentStateMemoryScope {
|
|
14
|
+
/**
|
|
15
|
+
* Initializes a new instance of the UserMemoryScope class.
|
|
16
|
+
*/
|
|
17
|
+
constructor() {
|
|
18
|
+
super(scopePath_1.ScopePath.user);
|
|
19
|
+
this.stateKey = 'UserState';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.UserMemoryScope = UserMemoryScope;
|
|
23
|
+
//# sourceMappingURL=userMemoryScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userMemoryScope.js","sourceRoot":"","sources":["../../../../src/memory/scopes/userMemoryScope.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,mEAA+D;AAC/D,4CAAwC;AAExC;;GAEG;AACH,MAAa,eAAgB,SAAQ,6CAAqB;IAExD;;SAEK;IACL;QACE,KAAK,CAAC,qBAAS,CAAC,IAAI,CAAC,CAAA;QALb,aAAQ,GAAG,WAAW,CAAA;IAMhC,CAAC;CACF;AARD,0CAQC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Defines path for avaiable turns.
|
|
7
|
+
*/
|
|
8
|
+
export declare class TurnPath {
|
|
9
|
+
static readonly lastResult = "turn.lastresult";
|
|
10
|
+
static readonly activity = "turn.activity";
|
|
11
|
+
static readonly recognized = "turn.recognized";
|
|
12
|
+
static readonly topIntent = "turn.recognized.intent";
|
|
13
|
+
static readonly topScore = "turn.recognized.score";
|
|
14
|
+
static readonly text = "turn.recognized.text";
|
|
15
|
+
static readonly unrecognizedText = "turn.unrecognizedText";
|
|
16
|
+
static readonly recognizedEntities = "turn.recognizedEntities";
|
|
17
|
+
static readonly interrupted = "turn.interrupted";
|
|
18
|
+
static readonly dialogEvent = "turn.dialogEvent";
|
|
19
|
+
static readonly repeatedIds = "turn.repeatedIds";
|
|
20
|
+
static readonly activityProcessed = "turn.activityProcessed";
|
|
21
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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.TurnPath = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Defines path for avaiable turns.
|
|
10
|
+
*/
|
|
11
|
+
class TurnPath {
|
|
12
|
+
}
|
|
13
|
+
exports.TurnPath = TurnPath;
|
|
14
|
+
/// The result from the last dialog that was called.
|
|
15
|
+
TurnPath.lastResult = 'turn.lastresult';
|
|
16
|
+
/// The current activity for the turn.
|
|
17
|
+
TurnPath.activity = 'turn.activity';
|
|
18
|
+
/// The recognized result for the current turn.
|
|
19
|
+
TurnPath.recognized = 'turn.recognized';
|
|
20
|
+
/// Path to the top intent.
|
|
21
|
+
TurnPath.topIntent = 'turn.recognized.intent';
|
|
22
|
+
/// Path to the top score.
|
|
23
|
+
TurnPath.topScore = 'turn.recognized.score';
|
|
24
|
+
/// Original text.
|
|
25
|
+
TurnPath.text = 'turn.recognized.text';
|
|
26
|
+
/// Original utterance split into unrecognized strings.
|
|
27
|
+
TurnPath.unrecognizedText = 'turn.unrecognizedText';
|
|
28
|
+
/// Entities that were recognized from text.
|
|
29
|
+
TurnPath.recognizedEntities = 'turn.recognizedEntities';
|
|
30
|
+
/// If true an interruption has occured.
|
|
31
|
+
TurnPath.interrupted = 'turn.interrupted';
|
|
32
|
+
/// The current dialog event (set during event processings).
|
|
33
|
+
TurnPath.dialogEvent = 'turn.dialogEvent';
|
|
34
|
+
/// Used to track that we don't end up in infinite loop of RepeatDialogs().
|
|
35
|
+
TurnPath.repeatedIds = 'turn.repeatedIds';
|
|
36
|
+
/// This is a bool which if set means that the turncontext.activity has been consumed by some component in the system.
|
|
37
|
+
TurnPath.activityProcessed = 'turn.activityProcessed';
|
|
38
|
+
//# sourceMappingURL=turnPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turnPath.js","sourceRoot":"","sources":["../../../src/memory/turnPath.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AACH,MAAa,QAAQ;;AAArB,4BAoCC;AAnCC,oDAAoD;AACpC,mBAAU,GAAG,iBAAiB,CAAA;AAE9C,sCAAsC;AACtB,iBAAQ,GAAG,eAAe,CAAA;AAE1C,+CAA+C;AAC/B,mBAAU,GAAG,iBAAiB,CAAA;AAE9C,2BAA2B;AACX,kBAAS,GAAG,wBAAwB,CAAA;AAEpD,0BAA0B;AACV,iBAAQ,GAAG,uBAAuB,CAAA;AAElD,kBAAkB;AACF,aAAI,GAAG,sBAAsB,CAAA;AAE7C,uDAAuD;AACvC,yBAAgB,GAAG,uBAAuB,CAAA;AAE1D,4CAA4C;AAC5B,2BAAkB,GAAG,yBAAyB,CAAA;AAE9D,wCAAwC;AACxB,oBAAW,GAAG,kBAAkB,CAAA;AAEhD,4DAA4D;AAC5C,oBAAW,GAAG,kBAAkB,CAAA;AAEhD,2EAA2E;AAC3D,oBAAW,GAAG,kBAAkB,CAAA;AAEhD,sHAAsH;AACtG,0BAAiB,GAAG,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { Activity, TurnContext } from '@microsoft/agents-hosting';
|
|
6
|
+
import { Dialog } from '../dialog';
|
|
7
|
+
import { DialogContext } from '../dialogContext';
|
|
8
|
+
import { PromptOptions, PromptRecognizerResult, PromptValidator } from './prompt';
|
|
9
|
+
import { DialogInstance } from '../dialogInstance';
|
|
10
|
+
import { DialogReason } from '../dialogReason';
|
|
11
|
+
import { DialogTurnResult } from '../dialogTurnResult';
|
|
12
|
+
/**
|
|
13
|
+
* Waits for an activity to be received.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* This prompt requires a validator be passed in and is useful when waiting for non-message
|
|
17
|
+
* activities like an event to be received. The validator can ignore received events until the
|
|
18
|
+
* expected activity is received.
|
|
19
|
+
*/
|
|
20
|
+
export declare class ActivityPrompt extends Dialog {
|
|
21
|
+
private validator;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new ActivityPrompt instance.
|
|
24
|
+
*
|
|
25
|
+
* @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`.
|
|
26
|
+
* @param validator Validator that will be called each time a new activity is received.
|
|
27
|
+
*/
|
|
28
|
+
constructor(dialogId: string, validator: PromptValidator<Activity>);
|
|
29
|
+
/**
|
|
30
|
+
* Called when a prompt dialog is pushed onto the dialog stack and is being activated.
|
|
31
|
+
*
|
|
32
|
+
* @param dialogContext The DialogContext for the current
|
|
33
|
+
* turn of the conversation.
|
|
34
|
+
* @param options PromptOptions, additional
|
|
35
|
+
* information to pass to the prompt being started.
|
|
36
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
37
|
+
* @remarks
|
|
38
|
+
* If the promise is successful, the result indicates whether the prompt is still
|
|
39
|
+
* active after the turn has been processed by the prompt.
|
|
40
|
+
*/
|
|
41
|
+
beginDialog(dialogContext: DialogContext, options: PromptOptions): Promise<DialogTurnResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Called when a prompt dialog is the active dialog and the user replied with a new activity.
|
|
44
|
+
*
|
|
45
|
+
* @param dialogContext The DialogContext for the current
|
|
46
|
+
* turn of conversation.
|
|
47
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
48
|
+
* @remarks
|
|
49
|
+
* If the promise is successful, the result indicates whether the dialog is still
|
|
50
|
+
* active after the turn has been processed by the dialog.
|
|
51
|
+
* The prompt generally continues to receive the user's replies until it accepts the
|
|
52
|
+
* user's reply as valid input for the prompt.
|
|
53
|
+
*/
|
|
54
|
+
continueDialog(dialogContext: DialogContext): Promise<DialogTurnResult>;
|
|
55
|
+
/**
|
|
56
|
+
* Called when a prompt dialog resumes being the active dialog on the dialog stack, such as
|
|
57
|
+
* when the previous active dialog on the stack completes.
|
|
58
|
+
*
|
|
59
|
+
* @param dialogContext The DialogContext for the current turn
|
|
60
|
+
* of the conversation.
|
|
61
|
+
* @param _reason DialogReason, an enum indicating why
|
|
62
|
+
* the dialog resumed.
|
|
63
|
+
* @param _result Optional. Value returned from the previous dialog on the stack.
|
|
64
|
+
* The type of the value returned is dependent on the previous dialog.
|
|
65
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
66
|
+
*/
|
|
67
|
+
resumeDialog(dialogContext: DialogContext, _reason: DialogReason, _result?: any): Promise<DialogTurnResult>;
|
|
68
|
+
/**
|
|
69
|
+
* Called when a prompt dialog has been requested to re-prompt the user for input.
|
|
70
|
+
*
|
|
71
|
+
* @param context TurnContext, context for the current
|
|
72
|
+
* turn of conversation with the user.
|
|
73
|
+
* @param instance DialogInstance, the instance
|
|
74
|
+
* of the dialog on the stack.
|
|
75
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
76
|
+
*/
|
|
77
|
+
repromptDialog(context: TurnContext, instance: DialogInstance): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* When overridden in a derived class, prompts the user for input.
|
|
80
|
+
*
|
|
81
|
+
* @param context TurnContext, context for the current
|
|
82
|
+
* turn of conversation with the user.
|
|
83
|
+
* @param state Contains state for the current instance of the prompt on the dialog stack.
|
|
84
|
+
* @param options A PromptOptions object constructed
|
|
85
|
+
* from the options initially provided in the call to Prompt.
|
|
86
|
+
* @param isRetry A boolean representing if the prompt is a retry.
|
|
87
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
88
|
+
*/
|
|
89
|
+
protected onPrompt(context: TurnContext, state: object, options: PromptOptions, isRetry: boolean): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* When overridden in a derived class, attempts to recognize the incoming Activity.
|
|
92
|
+
*
|
|
93
|
+
* @param context TurnContext, context for the current
|
|
94
|
+
* turn of conversation with the user.
|
|
95
|
+
* @param _state Contains state for the current instance of the prompt on the dialog stack.
|
|
96
|
+
* @param _options A PromptOptions object constructed
|
|
97
|
+
* from the options initially provided in the call to Prompt.
|
|
98
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
99
|
+
*/
|
|
100
|
+
protected onRecognize(context: TurnContext, _state: object, _options: PromptOptions): Promise<PromptRecognizerResult<Activity>>;
|
|
101
|
+
}
|