@microsoft/agents-hosting-dialogs 0.2.14 → 0.4.1
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/src/agentComponent.d.ts +18 -4
- package/dist/src/agentComponent.js +12 -4
- package/dist/src/agentComponent.js.map +1 -1
- package/dist/src/agentStateSet.d.ts +2 -2
- package/dist/src/agentStateSet.js +2 -2
- package/dist/src/choices/choice.d.ts +9 -0
- package/dist/src/choices/findChoices.d.ts +12 -0
- package/dist/src/choices/findChoices.js.map +1 -1
- package/dist/src/choices/findValues.d.ts +27 -0
- package/dist/src/choices/findValues.js.map +1 -1
- package/dist/src/choices/modelResult.d.ts +20 -0
- package/dist/src/choices/modelResult.js +4 -0
- package/dist/src/choices/modelResult.js.map +1 -1
- package/dist/src/choices/tokenizer.d.ts +15 -0
- package/dist/src/choices/tokenizer.js +4 -0
- package/dist/src/choices/tokenizer.js.map +1 -1
- package/dist/src/configurable.d.ts +1 -0
- package/dist/src/configurable.js +1 -0
- package/dist/src/configurable.js.map +1 -1
- package/dist/src/converter.d.ts +10 -1
- package/dist/src/dialog.d.ts +14 -13
- package/dist/src/dialog.js +11 -10
- package/dist/src/dialog.js.map +1 -1
- package/dist/src/dialogContext.d.ts +34 -35
- package/dist/src/dialogContext.js +24 -25
- package/dist/src/dialogContext.js.map +1 -1
- package/dist/src/dialogEvent.d.ts +3 -0
- package/dist/src/dialogEvents.d.ts +20 -0
- package/dist/src/dialogEvents.js +20 -0
- package/dist/src/dialogEvents.js.map +1 -1
- package/dist/src/dialogHelper.js +14 -0
- package/dist/src/dialogHelper.js.map +1 -1
- package/dist/src/dialogManager.d.ts +0 -1
- package/dist/src/dialogManager.js +0 -1
- package/dist/src/dialogManager.js.map +1 -1
- package/dist/src/dialogSet.d.ts +5 -9
- package/dist/src/dialogSet.js +5 -9
- package/dist/src/dialogSet.js.map +1 -1
- package/dist/src/dialogTurnStateConstants.d.ts +13 -1
- package/dist/src/dialogTurnStateConstants.js +13 -1
- package/dist/src/dialogTurnStateConstants.js.map +1 -1
- package/dist/src/intentScore.d.ts +6 -0
- package/dist/src/memory/dialogPath.d.ts +40 -8
- package/dist/src/memory/dialogPath.js +32 -8
- package/dist/src/memory/dialogPath.js.map +1 -1
- package/dist/src/memory/dialogStateManager.d.ts +2 -2
- package/dist/src/memory/dialogStateManager.js +2 -2
- package/dist/src/memory/pathResolvers/aliasPathResolver.d.ts +4 -0
- package/dist/src/memory/pathResolvers/aliasPathResolver.js +4 -0
- package/dist/src/memory/pathResolvers/aliasPathResolver.js.map +1 -1
- package/dist/src/memory/pathResolvers/atAtPathResolver.d.ts +6 -2
- package/dist/src/memory/pathResolvers/atAtPathResolver.js +6 -2
- package/dist/src/memory/pathResolvers/atAtPathResolver.js.map +1 -1
- package/dist/src/memory/pathResolvers/atPathResolver.d.ts +13 -7
- package/dist/src/memory/pathResolvers/atPathResolver.js +13 -7
- package/dist/src/memory/pathResolvers/atPathResolver.js.map +1 -1
- package/dist/src/memory/pathResolvers/dollarPathResolver.d.ts +7 -2
- package/dist/src/memory/pathResolvers/dollarPathResolver.js +7 -2
- package/dist/src/memory/pathResolvers/dollarPathResolver.js.map +1 -1
- package/dist/src/memory/pathResolvers/hashPathResolver.d.ts +7 -2
- package/dist/src/memory/pathResolvers/hashPathResolver.js +7 -2
- package/dist/src/memory/pathResolvers/hashPathResolver.js.map +1 -1
- package/dist/src/memory/pathResolvers/pathResolver.d.ts +10 -5
- package/dist/src/memory/pathResolvers/percentPathResolver.d.ts +7 -2
- package/dist/src/memory/pathResolvers/percentPathResolver.js +7 -2
- package/dist/src/memory/pathResolvers/percentPathResolver.js.map +1 -1
- package/dist/src/memory/scopePath.d.ts +27 -0
- package/dist/src/memory/scopePath.js +27 -0
- package/dist/src/memory/scopePath.js.map +1 -1
- package/dist/src/memory/scopes/classMemoryScope.d.ts +18 -14
- package/dist/src/memory/scopes/classMemoryScope.js +18 -14
- package/dist/src/memory/scopes/classMemoryScope.js.map +1 -1
- package/dist/src/memory/scopes/dialogClassMemoryScope.d.ts +12 -6
- package/dist/src/memory/scopes/dialogClassMemoryScope.js +12 -6
- package/dist/src/memory/scopes/dialogClassMemoryScope.js.map +1 -1
- package/dist/src/memory/scopes/dialogContextMemoryScope.d.ts +11 -7
- package/dist/src/memory/scopes/dialogContextMemoryScope.js +11 -7
- package/dist/src/memory/scopes/dialogContextMemoryScope.js.map +1 -1
- package/dist/src/memory/scopes/dialogMemoryScope.d.ts +23 -16
- package/dist/src/memory/scopes/dialogMemoryScope.js +23 -16
- package/dist/src/memory/scopes/dialogMemoryScope.js.map +1 -1
- package/dist/src/memory/scopes/turnMemoryScope.d.ts +14 -13
- package/dist/src/memory/scopes/turnMemoryScope.js +14 -13
- package/dist/src/memory/scopes/turnMemoryScope.js.map +1 -1
- package/dist/src/memory/turnPath.d.ts +61 -13
- package/dist/src/memory/turnPath.js +49 -13
- package/dist/src/memory/turnPath.js.map +1 -1
- package/dist/src/prompts/attachmentPrompt.d.ts +1 -1
- package/dist/src/prompts/attachmentPrompt.js +1 -1
- package/dist/src/prompts/choicePrompt.d.ts +17 -3
- package/dist/src/prompts/choicePrompt.js +1 -1
- package/dist/src/prompts/choicePrompt.js.map +1 -1
- package/dist/src/prompts/confirmPrompt.d.ts +6 -6
- package/dist/src/prompts/confirmPrompt.js +3 -3
- package/dist/src/prompts/datetimePrompt.d.ts +6 -6
- package/dist/src/prompts/datetimePrompt.js +3 -3
- package/dist/src/prompts/numberPrompt.d.ts +6 -6
- package/dist/src/prompts/numberPrompt.js +6 -6
- package/dist/src/prompts/prompt.d.ts +7 -7
- package/dist/src/prompts/prompt.js +2 -2
- package/dist/src/prompts/promptCultureModels.d.ts +38 -3
- package/dist/src/prompts/promptCultureModels.js +38 -3
- package/dist/src/prompts/promptCultureModels.js.map +1 -1
- package/dist/src/recognizer.d.ts +8 -1
- package/dist/src/recognizer.js +5 -1
- package/dist/src/recognizer.js.map +1 -1
- package/dist/src/recognizerResult.d.ts +15 -0
- package/dist/src/recognizerResult.js.map +1 -1
- package/dist/src/serviceCollection.d.ts +22 -22
- package/dist/src/serviceCollection.js +11 -11
- package/dist/src/waterfallDialog.d.ts +5 -5
- package/dist/src/waterfallDialog.js +5 -5
- package/dist/src/waterfallStepContext.d.ts +21 -0
- package/dist/src/waterfallStepContext.js.map +1 -1
- package/package.json +2 -2
- package/src/agentComponent.ts +18 -4
- package/src/agentStateSet.ts +2 -2
- package/src/choices/choice.ts +11 -0
- package/src/choices/findChoices.ts +15 -0
- package/src/choices/findValues.ts +33 -0
- package/src/choices/modelResult.ts +25 -0
- package/src/choices/tokenizer.ts +19 -0
- package/src/configurable.ts +1 -0
- package/src/converter.ts +10 -1
- package/src/dialog.ts +14 -13
- package/src/dialogContext.ts +42 -43
- package/src/dialogEvent.ts +3 -0
- package/src/dialogEvents.ts +25 -0
- package/src/dialogHelper.ts +14 -1
- package/src/dialogManager.ts +0 -1
- package/src/dialogSet.ts +5 -9
- package/src/dialogTurnStateConstants.ts +15 -1
- package/src/intentScore.ts +9 -2
- package/src/memory/dialogPath.ts +47 -23
- package/src/memory/dialogStateManager.ts +2 -2
- package/src/memory/pathResolvers/aliasPathResolver.ts +4 -0
- package/src/memory/pathResolvers/atAtPathResolver.ts +6 -2
- package/src/memory/pathResolvers/atPathResolver.ts +13 -7
- package/src/memory/pathResolvers/dollarPathResolver.ts +7 -2
- package/src/memory/pathResolvers/hashPathResolver.ts +7 -2
- package/src/memory/pathResolvers/pathResolver.ts +10 -5
- package/src/memory/pathResolvers/percentPathResolver.ts +7 -2
- package/src/memory/scopePath.ts +35 -0
- package/src/memory/scopes/classMemoryScope.ts +18 -14
- package/src/memory/scopes/dialogClassMemoryScope.ts +12 -6
- package/src/memory/scopes/dialogContextMemoryScope.ts +11 -7
- package/src/memory/scopes/dialogMemoryScope.ts +23 -16
- package/src/memory/scopes/turnMemoryScope.ts +14 -13
- package/src/memory/turnPath.ts +61 -25
- package/src/prompts/attachmentPrompt.ts +1 -1
- package/src/prompts/choicePrompt.ts +18 -3
- package/src/prompts/confirmPrompt.ts +6 -6
- package/src/prompts/datetimePrompt.ts +6 -6
- package/src/prompts/numberPrompt.ts +6 -6
- package/src/prompts/prompt.ts +7 -7
- package/src/prompts/promptCultureModels.ts +38 -3
- package/src/recognizer.ts +8 -1
- package/src/recognizerResult.ts +24 -5
- package/src/serviceCollection.ts +22 -22
- package/src/waterfallDialog.ts +5 -5
- package/src/waterfallStepContext.ts +32 -6
|
@@ -4,10 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { AliasPathResolver } from './aliasPathResolver'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* A path resolver that resolves paths starting with a dollar sign ('$')
|
|
9
|
+
* to the 'dialog.' namespace.
|
|
10
|
+
*/
|
|
7
11
|
export class DollarPathResolver extends AliasPathResolver {
|
|
8
12
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
* Initializes a new instance of the DollarPathResolver class.
|
|
14
|
+
* This resolver maps paths starting with '$' to the 'dialog.' namespace.
|
|
15
|
+
*/
|
|
11
16
|
constructor () {
|
|
12
17
|
super('$', 'dialog.')
|
|
13
18
|
}
|
|
@@ -4,10 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { AliasPathResolver } from './aliasPathResolver'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* A path resolver that resolves paths starting with a hash sign ('#')
|
|
9
|
+
* to the 'turn.recognized.intents.' namespace.
|
|
10
|
+
*/
|
|
7
11
|
export class HashPathResolver extends AliasPathResolver {
|
|
8
12
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
* Initializes a new instance of the HashPathResolver class.
|
|
14
|
+
* This resolver maps paths starting with '#' to the 'turn.recognized.intents.' namespace.
|
|
15
|
+
*/
|
|
11
16
|
constructor () {
|
|
12
17
|
super('#', 'turn.recognized.intents.')
|
|
13
18
|
}
|
|
@@ -3,12 +3,17 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Interface for resolving and transforming paths.
|
|
8
|
+
* Implementations of this interface define how specific path patterns
|
|
9
|
+
* should be transformed into other formats or namespaces.
|
|
10
|
+
*/
|
|
6
11
|
export interface PathResolver {
|
|
7
12
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
* Transforms the given path into a new format or namespace.
|
|
14
|
+
*
|
|
15
|
+
* @param path - The path to inspect and transform.
|
|
16
|
+
* @returns The transformed path.
|
|
17
|
+
*/
|
|
13
18
|
transformPath(path: string): string;
|
|
14
19
|
}
|
|
@@ -4,10 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { AliasPathResolver } from './aliasPathResolver'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* A path resolver that resolves paths starting with a percent sign ('%')
|
|
9
|
+
* to the 'class.' namespace.
|
|
10
|
+
*/
|
|
7
11
|
export class PercentPathResolver extends AliasPathResolver {
|
|
8
12
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
* Initializes a new instance of the PercentPathResolver class.
|
|
14
|
+
* This resolver maps paths starting with '%' to the 'class.' namespace.
|
|
15
|
+
*/
|
|
11
16
|
constructor () {
|
|
12
17
|
super('%', 'class.')
|
|
13
18
|
}
|
package/src/memory/scopePath.ts
CHANGED
|
@@ -7,13 +7,48 @@
|
|
|
7
7
|
* Defines paths for the available scopes.
|
|
8
8
|
*/
|
|
9
9
|
export class ScopePath {
|
|
10
|
+
/**
|
|
11
|
+
* Path for user-specific data.
|
|
12
|
+
*/
|
|
10
13
|
static readonly user = 'user'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Path for conversation-specific data.
|
|
17
|
+
*/
|
|
11
18
|
static readonly conversation = 'conversation'
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Path for dialog-specific data.
|
|
22
|
+
*/
|
|
12
23
|
static readonly dialog = 'dialog'
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Path for dialog class-specific data.
|
|
27
|
+
*/
|
|
13
28
|
static readonly dialogClass = 'dialogClass'
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Path for dialog context-specific data.
|
|
32
|
+
*/
|
|
14
33
|
static readonly dialogContext = 'dialogContext'
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Path for the current dialog instance data.
|
|
37
|
+
*/
|
|
15
38
|
static readonly this = 'this'
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Path for class-specific data.
|
|
42
|
+
*/
|
|
16
43
|
static readonly class = 'class'
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Path for settings-specific data.
|
|
47
|
+
*/
|
|
17
48
|
static readonly settings = 'settings'
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Path for turn-specific data.
|
|
52
|
+
*/
|
|
18
53
|
static readonly turn = 'turn'
|
|
19
54
|
}
|
|
@@ -7,22 +7,26 @@ import { ScopePath } from '../scopePath'
|
|
|
7
7
|
import { DialogContext } from '../../dialogContext'
|
|
8
8
|
import { Dialog } from '../../dialog'
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* A memory scope that provides access to the properties of the active dialog.
|
|
12
|
+
* This scope binds to the active dialog and clones its properties for use in memory.
|
|
13
|
+
*/
|
|
10
14
|
export class ClassMemoryScope extends MemoryScope {
|
|
11
15
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
* Initializes a new instance of the ClassMemoryScope class.
|
|
17
|
+
*
|
|
18
|
+
* @param name - Name of the scope class. Defaults to `ScopePath.class`.
|
|
19
|
+
*/
|
|
16
20
|
constructor (name = ScopePath.class) {
|
|
17
21
|
super(name, false)
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
* Gets the backing memory for this scope.
|
|
26
|
+
*
|
|
27
|
+
* @param dialogContext - The DialogContext object for this turn.
|
|
28
|
+
* @returns The memory for the scope, containing cloned properties of the active dialog.
|
|
29
|
+
*/
|
|
26
30
|
getMemory (dialogContext: DialogContext): object {
|
|
27
31
|
// if active dialog is a container dialog then "dialog" binds to it
|
|
28
32
|
if (dialogContext.activeDialog) {
|
|
@@ -52,11 +56,11 @@ export class ClassMemoryScope extends MemoryScope {
|
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
* Override to find the dialog instance referenced by the scope.
|
|
60
|
+
*
|
|
61
|
+
* @param dialogContext - Current dialog context.
|
|
62
|
+
* @returns The dialog instance referenced by the scope, or undefined if not found.
|
|
63
|
+
*/
|
|
60
64
|
protected onFindDialog (dialogContext: DialogContext): Dialog | undefined {
|
|
61
65
|
return dialogContext.findDialog(dialogContext.activeDialog.id)
|
|
62
66
|
}
|
|
@@ -8,19 +8,25 @@ import { DialogContext } from '../../dialogContext'
|
|
|
8
8
|
import { Dialog } from '../../dialog'
|
|
9
9
|
import { DialogContainer } from '../../dialogContainer'
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* A memory scope that provides access to the properties of the active dialog class.
|
|
13
|
+
* This scope resolves to the active dialog if it is a container, or to its parent dialog.
|
|
14
|
+
*/
|
|
11
15
|
export class DialogClassMemoryScope extends ClassMemoryScope {
|
|
12
16
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
* Initializes a new instance of the DialogClassMemoryScope class.
|
|
18
|
+
*/
|
|
15
19
|
constructor () {
|
|
16
20
|
super(ScopePath.dialogClass)
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
* @protected
|
|
25
|
+
* Finds the dialog instance referenced by the scope.
|
|
26
|
+
*
|
|
27
|
+
* @param dialogContext - The DialogContext object for this turn.
|
|
28
|
+
* @returns The current dialog, or its parent dialog if applicable.
|
|
29
|
+
*/
|
|
24
30
|
protected onFindDialog (dialogContext: DialogContext): Dialog | undefined {
|
|
25
31
|
// Is the active dialog a container?
|
|
26
32
|
const dialog = dialogContext.findDialog(dialogContext.activeDialog.id)
|
|
@@ -7,20 +7,24 @@ import { DialogContext } from '../../dialogContext'
|
|
|
7
7
|
import { MemoryScope } from './memoryScope'
|
|
8
8
|
import { ScopePath } from '../scopePath'
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* A memory scope that provides access to the dialog context.
|
|
12
|
+
* This scope includes information about the active dialog, its parent, and the dialog stack.
|
|
13
|
+
*/
|
|
10
14
|
export class DialogContextMemoryScope extends MemoryScope {
|
|
11
15
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
* Initializes a new instance of the `DialogContextMemoryScope` class.
|
|
17
|
+
*/
|
|
14
18
|
constructor () {
|
|
15
19
|
super(ScopePath.dialogContext, false)
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
* Gets the backing memory for this scope.
|
|
24
|
+
*
|
|
25
|
+
* @param dialogContext - The `DialogContext` object for this turn.
|
|
26
|
+
* @returns An object containing the dialog stack, active dialog ID, and parent dialog ID.
|
|
27
|
+
*/
|
|
24
28
|
getMemory (dialogContext: DialogContext): Record<'stack' | 'activeDialog' | 'parent', unknown> {
|
|
25
29
|
const stack = []
|
|
26
30
|
let currentDialogContext: DialogContext | undefined = dialogContext
|
|
@@ -7,20 +7,24 @@ import { ScopePath } from '../scopePath'
|
|
|
7
7
|
import { DialogContext } from '../../dialogContext'
|
|
8
8
|
import { DialogContainer } from '../../dialogContainer'
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* A memory scope that provides access to the active dialog's state.
|
|
12
|
+
* This scope binds to the active dialog if it is a container, or to its parent dialog if applicable.
|
|
13
|
+
*/
|
|
10
14
|
export class DialogMemoryScope extends MemoryScope {
|
|
11
15
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
* Initializes a new instance of the DialogMemoryScope class.
|
|
17
|
+
*/
|
|
14
18
|
constructor () {
|
|
15
19
|
super(ScopePath.dialog)
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
* Gets the backing memory for this scope.
|
|
24
|
+
*
|
|
25
|
+
* @param dialogContext - The DialogContext object for this turn.
|
|
26
|
+
* @returns The memory for the scope.
|
|
27
|
+
*/
|
|
24
28
|
getMemory (dialogContext: DialogContext): object {
|
|
25
29
|
// If active dialog is a container dialog then "dialog" binds to it.
|
|
26
30
|
// Otherwise the "dialog" will bind to the dialogs parent assuming it
|
|
@@ -35,11 +39,12 @@ export class DialogMemoryScope extends MemoryScope {
|
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
* Changes the backing object for the memory scope.
|
|
43
|
+
*
|
|
44
|
+
* @param dialogContext - The DialogContext object for this turn.
|
|
45
|
+
* @param memory - Memory object to set for the scope.
|
|
46
|
+
* @throws Will throw an error if the memory object is undefined or if no active dialog is found.
|
|
47
|
+
*/
|
|
43
48
|
setMemory (dialogContext: DialogContext, memory: object): void {
|
|
44
49
|
if (memory === undefined) {
|
|
45
50
|
throw new Error('DialogMemoryScope.setMemory: undefined memory object passed in.')
|
|
@@ -62,10 +67,12 @@ export class DialogMemoryScope extends MemoryScope {
|
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
* Determines if the given dialog context is a container.
|
|
71
|
+
*
|
|
72
|
+
* @private
|
|
73
|
+
* @param dialogContext - The DialogContext object for this turn.
|
|
74
|
+
* @returns A boolean indicating whether the dialog context is a container.
|
|
75
|
+
*/
|
|
69
76
|
private isContainer (dialogContext: DialogContext): boolean {
|
|
70
77
|
if (dialogContext !== undefined && dialogContext.activeDialog !== undefined) {
|
|
71
78
|
const dialog = dialogContext.findDialog(dialogContext.activeDialog.id)
|
|
@@ -12,22 +12,23 @@ import { DialogContext } from '../../dialogContext'
|
|
|
12
12
|
const TURN_STATE = 'turn'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* A memory scope that provides access to the turn's state.
|
|
16
|
+
* This scope is used to store and retrieve information specific to the current turn.
|
|
16
17
|
*/
|
|
17
18
|
export class TurnMemoryScope extends MemoryScope {
|
|
18
19
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
* Initializes a new instance of the TurnMemoryScope class.
|
|
21
|
+
*/
|
|
21
22
|
constructor () {
|
|
22
23
|
super(ScopePath.turn, true)
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
* Gets the backing memory for this scope.
|
|
28
|
+
*
|
|
29
|
+
* @param dialogContext - The DialogContext object for this turn.
|
|
30
|
+
* @returns The memory for the scope.
|
|
31
|
+
*/
|
|
31
32
|
getMemory (dialogContext: DialogContext): object {
|
|
32
33
|
let memory = dialogContext.context.turnState.get(TURN_STATE)
|
|
33
34
|
if (typeof memory !== 'object') {
|
|
@@ -39,11 +40,11 @@ export class TurnMemoryScope extends MemoryScope {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
* Changes the backing object for the memory scope.
|
|
44
|
+
*
|
|
45
|
+
* @param dialogContext - The DialogContext object for this turn.
|
|
46
|
+
* @param memory - Memory object to set for the scope.
|
|
47
|
+
*/
|
|
47
48
|
setMemory (dialogContext: DialogContext, memory: object): void {
|
|
48
49
|
if (memory === undefined) {
|
|
49
50
|
throw new Error('TurnMemoryScope.setMemory: undefined memory object passed in.')
|
package/src/memory/turnPath.ts
CHANGED
|
@@ -4,42 +4,78 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Defines path for
|
|
7
|
+
* Defines path for available turns.
|
|
8
8
|
*/
|
|
9
9
|
export class TurnPath {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The result from the last dialog that was called.
|
|
12
|
+
* @constant A string key representing the last result path (`'turn.lastresult'`).
|
|
13
|
+
*/
|
|
14
|
+
static readonly lastResult: string = 'turn.lastresult'
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The current activity for the turn.
|
|
18
|
+
* @constant A string key representing the activity path (`'turn.activity'`).
|
|
19
|
+
*/
|
|
20
|
+
static readonly activity: string = 'turn.activity'
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
/**
|
|
23
|
+
* The recognized result for the current turn.
|
|
24
|
+
* @constant A string key representing the recognized result path (`'turn.recognized'`).
|
|
25
|
+
*/
|
|
26
|
+
static readonly recognized: string = 'turn.recognized'
|
|
18
27
|
|
|
19
|
-
|
|
20
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Path to the top intent.
|
|
30
|
+
* @constant A string key representing the top intent path (`'turn.recognized.intent'`).
|
|
31
|
+
*/
|
|
32
|
+
static readonly topIntent: string = 'turn.recognized.intent'
|
|
21
33
|
|
|
22
|
-
|
|
23
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Path to the top score.
|
|
36
|
+
* @constant A string key representing the top score path (`'turn.recognized.score'`).
|
|
37
|
+
*/
|
|
38
|
+
static readonly topScore: string = 'turn.recognized.score'
|
|
24
39
|
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Original text.
|
|
42
|
+
* @constant A string key representing the original text path (`'turn.recognized.text'`).
|
|
43
|
+
*/
|
|
44
|
+
static readonly text: string = 'turn.recognized.text'
|
|
27
45
|
|
|
28
|
-
|
|
29
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Original utterance split into unrecognized strings.
|
|
48
|
+
* @constant A string key representing the unrecognized text path (`'turn.unrecognizedText'`).
|
|
49
|
+
*/
|
|
50
|
+
static readonly unrecognizedText: string = 'turn.unrecognizedText'
|
|
30
51
|
|
|
31
|
-
|
|
32
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Entities that were recognized from text.
|
|
54
|
+
* @constant A string key representing the recognized entities path (`'turn.recognizedEntities'`).
|
|
55
|
+
*/
|
|
56
|
+
static readonly recognizedEntities: string = 'turn.recognizedEntities'
|
|
33
57
|
|
|
34
|
-
|
|
35
|
-
|
|
58
|
+
/**
|
|
59
|
+
* If true, an interruption has occurred.
|
|
60
|
+
* @constant A string key representing the interrupted path (`'turn.interrupted'`).
|
|
61
|
+
*/
|
|
62
|
+
static readonly interrupted: string = 'turn.interrupted'
|
|
36
63
|
|
|
37
|
-
|
|
38
|
-
|
|
64
|
+
/**
|
|
65
|
+
* The current dialog event (set during event processing).
|
|
66
|
+
* @constant A string key representing the dialog event path (`'turn.dialogEvent'`).
|
|
67
|
+
*/
|
|
68
|
+
static readonly dialogEvent: string = 'turn.dialogEvent'
|
|
39
69
|
|
|
40
|
-
|
|
41
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Used to track that we don't end up in an infinite loop of RepeatDialogs().
|
|
72
|
+
* @constant A string key representing the repeated IDs path (`'turn.repeatedIds'`).
|
|
73
|
+
*/
|
|
74
|
+
static readonly repeatedIds: string = 'turn.repeatedIds'
|
|
42
75
|
|
|
43
|
-
|
|
44
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Indicates whether the turncontext.activity has been consumed by some component in the system.
|
|
78
|
+
* @constant A string key representing the activity processed path (`'turn.activityProcessed'`).
|
|
79
|
+
*/
|
|
80
|
+
static readonly activityProcessed: string = 'turn.activityProcessed'
|
|
45
81
|
}
|
|
@@ -10,7 +10,7 @@ import { Attachment, InputHints } from '@microsoft/agents-activity'
|
|
|
10
10
|
* Prompts a user to upload attachments like images.
|
|
11
11
|
*
|
|
12
12
|
* @remarks
|
|
13
|
-
* By default the prompt will return to the calling dialog an
|
|
13
|
+
* By default the prompt will return to the calling dialog an {@link Attachment | Attachment[]}.
|
|
14
14
|
*/
|
|
15
15
|
export class AttachmentPrompt extends Prompt<Attachment[]> {
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
@@ -9,7 +9,22 @@ import { PromptCultureModels } from './promptCultureModels'
|
|
|
9
9
|
import { Activity } from '@microsoft/agents-activity'
|
|
10
10
|
|
|
11
11
|
// Need ChoiceDefaultsProperty so we can set choiceDefaults dynamically with lambda
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents a dictionary of default choice options for different locales.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* This interface is used to define the default options for rendering choices in prompts,
|
|
18
|
+
* such as separators, inline options, and whether to include numbers.
|
|
19
|
+
*/
|
|
12
20
|
export interface ChoiceDefaultsChoicePrompt {
|
|
21
|
+
/**
|
|
22
|
+
* A mapping of locale strings to their corresponding choice factory options.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* Each locale key maps to a `ChoiceFactoryOptions` object that defines the
|
|
26
|
+
* default behavior for rendering choices in that locale.
|
|
27
|
+
*/
|
|
13
28
|
[locale: string]: ChoiceFactoryOptions;
|
|
14
29
|
}
|
|
15
30
|
|
|
@@ -17,12 +32,12 @@ export interface ChoiceDefaultsChoicePrompt {
|
|
|
17
32
|
* Prompts a user to select from a list of choices.
|
|
18
33
|
*
|
|
19
34
|
* @remarks
|
|
20
|
-
* By default the prompt will return to the calling dialog a
|
|
35
|
+
* By default the prompt will return to the calling dialog a {@link FoundChoice} object containing the
|
|
21
36
|
* choice that was selected.
|
|
22
37
|
*/
|
|
23
38
|
export class ChoicePrompt extends Prompt<FoundChoice> {
|
|
24
39
|
/**
|
|
25
|
-
* A dictionary of Default Choices based on
|
|
40
|
+
* A dictionary of Default Choices based on {@link PromptCultureModels.getSupportedCultures | PromptCultureModels.getSupportedCultures method}.
|
|
26
41
|
* Can be replaced by user using the constructor that contains choiceDefaults.
|
|
27
42
|
*/
|
|
28
43
|
private choiceDefaults: ChoiceDefaultsChoicePrompt
|
|
@@ -47,7 +62,7 @@ export class ChoicePrompt extends Prompt<FoundChoice> {
|
|
|
47
62
|
choiceOptions: ChoiceFactoryOptions | undefined
|
|
48
63
|
|
|
49
64
|
/**
|
|
50
|
-
* Additional options passed to the underlying
|
|
65
|
+
* Additional options passed to the underlying {@link recognizeChoices | recognizeChoices function }.
|
|
51
66
|
*/
|
|
52
67
|
recognizerOptions: FindChoicesOptions | undefined
|
|
53
68
|
|
|
@@ -23,7 +23,7 @@ export interface ChoiceDefaultsConfirmPrompt {
|
|
|
23
23
|
*/
|
|
24
24
|
export class ConfirmPrompt extends Prompt<boolean> {
|
|
25
25
|
/**
|
|
26
|
-
* A dictionary of Default Choices based on
|
|
26
|
+
* A dictionary of Default Choices based on {@link PromptCultureModels.getSupportedCultures | PromptCultureModels.getSupportedCultures} method.
|
|
27
27
|
* Can be replaced by user using the constructor that contains choiceDefaults.
|
|
28
28
|
* This is initially set in the constructor.
|
|
29
29
|
*/
|
|
@@ -37,12 +37,12 @@ export class ConfirmPrompt extends Prompt<boolean> {
|
|
|
37
37
|
* Style of the "yes" and "no" choices rendered to the user when prompting.
|
|
38
38
|
*
|
|
39
39
|
* @remarks
|
|
40
|
-
* Defaults to
|
|
40
|
+
* Defaults to {@link ListStyle.auto}.
|
|
41
41
|
*/
|
|
42
42
|
style: ListStyle
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* Additional options passed to the
|
|
45
|
+
* Additional options passed to the {@link ChoiceFactory } and used to tweak the style of choices
|
|
46
46
|
* rendered to the user.
|
|
47
47
|
*/
|
|
48
48
|
choiceOptions: ChoiceFactoryOptions | undefined
|
|
@@ -55,10 +55,10 @@ export class ConfirmPrompt extends Prompt<boolean> {
|
|
|
55
55
|
/**
|
|
56
56
|
* Creates a new ConfirmPrompt instance.
|
|
57
57
|
*
|
|
58
|
-
* @param dialogId Unique ID of the dialog within its parent
|
|
58
|
+
* @param dialogId Unique ID of the dialog within its parent {@link DialogSet} or {@link ComponentDialog}.
|
|
59
59
|
* @param validator (Optional) validator that will be called each time the user responds to the prompt.
|
|
60
|
-
* @param defaultLocale (Optional) locale to use if
|
|
61
|
-
* @param choiceDefaults (Optional) Overrides the dictionary of Default Choices on
|
|
60
|
+
* @param defaultLocale (Optional) locale to use if the {@link Activity.locale | TurnContext.activity.locale} is not specified. Defaults to a value of `en-us`.
|
|
61
|
+
* @param choiceDefaults (Optional) Overrides the dictionary of Default Choices on {@link PromptCultureModels.getSupportedCultures | PromptCultureModels.getSupportedCultures} method.
|
|
62
62
|
*/
|
|
63
63
|
constructor (
|
|
64
64
|
dialogId: string,
|
|
@@ -8,7 +8,7 @@ import { Prompt, PromptOptions, PromptRecognizerResult, PromptValidator } from '
|
|
|
8
8
|
import { Activity, InputHints } from '@microsoft/agents-activity'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Result returned by the
|
|
11
|
+
* Result returned by the {@link DateTimePrompt}.
|
|
12
12
|
*/
|
|
13
13
|
export interface DateTimeResolution {
|
|
14
14
|
/**
|
|
@@ -23,8 +23,8 @@ export interface DateTimeResolution {
|
|
|
23
23
|
type: string;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Value of the specified
|
|
27
|
-
* of the
|
|
26
|
+
* Value of the specified `type` that's a reasonable approximation given the ambiguity
|
|
27
|
+
* of the `timex`.
|
|
28
28
|
*/
|
|
29
29
|
value: string;
|
|
30
30
|
}
|
|
@@ -33,7 +33,7 @@ export interface DateTimeResolution {
|
|
|
33
33
|
* Prompts a user to enter a datetime expression.
|
|
34
34
|
*
|
|
35
35
|
* @remarks
|
|
36
|
-
* By default the prompt will return to the calling dialog a
|
|
36
|
+
* By default the prompt will return to the calling dialog a {@link DateTimeResolution | DateTimeResolution[] }.
|
|
37
37
|
*/
|
|
38
38
|
export class DateTimePrompt extends Prompt<DateTimeResolution[]> {
|
|
39
39
|
/**
|
|
@@ -44,9 +44,9 @@ export class DateTimePrompt extends Prompt<DateTimeResolution[]> {
|
|
|
44
44
|
/**
|
|
45
45
|
* Creates a new DateTimePrompt instance.
|
|
46
46
|
*
|
|
47
|
-
* @param dialogId Unique ID of the dialog within its parent
|
|
47
|
+
* @param dialogId Unique ID of the dialog within its parent {@link DialogSet} or {@link ComponentDialog}.
|
|
48
48
|
* @param validator (Optional) validator that will be called each time the user responds to the prompt.
|
|
49
|
-
* @param defaultLocale (Optional) locale to use if
|
|
49
|
+
* @param defaultLocale (Optional) locale to use if the {@link Activity.locale | TurnContext.activity.locale} is not specified. Defaults to a value of `en-us`.
|
|
50
50
|
*/
|
|
51
51
|
constructor (dialogId: string, validator?: PromptValidator<DateTimeResolution[]>, defaultLocale?: string) {
|
|
52
52
|
super(dialogId, validator)
|
|
@@ -28,9 +28,9 @@ export class NumberPrompt extends Prompt<number> {
|
|
|
28
28
|
/**
|
|
29
29
|
* Creates a new NumberPrompt instance.
|
|
30
30
|
*
|
|
31
|
-
* @param dialogId Unique ID of the dialog within its parent
|
|
31
|
+
* @param dialogId Unique ID of the dialog within its parent {@link DialogSet} or {@link ComponentDialog}.
|
|
32
32
|
* @param validator (Optional) validator that will be called each time the user responds to the prompt.
|
|
33
|
-
* @param defaultLocale (Optional) locale to use if
|
|
33
|
+
* @param defaultLocale (Optional) locale to use if the {@link Activity.locale | TurnContext.activity.locale} is not specified. Defaults to a value of `en-us`.
|
|
34
34
|
*/
|
|
35
35
|
constructor (dialogId: string, validator?: PromptValidator<number>, defaultLocale?: string) {
|
|
36
36
|
super(dialogId, validator)
|
|
@@ -40,10 +40,10 @@ export class NumberPrompt extends Prompt<number> {
|
|
|
40
40
|
/**
|
|
41
41
|
* Prompts the user for input.
|
|
42
42
|
*
|
|
43
|
-
* @param context
|
|
43
|
+
* @param context {@link TurnContext} context for the current
|
|
44
44
|
* turn of conversation with the user.
|
|
45
45
|
* @param state Contains state for the current instance of the prompt on the dialog stack.
|
|
46
|
-
* @param options A
|
|
46
|
+
* @param options A {@link PromptOptions} object constructed
|
|
47
47
|
* from the options initially provided in the call to Prompt.
|
|
48
48
|
* @param isRetry `true` if this is the first time this prompt dialog instance
|
|
49
49
|
* on the stack is prompting the user for input; otherwise, false.
|
|
@@ -65,10 +65,10 @@ export class NumberPrompt extends Prompt<number> {
|
|
|
65
65
|
/**
|
|
66
66
|
* Attempts to recognize the user's input.
|
|
67
67
|
*
|
|
68
|
-
* @param context
|
|
68
|
+
* @param context {@link TurnContext}, context for the current
|
|
69
69
|
* turn of conversation with the user.
|
|
70
70
|
* @param _state Contains state for the current instance of the prompt on the dialog stack.
|
|
71
|
-
* @param _options A
|
|
71
|
+
* @param _options A {@link PromptOptions} object constructed
|
|
72
72
|
* from the options initially provided in the call to Prompt.
|
|
73
73
|
* @returns A `Promise` representing the asynchronous operation.
|
|
74
74
|
*/
|