@microsoft/agents-hosting-dialogs 0.2.14 → 0.3.5
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 +31 -32
- package/dist/src/dialogContext.js +22 -23
- 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 +4 -8
- package/dist/src/dialogSet.js +4 -8
- 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 +37 -38
- 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 +4 -8
- 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
package/src/dialog.ts
CHANGED
|
@@ -61,7 +61,7 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
61
61
|
* An encoded string used to aid in the detection of agent changes on re-deployment.
|
|
62
62
|
*
|
|
63
63
|
* @remarks
|
|
64
|
-
* This defaults to returning the
|
|
64
|
+
* This defaults to returning the dialog's `id` but can be overridden to provide more
|
|
65
65
|
* precise change detection logic. Any dialog on the stack that has its version change will
|
|
66
66
|
* result in a `versionChanged` event will be raised. If this event is not handled by the agent,
|
|
67
67
|
* an error will be thrown resulting in the agent error handler logic being run.
|
|
@@ -82,12 +82,12 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
82
82
|
* @remarks
|
|
83
83
|
* Derived dialogs must override this method.
|
|
84
84
|
*
|
|
85
|
-
* The DialogContext calls this method when it creates
|
|
86
|
-
* a new DialogInstance for this dialog, pushes it
|
|
85
|
+
* The {@link DialogContext} calls this method when it creates
|
|
86
|
+
* a new {@link DialogInstance} for this dialog, pushes it
|
|
87
87
|
* onto the dialog stack, and starts the dialog.
|
|
88
88
|
*
|
|
89
89
|
* A dialog that represents a single-turn conversation should await
|
|
90
|
-
* DialogContext.endDialog before exiting this method.
|
|
90
|
+
* {@link DialogContext.endDialog} before exiting this method.
|
|
91
91
|
*
|
|
92
92
|
*/
|
|
93
93
|
abstract beginDialog (dc: DialogContext, options?: O): Promise<DialogTurnResult>
|
|
@@ -101,11 +101,11 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
101
101
|
* Derived dialogs that support multiple-turn conversations should override this method.
|
|
102
102
|
* By default, this method signals that the dialog is complete and returns.
|
|
103
103
|
*
|
|
104
|
-
* The DialogContext calls this method when it continues
|
|
104
|
+
* The {@link DialogContext} calls this method when it continues
|
|
105
105
|
* the dialog.
|
|
106
106
|
*
|
|
107
107
|
* To signal to the dialog context that this dialog has completed, await
|
|
108
|
-
* DialogContext.endDialog before exiting this method.
|
|
108
|
+
* {@link DialogContext.endDialog} before exiting this method.
|
|
109
109
|
*
|
|
110
110
|
* @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
|
|
111
111
|
*/
|
|
@@ -125,13 +125,13 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
125
125
|
* Derived dialogs that support multiple-turn conversations should override this method.
|
|
126
126
|
* By default, this method signals that the dialog is complete and returns.
|
|
127
127
|
*
|
|
128
|
-
* The DialogContext calls this method when it resumes
|
|
128
|
+
* The {@link DialogContext} calls this method when it resumes
|
|
129
129
|
* the dialog. If the previous dialog on the stack returned a value, that value is in the `result`
|
|
130
130
|
* parameter.
|
|
131
131
|
*
|
|
132
|
-
* To start a _child_ dialog, use DialogContext.beginDialog or DialogContext.prompt; however, this dialog will not
|
|
132
|
+
* To start a _child_ dialog, use {@link DialogContext.beginDialog} or {@link DialogContext.prompt}; however, this dialog will not
|
|
133
133
|
* necessarily be the one that started the child dialog.
|
|
134
|
-
* To signal to the dialog context that this dialog has completed, await DialogContext.endDialog before exiting this method.
|
|
134
|
+
* To signal to the dialog context that this dialog has completed, await {@link DialogContext.endDialog} before exiting this method.
|
|
135
135
|
*
|
|
136
136
|
* @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
|
|
137
137
|
*/
|
|
@@ -141,7 +141,7 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
|
-
* When overridden in a derived class,
|
|
144
|
+
* When overridden in a derived class, prompts the user again for input.
|
|
145
145
|
*
|
|
146
146
|
* @param _context The context object for the turn.
|
|
147
147
|
* @param _instance Current state information for this dialog.
|
|
@@ -150,7 +150,7 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
150
150
|
* Derived dialogs that support validation and re-prompt logic should override this method.
|
|
151
151
|
* By default, this method has no effect.
|
|
152
152
|
*
|
|
153
|
-
* The DialogContext calls this method when the current
|
|
153
|
+
* The {@link DialogContext} calls this method when the current
|
|
154
154
|
* dialog should re-request input from the user. This method is implemented for prompt dialogs.
|
|
155
155
|
*
|
|
156
156
|
*/
|
|
@@ -169,7 +169,7 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
169
169
|
* Derived dialogs that need to perform logging or cleanup before ending should override this method.
|
|
170
170
|
* By default, this method has no effect.
|
|
171
171
|
*
|
|
172
|
-
* The DialogContext calls this method when the current
|
|
172
|
+
* The {@link DialogContext} calls this method when the current
|
|
173
173
|
* dialog is ending.
|
|
174
174
|
*
|
|
175
175
|
*/
|
|
@@ -178,7 +178,8 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
|
-
* Called when an event has been raised, using
|
|
181
|
+
* Called when an event has been raised, using {@link DialogContext.emitEvent | DialogContext.emitEvent method },
|
|
182
|
+
* by either the current dialog or a dialog that the current dialog started.
|
|
182
183
|
*
|
|
183
184
|
* @param dialogContext - The dialog context for the current turn of conversation.
|
|
184
185
|
* @param event - The event being raised.
|
package/src/dialogContext.ts
CHANGED
|
@@ -45,10 +45,10 @@ const wrapErrors = async <T>(dialogContext: DialogContext, promise: Promise<T>):
|
|
|
45
45
|
const ACTIVITY_RECEIVED_EMITTED = Symbol('ActivityReceivedEmitted')
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* Contains dialog state, information about the state of the dialog stack, for a specific DialogSet.
|
|
48
|
+
* Contains dialog state, information about the state of the dialog stack, for a specific {@link DialogSet}.
|
|
49
49
|
*
|
|
50
50
|
* @remarks
|
|
51
|
-
* State is read from and saved to storage each turn, and state cache for the turn is managed through the TurnContext.
|
|
51
|
+
* State is read from and saved to storage each turn, and state cache for the turn is managed through the {@link TurnContext}.
|
|
52
52
|
*
|
|
53
53
|
* For more information, see the articles on
|
|
54
54
|
* [Managing state](https://docs.microsoft.com/azure/bot-service/bot-builder-concept-state) and
|
|
@@ -56,18 +56,18 @@ const ACTIVITY_RECEIVED_EMITTED = Symbol('ActivityReceivedEmitted')
|
|
|
56
56
|
*/
|
|
57
57
|
export interface DialogState {
|
|
58
58
|
/**
|
|
59
|
-
* Contains state information for each Dialog on the stack.
|
|
59
|
+
* Contains state information for each {@link Dialog} on the stack.
|
|
60
60
|
*/
|
|
61
61
|
dialogStack: DialogInstance[];
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* The context for the current dialog turn with respect to a specific DialogSet.
|
|
65
|
+
* The context for the current dialog turn with respect to a specific {@link DialogSet}.
|
|
66
66
|
*
|
|
67
67
|
* @remarks
|
|
68
68
|
* This includes the turn context, information about the dialog set, and the state of the dialog stack.
|
|
69
69
|
*
|
|
70
|
-
* From code outside of a dialog in the set, use DialogSet.createContext
|
|
70
|
+
* From code outside of a dialog in the set, use {@link DialogSet.createContext | DialogSet.createContext method}
|
|
71
71
|
* to create the dialog context. Then use the methods of the dialog context to manage the progression of dialogs in the set.
|
|
72
72
|
*
|
|
73
73
|
* When you implement a dialog, the dialog context is a parameter available to the various methods you override or implement.
|
|
@@ -77,9 +77,9 @@ export class DialogContext {
|
|
|
77
77
|
/**
|
|
78
78
|
* Creates an new instance of the DialogContext class.
|
|
79
79
|
*
|
|
80
|
-
* @param dialogs The DialogSet for which to create the dialog context.
|
|
81
|
-
* @param contextOrDialogContext The TurnContext object for the current turn.
|
|
82
|
-
* @param state The state object to use to read and write DialogState to storage.
|
|
80
|
+
* @param dialogs The {@link DialogSet} for which to create the dialog context.
|
|
81
|
+
* @param contextOrDialogContext The {@link TurnContext} object for the current turn.
|
|
82
|
+
* @param state The state object to use to read and write {@link DialogState} to storage.
|
|
83
83
|
* @remarks
|
|
84
84
|
* Passing in a DialogContext instance will clone the dialog context.
|
|
85
85
|
*/
|
|
@@ -88,9 +88,9 @@ export class DialogContext {
|
|
|
88
88
|
/**
|
|
89
89
|
* Creates an new instance of the DialogContext class.
|
|
90
90
|
*
|
|
91
|
-
* @param dialogs The DialogSet for which to create the dialog context.
|
|
92
|
-
* @param contextOrDialogContext The DialogContext object for the current turn.
|
|
93
|
-
* @param state The state object to use to read and write DialogState
|
|
91
|
+
* @param dialogs The {@link DialogSet} for which to create the dialog context.
|
|
92
|
+
* @param contextOrDialogContext The {@link DialogContext} object for the current turn.
|
|
93
|
+
* @param state The state object to use to read and write {@link DialogState} to storage.
|
|
94
94
|
* @remarks
|
|
95
95
|
* Passing in a DialogContext instance will clone the dialog context.
|
|
96
96
|
*/
|
|
@@ -99,9 +99,9 @@ export class DialogContext {
|
|
|
99
99
|
/**
|
|
100
100
|
* Creates an new instance of the DialogContext class.
|
|
101
101
|
*
|
|
102
|
-
* @param dialogs The DialogSet for which to create the dialog context.
|
|
103
|
-
* @param contextOrDialogContext The TurnContext or DialogContext for the current turn.
|
|
104
|
-
* @param state The state object to use to read and write DialogState to storage.
|
|
102
|
+
* @param dialogs The {@link DialogSet} for which to create the dialog context.
|
|
103
|
+
* @param contextOrDialogContext The {@link TurnContext} or {@link DialogContext} for the current turn.
|
|
104
|
+
* @param state The state object to use to read and write {@link DialogState} to storage.
|
|
105
105
|
* @remarks Passing in a DialogContext instance will clone the dialog context.
|
|
106
106
|
*/
|
|
107
107
|
constructor (dialogs: DialogSet, contextOrDialogContext: TurnContext | DialogContext, state: DialogState) {
|
|
@@ -145,7 +145,7 @@ export class DialogContext {
|
|
|
145
145
|
*
|
|
146
146
|
* @remarks
|
|
147
147
|
* When it attempts to start a dialog, the dialog context searches for the Dialog.id
|
|
148
|
-
* in its DialogContext.dialogs. If the dialog to start is not found
|
|
148
|
+
* in its {@link DialogContext.dialogs}. If the dialog to start is not found
|
|
149
149
|
* in this dialog context, it searches in its parent dialog context, and so on.
|
|
150
150
|
*/
|
|
151
151
|
parent: DialogContext | undefined
|
|
@@ -175,7 +175,7 @@ export class DialogContext {
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
/**
|
|
178
|
-
* Gets the DialogStateManager which manages view of all memory scopes.
|
|
178
|
+
* Gets the {@link DialogStateManager} which manages view of all memory scopes.
|
|
179
179
|
*/
|
|
180
180
|
state: DialogStateManager
|
|
181
181
|
|
|
@@ -185,8 +185,7 @@ export class DialogContext {
|
|
|
185
185
|
services: TurnContextStateCollection = new TurnContextStateCollection()
|
|
186
186
|
|
|
187
187
|
/**
|
|
188
|
-
* @
|
|
189
|
-
* @returns The current dialog manager instance. This property is deprecated.
|
|
188
|
+
* @returns The current dialog manager instance.
|
|
190
189
|
*/
|
|
191
190
|
get dialogManager (): DialogManager {
|
|
192
191
|
return this.context.turnState.get(DialogTurnStateConstants.dialogManager)
|
|
@@ -224,7 +223,7 @@ export class DialogContext {
|
|
|
224
223
|
* If there's already an active dialog on the stack, that dialog will be paused until
|
|
225
224
|
* it is again the top dialog on the stack.
|
|
226
225
|
*
|
|
227
|
-
* The DialogTurnResult.status of returned object describes
|
|
226
|
+
* The {@link DialogTurnResult.status} of returned object describes
|
|
228
227
|
* the status of the dialog stack after this method completes.
|
|
229
228
|
*
|
|
230
229
|
* This method throws an exception if the requested dialog can't be found in this dialog context
|
|
@@ -260,12 +259,12 @@ export class DialogContext {
|
|
|
260
259
|
* @param eventValue Optional. Value to pass along with custom cancellation event.
|
|
261
260
|
* @returns {Promise<DialogTurnResult>} a promise resolving to the dialog turn result.
|
|
262
261
|
* @remarks
|
|
263
|
-
* This calls each dialog's
|
|
262
|
+
* This calls each dialog's {@link Dialog.endDialog | endDialog method} before
|
|
264
263
|
* removing the dialog from the stack.
|
|
265
264
|
*
|
|
266
265
|
* If there were any dialogs on the stack initially, the DialogTurnResult.status
|
|
267
|
-
* of the return value is DialogTurnStatus.cancelled; otherwise, it's
|
|
268
|
-
* DialogTurnStatus.empty.
|
|
266
|
+
* of the return value is {@link DialogTurnStatus.cancelled}; otherwise, it's
|
|
267
|
+
* {@link DialogTurnStatus.empty}.
|
|
269
268
|
*
|
|
270
269
|
*/
|
|
271
270
|
async cancelAllDialogs (cancelParents = false, eventName?: string, eventValue?: any): Promise<DialogTurnResult> {
|
|
@@ -307,7 +306,7 @@ export class DialogContext {
|
|
|
307
306
|
* @param dialogId ID of the dialog to search for.
|
|
308
307
|
* @returns The dialog for the provided ID.
|
|
309
308
|
* @remarks
|
|
310
|
-
* If the dialog to start is not found in the DialogSet associated
|
|
309
|
+
* If the dialog to start is not found in the {@link DialogSet} associated
|
|
311
310
|
* with this dialog context, it attempts to find the dialog in its parent dialog context.
|
|
312
311
|
*
|
|
313
312
|
*/
|
|
@@ -329,7 +328,7 @@ export class DialogContext {
|
|
|
329
328
|
*
|
|
330
329
|
* @remarks
|
|
331
330
|
* This helper method formats the object to use as the `options` parameter, and then calls
|
|
332
|
-
* DialogContext.beginDialog to start the specified prompt dialog.
|
|
331
|
+
* {@link DialogContext.beginDialog} to start the specified prompt dialog.
|
|
333
332
|
*
|
|
334
333
|
*/
|
|
335
334
|
async prompt (
|
|
@@ -342,13 +341,13 @@ export class DialogContext {
|
|
|
342
341
|
*
|
|
343
342
|
* @param dialogId ID of the prompt dialog to start.
|
|
344
343
|
* @param promptOrOptions The text of the initial prompt to send the user,
|
|
345
|
-
* the Activity to send as the initial prompt, or
|
|
344
|
+
* the {@link Activity} to send as the initial prompt, or
|
|
346
345
|
* the object with which to format the prompt dialog.
|
|
347
346
|
* @param choices Optional. Array of choices for the user to choose from,
|
|
348
|
-
* for use with a ChoicePrompt.
|
|
347
|
+
* for use with a {@link ChoicePrompt}.
|
|
349
348
|
* @remarks
|
|
350
349
|
* This helper method formats the object to use as the `options` parameter, and then calls
|
|
351
|
-
* DialogContext.beginDialog to start the specified prompt dialog.
|
|
350
|
+
* {@link DialogContext.beginDialog} to start the specified prompt dialog.
|
|
352
351
|
*
|
|
353
352
|
*/
|
|
354
353
|
async prompt (
|
|
@@ -362,12 +361,12 @@ export class DialogContext {
|
|
|
362
361
|
*
|
|
363
362
|
* @param dialogId ID of the prompt dialog to start.
|
|
364
363
|
* @param promptOrOptions The text of the initial prompt to send the user,
|
|
365
|
-
* or the Activity to send as the initial prompt.
|
|
364
|
+
* or the {@link Activity} to send as the initial prompt.
|
|
366
365
|
* @param choices Optional. Array of choices for the user to choose from,
|
|
367
|
-
* for use with a ChoicePrompt.
|
|
366
|
+
* for use with a {@link ChoicePrompt}.
|
|
368
367
|
* @returns {Promise<DialogTurnResult>} a promise resolving to the dialog turn result.
|
|
369
368
|
* @remarks This helper method formats the object to use as the `options` parameter, and then calls
|
|
370
|
-
* beginDialog to start the specified prompt dialog.
|
|
369
|
+
* {@link DialogContext.beginDialog} to start the specified prompt dialog.
|
|
371
370
|
*
|
|
372
371
|
*/
|
|
373
372
|
async prompt (
|
|
@@ -394,14 +393,14 @@ export class DialogContext {
|
|
|
394
393
|
|
|
395
394
|
/**
|
|
396
395
|
* Continues execution of the active dialog, if there is one, by passing this dialog context to its
|
|
397
|
-
*
|
|
396
|
+
* {@link DialogContext.continueDialog} method.
|
|
398
397
|
*
|
|
399
398
|
* @returns {Promise<DialogTurnResult>} a promise resolving to the dialog turn result.
|
|
400
399
|
* @remarks
|
|
401
|
-
* After the call completes, you can check the turn context's TurnContext.responded
|
|
400
|
+
* After the call completes, you can check the turn context's {@link TurnContext.responded}
|
|
402
401
|
* property to determine if the dialog sent a reply to the user.
|
|
403
402
|
*
|
|
404
|
-
* The DialogTurnResult.status of returned object describes
|
|
403
|
+
* The {@link DialogTurnResult.status} of returned object describes
|
|
405
404
|
* the status of the dialog stack after this method completes.
|
|
406
405
|
*
|
|
407
406
|
* Typically, you would call this from within your agent's turn handler.
|
|
@@ -446,12 +445,12 @@ export class DialogContext {
|
|
|
446
445
|
* @returns {Promise<DialogTurnResult>} a promise resolving to the dialog turn result.
|
|
447
446
|
* @remarks
|
|
448
447
|
* The _parent_ dialog is the next dialog on the dialog stack, if there is one. This method
|
|
449
|
-
* calls the parent's Dialog.resumeDialog method,
|
|
448
|
+
* calls the parent's {@link Dialog.resumeDialog} method,
|
|
450
449
|
* passing the result returned by the ending dialog. If there is no parent dialog, the turn ends
|
|
451
450
|
* and the result is available to the agent through the returned object's
|
|
452
|
-
* DialogTurnResult.result property.
|
|
451
|
+
* {@link DialogTurnResult.result} property.
|
|
453
452
|
*
|
|
454
|
-
* The DialogTurnResult.status of returned object describes
|
|
453
|
+
* The {@link DialogTurnResult.status} of returned object describes
|
|
455
454
|
* the status of the dialog stack after this method completes.
|
|
456
455
|
*
|
|
457
456
|
* Typically, you would call this from within the logic for a specific dialog to signal back to
|
|
@@ -492,7 +491,7 @@ export class DialogContext {
|
|
|
492
491
|
* @remarks
|
|
493
492
|
* This is particularly useful for creating a loop or redirecting to another dialog.
|
|
494
493
|
*
|
|
495
|
-
* The DialogTurnResult.status of returned object describes
|
|
494
|
+
* The {@link DialogTurnResult.status} of returned object describes
|
|
496
495
|
* the status of the dialog stack after this method completes.
|
|
497
496
|
*
|
|
498
497
|
* This method is similar to ending the current dialog and immediately beginning the new one.
|
|
@@ -511,7 +510,7 @@ export class DialogContext {
|
|
|
511
510
|
* Requests the active dialog to re-prompt the user for input.
|
|
512
511
|
*
|
|
513
512
|
* @remarks
|
|
514
|
-
* This calls the active dialog's Dialog.repromptDialog method.
|
|
513
|
+
* This calls the active dialog's {@link Dialog.repromptDialog} method.
|
|
515
514
|
*
|
|
516
515
|
*/
|
|
517
516
|
async repromptDialog (): Promise<void> {
|
package/src/dialogEvent.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an event that occurs within a dialog, providing details such as its name, whether it should bubble to parent contexts, and any associated value.
|
|
3
|
+
*/
|
|
1
4
|
export interface DialogEvent {
|
|
2
5
|
/**
|
|
3
6
|
* Flag indicating whether the event will be bubbled to the parent `DialogContext`.
|
package/src/dialogEvents.ts
CHANGED
|
@@ -5,12 +5,37 @@
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Represents the events related to the "lifecycle" of the dialog.
|
|
8
|
+
*
|
|
9
|
+
* These events are used to signal various stages or actions within a dialog's lifecycle.
|
|
8
10
|
*/
|
|
9
11
|
export class DialogEvents {
|
|
12
|
+
/**
|
|
13
|
+
* Event triggered when a dialog begins.
|
|
14
|
+
*/
|
|
10
15
|
static readonly beginDialog = 'beginDialog'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Event triggered to reprompt a dialog.
|
|
19
|
+
*/
|
|
11
20
|
static readonly repromptDialog = 'repromptDialog'
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Event triggered when a dialog is canceled.
|
|
24
|
+
*/
|
|
12
25
|
static readonly cancelDialog = 'cancelDialog'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Event triggered when an activity is received.
|
|
29
|
+
*/
|
|
13
30
|
static readonly activityReceived = 'activityReceived'
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Event triggered when the dialog version changes.
|
|
34
|
+
*/
|
|
14
35
|
static readonly versionChanged = 'versionChanged'
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Event triggered when an error occurs.
|
|
39
|
+
*/
|
|
15
40
|
static readonly error = 'error'
|
|
16
41
|
}
|
package/src/dialogHelper.ts
CHANGED
|
@@ -106,6 +106,14 @@ export async function internalRun (
|
|
|
106
106
|
return dialogTurnResult
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Executes the dialog by either continuing an existing dialog or starting a new one.
|
|
111
|
+
*
|
|
112
|
+
* @param context The TurnContext for the turn.
|
|
113
|
+
* @param dialogId The ID of the dialog to start or continue.
|
|
114
|
+
* @param dialogContext The DialogContext for the current turn of conversation.
|
|
115
|
+
* @returns A promise resolving to the result of the dialog turn.
|
|
116
|
+
*/
|
|
109
117
|
async function innerRun (
|
|
110
118
|
context: TurnContext,
|
|
111
119
|
dialogId: string,
|
|
@@ -136,8 +144,13 @@ export function getActiveDialogContext (dialogContext: DialogContext): DialogCon
|
|
|
136
144
|
|
|
137
145
|
return getActiveDialogContext(child)
|
|
138
146
|
}
|
|
139
|
-
|
|
140
147
|
// Helper to send a trace activity with a memory snapshot of the active dialog DC.
|
|
148
|
+
/**
|
|
149
|
+
* Sends a trace activity containing a memory snapshot of the active dialog context.
|
|
150
|
+
*
|
|
151
|
+
* @param dialogContext The DialogContext for the current turn of conversation.
|
|
152
|
+
* @returns A promise that resolves when the trace activity is sent.
|
|
153
|
+
*/
|
|
141
154
|
const sendStateSnapshotTrace = async (dialogContext: DialogContext): Promise<void> => {
|
|
142
155
|
const traceLabel = 'Agent State'
|
|
143
156
|
|
package/src/dialogManager.ts
CHANGED
package/src/dialogSet.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface DialogDependencies {
|
|
|
26
26
|
* persist the dialog stack for the set:
|
|
27
27
|
*
|
|
28
28
|
* To interact with the sets dialogs you can call createcontext with the
|
|
29
|
-
* current
|
|
29
|
+
* current {@link TurnContext}. That will create a {@link DialogContext} that can be used to start or continue
|
|
30
30
|
* execution of the sets dialogs:
|
|
31
31
|
*
|
|
32
32
|
*/
|
|
@@ -39,8 +39,8 @@ export class DialogSet {
|
|
|
39
39
|
* Creates a new DialogSet instance.
|
|
40
40
|
*
|
|
41
41
|
* @remarks
|
|
42
|
-
* If the `dialogState`
|
|
43
|
-
* will return an error. You will need to create a
|
|
42
|
+
* If the `dialogState` parameter is not passed in, calls to {@link DialogSet.createcontext |createContext}
|
|
43
|
+
* will return an error. You will need to create a {@link DialogContext} for the set manually and
|
|
44
44
|
* pass in your own state object for persisting the sets dialog stack:
|
|
45
45
|
*
|
|
46
46
|
* @param dialogState (Optional) state property used to persist the sets dialog stack.
|
|
@@ -75,7 +75,7 @@ export class DialogSet {
|
|
|
75
75
|
* Adds a new dialog or prompt to the set.
|
|
76
76
|
*
|
|
77
77
|
* @remarks
|
|
78
|
-
* If the
|
|
78
|
+
* If the {@link Dialog.id} being added already exists in the set, the dialogs id will be updated to
|
|
79
79
|
* include a suffix which makes it unique. So adding 2 dialogs named "duplicate" to the set
|
|
80
80
|
* would result in the first one having an id of "duplicate" and the second one having an id
|
|
81
81
|
* of "duplicate2".
|
|
@@ -146,10 +146,6 @@ export class DialogSet {
|
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
* Finds a dialog that was previously added to the set using add.
|
|
149
|
-
*
|
|
150
|
-
* @remarks
|
|
151
|
-
* This example finds a dialog named "greeting":
|
|
152
|
-
*
|
|
153
149
|
* @param dialogId ID of the dialog or prompt to lookup.
|
|
154
150
|
* @returns The dialog if found; otherwise undefined.
|
|
155
151
|
*/
|
|
@@ -4,10 +4,24 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Provides constants used to manage the state of a dialog turn.
|
|
8
|
+
*
|
|
9
|
+
* These constants are used as keys to store and retrieve specific state information
|
|
10
|
+
* during the execution of a dialog turn.
|
|
8
11
|
*/
|
|
9
12
|
export class DialogTurnStateConstants {
|
|
13
|
+
/**
|
|
14
|
+
* Symbol representing the configuration for the dialog turn.
|
|
15
|
+
*/
|
|
10
16
|
static configuration = Symbol('configuration')
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Symbol representing the dialog manager instance.
|
|
20
|
+
*/
|
|
11
21
|
static dialogManager = Symbol('dialogManager')
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Symbol representing the queue storage for the dialog turn.
|
|
25
|
+
*/
|
|
12
26
|
static queueStorage = Symbol('queueStorage')
|
|
13
27
|
}
|
package/src/intentScore.ts
CHANGED
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
* Score plus any extra information about an intent.
|
|
7
7
|
*/
|
|
8
8
|
export interface IntentScore {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Optional. The confidence score of the intent, ranging from 0.0 to 1.0.
|
|
11
|
+
*/
|
|
12
|
+
score?: number
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Additional properties related to the intent.
|
|
16
|
+
*/
|
|
17
|
+
[key: string]: unknown
|
|
11
18
|
}
|
package/src/memory/dialogPath.ts
CHANGED
|
@@ -7,27 +7,51 @@
|
|
|
7
7
|
* Defines path for available dialogs.
|
|
8
8
|
*/
|
|
9
9
|
export class DialogPath {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
static readonly
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
static readonly
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
static readonly
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
static readonly
|
|
10
|
+
/**
|
|
11
|
+
* Counter of emitted events.
|
|
12
|
+
* @constant A string key representing the event counter path (`'dialog.eventCounter'`).
|
|
13
|
+
*/
|
|
14
|
+
static readonly eventCounter: string = 'dialog.eventCounter'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Currently expected properties.
|
|
18
|
+
* @constant A string key representing the expected properties path (`'dialog.expectedProperties'`).
|
|
19
|
+
*/
|
|
20
|
+
static readonly expectedProperties: string = 'dialog.expectedProperties'
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Default operation to use for entities where there is no identified operation entity.
|
|
24
|
+
* @constant A string key representing the default operation path (`'dialog.defaultOperation'`).
|
|
25
|
+
*/
|
|
26
|
+
static readonly defaultOperation: string = 'dialog.defaultOperation'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Last surfaced entity ambiguity event.
|
|
30
|
+
* @constant A string key representing the last event path (`'dialog.lastEvent'`).
|
|
31
|
+
*/
|
|
32
|
+
static readonly lastEvent: string = 'dialog.lastEvent'
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Currently required properties.
|
|
36
|
+
* @constant A string key representing the required properties path (`'dialog.requiredProperties'`).
|
|
37
|
+
*/
|
|
38
|
+
static readonly requiredProperties: string = 'dialog.requiredProperties'
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Number of retries for the current Ask.
|
|
42
|
+
* @constant A string key representing the retries path (`'dialog.retries'`).
|
|
43
|
+
*/
|
|
44
|
+
static readonly retries: string = 'dialog.retries'
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Last intent.
|
|
48
|
+
* @constant A string key representing the last intent path (`'dialog.lastIntent'`).
|
|
49
|
+
*/
|
|
50
|
+
static readonly lastIntent: string = 'dialog.lastIntent'
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Last trigger event: defined in FormEvent, ask, clarifyEntity etc.
|
|
54
|
+
* @constant A string key representing the last trigger event path (`'dialog.lastTriggerEvent'`).
|
|
55
|
+
*/
|
|
56
|
+
static readonly lastTriggerEvent: string = 'dialog.lastTriggerEvent'
|
|
33
57
|
}
|
|
@@ -435,7 +435,7 @@ export class DialogStateManager {
|
|
|
435
435
|
* Track when specific paths are changed.
|
|
436
436
|
*
|
|
437
437
|
* @param paths Paths to track.
|
|
438
|
-
* @returns Normalized paths to pass to
|
|
438
|
+
* @returns Normalized paths to pass to `anyPathChanged` method.
|
|
439
439
|
*/
|
|
440
440
|
trackPaths (paths: string[]): string[] {
|
|
441
441
|
const allPaths: string[] = []
|
|
@@ -459,7 +459,7 @@ export class DialogStateManager {
|
|
|
459
459
|
* Check to see if any path has changed since watermark.
|
|
460
460
|
*
|
|
461
461
|
* @param counter Time counter to compare to.
|
|
462
|
-
* @param paths Paths from
|
|
462
|
+
* @param paths Paths from `trackPaths` method to check.
|
|
463
463
|
* @returns True if any path has changed since counter.
|
|
464
464
|
*/
|
|
465
465
|
anyPathChanged (counter: number, paths: string[]): boolean {
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { PathResolver } from './pathResolver'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* A class that resolves paths by replacing an alias with a specified prefix and optional postfix.
|
|
9
|
+
* This is useful for transforming paths that use shorthand aliases into fully qualified paths.
|
|
10
|
+
*/
|
|
7
11
|
export class AliasPathResolver implements PathResolver {
|
|
8
12
|
private readonly alias: string
|
|
9
13
|
private readonly prefix: string
|
|
@@ -4,10 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { AliasPathResolver } from './aliasPathResolver'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* A specialized path resolver that replaces the '@@' alias with the prefix 'turn.recognized.entities.'.
|
|
9
|
+
* This is used to resolve paths related to recognized entities in a conversational turn.
|
|
10
|
+
*/
|
|
7
11
|
export class AtAtPathResolver extends AliasPathResolver {
|
|
8
12
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
* Initializes a new instance of the AtAtPathResolver class.
|
|
14
|
+
*/
|
|
11
15
|
constructor () {
|
|
12
16
|
super('@@', 'turn.recognized.entities.')
|
|
13
17
|
}
|
|
@@ -4,23 +4,29 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { AliasPathResolver } from './aliasPathResolver'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* A path resolver that replaces the '@' alias with a specific prefix and transforms paths
|
|
9
|
+
* to access recognized entities in a conversational turn. It ensures that the resolved
|
|
10
|
+
* path includes the 'first()' function for entity properties.
|
|
11
|
+
*/
|
|
7
12
|
export class AtPathResolver extends AliasPathResolver {
|
|
8
13
|
private readonly _prefix = 'turn.recognized.entities.'
|
|
9
14
|
private readonly _delims = ['.', '[']
|
|
10
15
|
|
|
11
16
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
* Initializes a new instance of the AtPathResolver class.
|
|
18
|
+
*/
|
|
14
19
|
constructor () {
|
|
15
20
|
super('@', '')
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
* Transforms the path by replacing the '@' alias and appending the 'first()' function
|
|
25
|
+
* to entity properties.
|
|
26
|
+
*
|
|
27
|
+
* @param path The path to inspect and transform.
|
|
28
|
+
* @returns The transformed path.
|
|
29
|
+
*/
|
|
24
30
|
transformPath (path: string): string {
|
|
25
31
|
path = path.trim()
|
|
26
32
|
if (path.startsWith('@') && path.length > 1 && !path.startsWith('@@')) {
|