@microsoft/agents-hosting-dialogs 1.0.0 → 1.0.3-g444d99f704
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/agentStateSet.d.ts +30 -27
- package/dist/src/agentStateSet.js +30 -27
- package/dist/src/agentStateSet.js.map +1 -1
- package/dist/src/choices/findValues.d.ts +21 -12
- package/dist/src/choices/findValues.js +8 -5
- package/dist/src/choices/findValues.js.map +1 -1
- package/dist/src/componentDialog.d.ts +117 -95
- package/dist/src/componentDialog.js +106 -84
- package/dist/src/componentDialog.js.map +1 -1
- package/dist/src/dialog.d.ts +15 -10
- package/dist/src/dialog.js +15 -10
- package/dist/src/dialog.js.map +1 -1
- package/dist/src/dialogContainer.d.ts +5 -2
- package/dist/src/dialogContainer.js +5 -2
- package/dist/src/dialogContainer.js.map +1 -1
- package/dist/src/dialogContext.d.ts +30 -9
- package/dist/src/dialogContext.js +31 -11
- package/dist/src/dialogContext.js.map +1 -1
- package/dist/src/dialogInstance.d.ts +11 -11
- package/dist/src/dialogReason.d.ts +13 -13
- package/dist/src/dialogReason.js +13 -13
- package/dist/src/dialogReason.js.map +1 -1
- package/dist/src/dialogSet.d.ts +11 -6
- package/dist/src/dialogSet.js +9 -4
- package/dist/src/dialogSet.js.map +1 -1
- package/dist/src/dialogTurnResult.d.ts +1 -0
- package/dist/src/dialogTurnStateConstants.d.ts +1 -0
- package/dist/src/dialogTurnStateConstants.js +1 -0
- package/dist/src/dialogTurnStateConstants.js.map +1 -1
- package/dist/src/dialogTurnStatus.d.ts +1 -0
- package/dist/src/dialogTurnStatus.js +1 -0
- package/dist/src/dialogTurnStatus.js.map +1 -1
- package/dist/src/memory/dialogStateManager.d.ts +9 -4
- package/dist/src/memory/dialogStateManager.js +9 -4
- package/dist/src/memory/dialogStateManager.js.map +1 -1
- package/dist/src/prompts/activityPrompt.d.ts +4 -0
- package/dist/src/prompts/activityPrompt.js +4 -0
- package/dist/src/prompts/activityPrompt.js.map +1 -1
- package/dist/src/prompts/attachmentPrompt.d.ts +1 -0
- package/dist/src/prompts/attachmentPrompt.js +1 -0
- package/dist/src/prompts/attachmentPrompt.js.map +1 -1
- package/dist/src/prompts/choicePrompt.d.ts +4 -0
- package/dist/src/prompts/choicePrompt.js +1 -0
- package/dist/src/prompts/choicePrompt.js.map +1 -1
- package/dist/src/prompts/confirmPrompt.d.ts +4 -1
- package/dist/src/prompts/confirmPrompt.js +1 -0
- package/dist/src/prompts/confirmPrompt.js.map +1 -1
- package/dist/src/prompts/datetimePrompt.d.ts +1 -0
- package/dist/src/prompts/datetimePrompt.js +1 -0
- package/dist/src/prompts/datetimePrompt.js.map +1 -1
- package/dist/src/prompts/numberPrompt.d.ts +1 -0
- package/dist/src/prompts/numberPrompt.js +1 -0
- package/dist/src/prompts/numberPrompt.js.map +1 -1
- package/dist/src/prompts/prompt.d.ts +22 -6
- package/dist/src/prompts/prompt.js +8 -0
- package/dist/src/prompts/prompt.js.map +1 -1
- package/dist/src/prompts/promptCultureModels.d.ts +16 -1
- package/dist/src/prompts/promptCultureModels.js +4 -1
- package/dist/src/prompts/promptCultureModels.js.map +1 -1
- package/dist/src/prompts/textPrompt.d.ts +3 -0
- package/dist/src/prompts/textPrompt.js +3 -0
- package/dist/src/prompts/textPrompt.js.map +1 -1
- package/dist/src/recognizer.d.ts +3 -0
- package/dist/src/recognizer.js +1 -0
- package/dist/src/recognizer.js.map +1 -1
- package/dist/src/recognizerResult.d.ts +5 -4
- package/dist/src/recognizerResult.js +5 -4
- package/dist/src/recognizerResult.js.map +1 -1
- package/dist/src/stringUtils.d.ts +4 -3
- package/dist/src/stringUtils.js +4 -3
- package/dist/src/stringUtils.js.map +1 -1
- package/dist/src/waterfallDialog.d.ts +11 -4
- package/dist/src/waterfallDialog.js +11 -4
- package/dist/src/waterfallDialog.js.map +1 -1
- package/package.json +2 -2
- package/src/agentStateSet.ts +30 -27
- package/src/choices/findValues.ts +21 -12
- package/src/componentDialog.ts +127 -97
- package/src/dialog.ts +15 -10
- package/src/dialogContainer.ts +5 -2
- package/src/dialogContext.ts +37 -11
- package/src/dialogInstance.ts +11 -11
- package/src/dialogReason.ts +13 -13
- package/src/dialogSet.ts +11 -6
- package/src/dialogTurnResult.ts +1 -0
- package/src/dialogTurnStateConstants.ts +1 -0
- package/src/dialogTurnStatus.ts +1 -0
- package/src/memory/dialogStateManager.ts +9 -4
- package/src/prompts/activityPrompt.ts +4 -0
- package/src/prompts/attachmentPrompt.ts +1 -0
- package/src/prompts/choicePrompt.ts +4 -0
- package/src/prompts/confirmPrompt.ts +4 -1
- package/src/prompts/datetimePrompt.ts +1 -0
- package/src/prompts/numberPrompt.ts +1 -0
- package/src/prompts/prompt.ts +22 -6
- package/src/prompts/promptCultureModels.ts +16 -1
- package/src/prompts/textPrompt.ts +3 -0
- package/src/recognizer.ts +3 -0
- package/src/recognizerResult.ts +5 -4
- package/src/stringUtils.ts +4 -3
- package/src/waterfallDialog.ts +11 -4
|
@@ -31,7 +31,7 @@ export interface FindValuesOptions {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Represents a value that was successfully found and matched during a search operation.
|
|
35
35
|
*
|
|
36
36
|
* @remarks
|
|
37
37
|
* This interface contains the matched value along with metadata about the match quality
|
|
@@ -49,7 +49,8 @@ export interface FindValuesOptions {
|
|
|
49
49
|
*/
|
|
50
50
|
export interface FoundValue {
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* The exact value that was matched from the original search list.
|
|
53
|
+
*
|
|
53
54
|
* @remarks
|
|
54
55
|
* This is the original string value, not the user's input that matched it.
|
|
55
56
|
*
|
|
@@ -58,7 +59,8 @@ export interface FoundValue {
|
|
|
58
59
|
value: string;
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
|
-
*
|
|
62
|
+
* The zero-based index position of this value in the original list that was searched.
|
|
63
|
+
*
|
|
62
64
|
* @remarks
|
|
63
65
|
* This allows you to correlate the found value back to its position in the source array.
|
|
64
66
|
*
|
|
@@ -67,7 +69,8 @@ export interface FoundValue {
|
|
|
67
69
|
index: number;
|
|
68
70
|
|
|
69
71
|
/**
|
|
70
|
-
*
|
|
72
|
+
* A confidence score between 0 and 1 indicating the quality of the match.
|
|
73
|
+
*
|
|
71
74
|
* @remarks
|
|
72
75
|
* - 1.0 indicates a perfect exact match
|
|
73
76
|
* - Lower values indicate partial or fuzzy matches
|
|
@@ -79,7 +82,8 @@ export interface FoundValue {
|
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
/**
|
|
82
|
-
*
|
|
85
|
+
* Represents a value with its original position that can be used in search operations.
|
|
86
|
+
*
|
|
83
87
|
* @remarks
|
|
84
88
|
* This interface is used internally by the search algorithm to maintain the relationship
|
|
85
89
|
* between search values and their original positions in the source array.
|
|
@@ -102,7 +106,8 @@ export interface FoundValue {
|
|
|
102
106
|
*/
|
|
103
107
|
export interface SortedValue {
|
|
104
108
|
/**
|
|
105
|
-
*
|
|
109
|
+
* The string value to be searched for during matching operations.
|
|
110
|
+
*
|
|
106
111
|
* @remarks
|
|
107
112
|
* This is the actual text content that will be compared against user input.
|
|
108
113
|
*
|
|
@@ -111,7 +116,8 @@ export interface SortedValue {
|
|
|
111
116
|
value: string;
|
|
112
117
|
|
|
113
118
|
/**
|
|
114
|
-
*
|
|
119
|
+
* The zero-based index position of this value in the original source array.
|
|
120
|
+
*
|
|
115
121
|
* @remarks
|
|
116
122
|
* This allows the search algorithm to correlate found matches back to their
|
|
117
123
|
* original positions, which is essential for maintaining proper choice selection.
|
|
@@ -122,17 +128,20 @@ export interface SortedValue {
|
|
|
122
128
|
}
|
|
123
129
|
|
|
124
130
|
/**
|
|
125
|
-
*
|
|
131
|
+
* Low-level function that searches for a set of values within an utterance.
|
|
132
|
+
*
|
|
133
|
+
* @param utterance The text or user utterance to search over.
|
|
134
|
+
* @param values List of values to search over.
|
|
135
|
+
* @param options (Optional) options used to tweak the search that's performed.
|
|
136
|
+
* @returns A list of found values.
|
|
137
|
+
*
|
|
126
138
|
* @remarks
|
|
127
139
|
* Higher level functions like `findChoices()` and `recognizeChoices()` are layered above this function. In most
|
|
128
140
|
* cases its easier to just call one of the higher level functions instead but this function contains
|
|
129
141
|
* the fuzzy search algorithm that drives choice recognition.
|
|
130
142
|
*
|
|
131
143
|
* @internal
|
|
132
|
-
|
|
133
|
-
* @param values List of values to search over.
|
|
134
|
-
* @param options (Optional) options used to tweak the search that's performed.
|
|
135
|
-
* @returns A list of found values.
|
|
144
|
+
|
|
136
145
|
*/
|
|
137
146
|
export function findValues (
|
|
138
147
|
utterance: string,
|
package/src/componentDialog.ts
CHANGED
|
@@ -16,36 +16,39 @@ const PERSISTED_DIALOG_STATE = 'dialogs'
|
|
|
16
16
|
/**
|
|
17
17
|
* Base class for a dialog that contains other child dialogs.
|
|
18
18
|
*
|
|
19
|
+
* @param O (Optional) options that can be passed into the `DialogContext.beginDialog()` method.
|
|
20
|
+
*
|
|
19
21
|
* @remarks
|
|
20
22
|
* Component dialogs let you break your agent's logic up into components that can themselves be added
|
|
21
23
|
* as a dialog to another `ComponentDialog` or `DialogSet`. Components can also be exported as part
|
|
22
24
|
* of a node package and used within other agents.
|
|
23
25
|
*
|
|
24
|
-
* @param O (Optional) options that can be passed into the `DialogContext.beginDialog()` method.
|
|
25
26
|
*/
|
|
26
27
|
export class ComponentDialog<O extends object = {}> extends DialogContainer<O> {
|
|
27
28
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
* ID of the child dialog that should be started anytime the component is started.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* This defaults to the ID of the first child dialog added using [addDialog()](#adddialog).
|
|
33
|
+
*/
|
|
33
34
|
protected initialDialogId: string
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
* Called when the dialog is started and pushed onto the parent's dialog stack.
|
|
38
|
+
*
|
|
39
|
+
* @param outerDialogContext The parent DialogContext for the current turn of conversation.
|
|
40
|
+
* @param options Optional, initial information to pass to the dialog.
|
|
41
|
+
* @returns A Promise representing the asynchronous operation.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* If the task is successful, the result indicates whether the dialog is still
|
|
45
|
+
* active after the turn has been processed by the dialog.
|
|
46
|
+
* By default, this calls the
|
|
47
|
+
* Dialog.BeginDialogAsync(DialogContext, object, CancellationToken) method
|
|
48
|
+
* of the component dialog's initial dialog, as defined by InitialDialogId.
|
|
49
|
+
* Override this method in a derived class to implement interrupt logic.
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
49
52
|
async beginDialog (outerDialogContext: DialogContext, options?: O): Promise<DialogTurnResult> {
|
|
50
53
|
await this.checkForVersionChange(outerDialogContext)
|
|
51
54
|
|
|
@@ -73,14 +76,16 @@ export class ComponentDialog<O extends object = {}> extends DialogContainer<O> {
|
|
|
73
76
|
/**
|
|
74
77
|
* Called when the dialog is _continued_, where it is the active dialog and the
|
|
75
78
|
* user replies with a new Activity.
|
|
76
|
-
* If this method is *not* overridden, the dialog automatically ends when the user replies.
|
|
77
79
|
*
|
|
78
80
|
* @param outerDialogContext The parent DialogContext for the current turn of conversation.
|
|
79
81
|
* @returns A Promise representing the asynchronous operation.
|
|
82
|
+
*
|
|
80
83
|
* @remarks
|
|
84
|
+
* If this method is *not* overridden, the dialog automatically ends when the user replies.
|
|
81
85
|
* If the task is successful, the result indicates whether the dialog is still
|
|
82
86
|
* active after the turn has been processed by the dialog. The result may also contain a
|
|
83
87
|
* return value.
|
|
88
|
+
*
|
|
84
89
|
*/
|
|
85
90
|
async continueDialog (outerDialogContext: DialogContext): Promise<DialogTurnResult> {
|
|
86
91
|
await this.checkForVersionChange(outerDialogContext)
|
|
@@ -108,6 +113,7 @@ export class ComponentDialog<O extends object = {}> extends DialogContainer<O> {
|
|
|
108
113
|
* @param _result Optional, value returned from the dialog that was called. The type
|
|
109
114
|
* of the value returned is dependent on the child dialog.
|
|
110
115
|
* @returns A Promise representing the asynchronous operation.
|
|
116
|
+
*
|
|
111
117
|
* @remarks
|
|
112
118
|
* If the task is successful, the result indicates whether this dialog is still
|
|
113
119
|
* active after this dialog turn has been processed.
|
|
@@ -132,12 +138,12 @@ export class ComponentDialog<O extends object = {}> extends DialogContainer<O> {
|
|
|
132
138
|
}
|
|
133
139
|
|
|
134
140
|
/**
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
* Called when the dialog should re-prompt the user for input.
|
|
142
|
+
*
|
|
143
|
+
* @param context The TurnContext object for this turn.
|
|
144
|
+
* @param instance State information for this dialog.
|
|
145
|
+
* @returns A Promise representing the asynchronous operation.
|
|
146
|
+
*/
|
|
141
147
|
async repromptDialog (context: TurnContext, instance: DialogInstance): Promise<void> {
|
|
142
148
|
// Forward to inner dialogs
|
|
143
149
|
const innerDC: DialogContext = this.createInnerDC(context, instance)
|
|
@@ -148,15 +154,18 @@ export class ComponentDialog<O extends object = {}> extends DialogContainer<O> {
|
|
|
148
154
|
}
|
|
149
155
|
|
|
150
156
|
/**
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
* Called when the Dialog is ending.
|
|
158
|
+
*
|
|
159
|
+
* @param context The TurnContext object for this turn.
|
|
160
|
+
* @param instance State information associated with the instance of this component Dialog on its parent's dialog stack.
|
|
161
|
+
* @param reason Reason why the Dialog ended.
|
|
162
|
+
* @returns A Promise representing the asynchronous operation.
|
|
163
|
+
*
|
|
164
|
+
* @remarks
|
|
165
|
+
* When this method is called from the parent dialog's context, the component Dialog
|
|
166
|
+
* cancels all of the dialogs on its inner dialog stack before ending.
|
|
167
|
+
*
|
|
168
|
+
*/
|
|
160
169
|
async endDialog (context: TurnContext, instance: DialogInstance, reason: DialogReason): Promise<void> {
|
|
161
170
|
// Forward cancel to inner dialogs
|
|
162
171
|
if (reason === DialogReason.cancelCalled) {
|
|
@@ -169,13 +178,14 @@ export class ComponentDialog<O extends object = {}> extends DialogContainer<O> {
|
|
|
169
178
|
}
|
|
170
179
|
|
|
171
180
|
/**
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
181
|
+
* Adds a child Dialog or prompt to the components internal DialogSet.
|
|
182
|
+
*
|
|
183
|
+
* @param dialog The child Dialog or prompt to add.
|
|
184
|
+
* @returns The ComponentDialog after the operation is complete.
|
|
185
|
+
*
|
|
186
|
+
* @remarks
|
|
187
|
+
* The Dialog.id of the first child added to the component will be assigned to the initialDialogId property.
|
|
188
|
+
*/
|
|
179
189
|
addDialog (dialog: Dialog): this {
|
|
180
190
|
this.dialogs.add(dialog)
|
|
181
191
|
if (this.initialDialogId === undefined) {
|
|
@@ -196,101 +206,121 @@ export class ComponentDialog<O extends object = {}> extends DialogContainer<O> {
|
|
|
196
206
|
}
|
|
197
207
|
|
|
198
208
|
/**
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
+
* Called anytime an instance of the component has been started.
|
|
210
|
+
*
|
|
211
|
+
* @param innerDialogContext Dialog context for the components internal `DialogSet`.
|
|
212
|
+
* @param options (Optional) options that were passed to the component by its parent.
|
|
213
|
+
* @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
|
|
214
|
+
*
|
|
215
|
+
* @remarks
|
|
216
|
+
* SHOULD be overridden by components that wish to perform custom interruption logic. The
|
|
217
|
+
* default implementation calls `innerDC.beginDialog()` with the dialog assigned to
|
|
218
|
+
* `initialDialogId`.
|
|
219
|
+
*
|
|
220
|
+
*/
|
|
209
221
|
protected onBeginDialog (innerDialogContext: DialogContext, options?: O): Promise<DialogTurnResult> {
|
|
210
222
|
return innerDialogContext.beginDialog(this.initialDialogId, options)
|
|
211
223
|
}
|
|
212
224
|
|
|
213
225
|
/**
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
226
|
+
* Called anytime a multi-turn component receives additional activities.
|
|
227
|
+
*
|
|
228
|
+
* @param innerDC Dialog context for the components internal `DialogSet`.
|
|
229
|
+
* @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
|
|
230
|
+
*
|
|
231
|
+
* @remarks
|
|
232
|
+
* SHOULD be overridden by components that wish to perform custom interruption logic. The
|
|
233
|
+
* default implementation calls `innerDC.continueDialog()`.
|
|
234
|
+
*/
|
|
222
235
|
protected onContinueDialog (innerDC: DialogContext): Promise<DialogTurnResult> {
|
|
223
236
|
return innerDC.continueDialog()
|
|
224
237
|
}
|
|
225
238
|
|
|
226
239
|
/**
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
240
|
+
* Called when the component is ending.
|
|
241
|
+
*
|
|
242
|
+
* @param _context Context for the current turn of conversation.
|
|
243
|
+
* @param _instance The components instance data within its parents dialog stack.
|
|
244
|
+
* @param _reason The reason the component is ending.
|
|
245
|
+
* @returns A promise representing the asynchronous operation.
|
|
246
|
+
*
|
|
247
|
+
* @remarks
|
|
248
|
+
* If the `reason` code is equal to `DialogReason.cancelCalled`, then any active child dialogs
|
|
249
|
+
* will be cancelled before this method is called.
|
|
250
|
+
*
|
|
251
|
+
*/
|
|
237
252
|
protected onEndDialog (_context: TurnContext, _instance: DialogInstance, _reason: DialogReason): Promise<void> {
|
|
238
253
|
return Promise.resolve()
|
|
239
254
|
}
|
|
240
255
|
|
|
241
256
|
/**
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
257
|
+
* Called when the component has been requested to re-prompt the user for input.
|
|
258
|
+
*
|
|
259
|
+
* @param _context Context for the current turn of conversation.
|
|
260
|
+
* @param _instance The instance of the current dialog.
|
|
261
|
+
* @returns A promise representing the asynchronous operation.
|
|
262
|
+
*
|
|
263
|
+
* @remarks
|
|
264
|
+
* The active child dialog will have already been asked to reprompt before this method is called.
|
|
265
|
+
*
|
|
266
|
+
*/
|
|
250
267
|
protected onRepromptDialog (_context: TurnContext, _instance: DialogInstance): Promise<void> {
|
|
251
268
|
return Promise.resolve()
|
|
252
269
|
}
|
|
253
270
|
|
|
254
271
|
/**
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
272
|
+
* Called when the components last active child dialog ends and the component is ending.
|
|
273
|
+
*
|
|
274
|
+
* @param outerDC Dialog context for the parents `DialogSet`.
|
|
275
|
+
* @param result Result returned by the last active child dialog. Can be a value of `undefined`.
|
|
276
|
+
* @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
|
|
277
|
+
*
|
|
278
|
+
* @remarks
|
|
279
|
+
* SHOULD be overridden by components that wish to perform custom logic before the component
|
|
280
|
+
* ends. The default implementation calls `outerDC.endDialog()` with the `result` returned
|
|
281
|
+
* from the last active child dialog.
|
|
282
|
+
*/
|
|
265
283
|
protected endComponent (outerDC: DialogContext, result: any): Promise<DialogTurnResult> {
|
|
266
284
|
return outerDC.endDialog(result)
|
|
267
285
|
}
|
|
268
286
|
|
|
269
287
|
/**
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
288
|
+
* Creates a new DialogContext instance for the current turn of conversation.
|
|
289
|
+
*
|
|
290
|
+
* @param context DialogContext for the current turn of conversation with the user.
|
|
291
|
+
* @param instance DialogInstance which contains the current state information for this dialog.
|
|
292
|
+
* @returns A new DialogContext instance.
|
|
293
|
+
*
|
|
294
|
+
* @remarks
|
|
295
|
+
* You should only call this if you don't have a dialogContext to work with (such as OnResume())
|
|
296
|
+
*
|
|
297
|
+
* @private
|
|
298
|
+
*/
|
|
277
299
|
private createInnerDC (context: DialogContext, instance: DialogInstance): DialogContext
|
|
278
300
|
/**
|
|
279
|
-
*
|
|
301
|
+
* Creates a new DialogContext instance for the current turn of conversation.
|
|
302
|
+
*
|
|
280
303
|
* @param context TurnContext for the current turn of conversation with the user.
|
|
281
304
|
* @param instance DialogInstance which contains the current state information for this dialog.
|
|
282
305
|
* @returns A new DialogContext instance.
|
|
306
|
+
*
|
|
283
307
|
* @remarks
|
|
284
308
|
* You should only call this if you don't have a dc to work with (such as OnResume())
|
|
309
|
+
*
|
|
310
|
+
* @private
|
|
285
311
|
*/
|
|
286
312
|
private createInnerDC (context: TurnContext, instance: DialogInstance): DialogContext
|
|
287
313
|
/**
|
|
288
|
-
*
|
|
314
|
+
* Creates a new DialogContext instance for the current turn of conversation.
|
|
315
|
+
*
|
|
289
316
|
* @param context TurnContext or DialogContext for the current turn of conversation with the user.
|
|
290
317
|
* @param instance DialogInstance which contains the current state information for this dialog.
|
|
291
318
|
* @returns A new DialogContext instance.
|
|
319
|
+
*
|
|
292
320
|
* @remarks
|
|
293
321
|
* You should only call this if you don't have a dc to work with (such as OnResume())
|
|
322
|
+
*
|
|
323
|
+
* @private
|
|
294
324
|
*/
|
|
295
325
|
private createInnerDC (context: TurnContext | DialogContext, instance: DialogInstance): DialogContext {
|
|
296
326
|
if (!instance) {
|
package/src/dialog.ts
CHANGED
|
@@ -39,9 +39,10 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
39
39
|
/**
|
|
40
40
|
* Unique ID of the dialog.
|
|
41
41
|
*
|
|
42
|
+
* @returns The Id for the dialog.
|
|
43
|
+
*
|
|
42
44
|
* @remarks
|
|
43
45
|
* This will be automatically generated if not specified.
|
|
44
|
-
* @returns The Id for the dialog.
|
|
45
46
|
*/
|
|
46
47
|
get id (): string {
|
|
47
48
|
if (this._id === undefined) {
|
|
@@ -60,6 +61,8 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
60
61
|
/**
|
|
61
62
|
* An encoded string used to aid in the detection of agent changes on re-deployment.
|
|
62
63
|
*
|
|
64
|
+
* @returns Unique string which should only change when dialog has changed in a way that should restart the dialog.
|
|
65
|
+
*
|
|
63
66
|
* @remarks
|
|
64
67
|
* This defaults to returning the dialog's `id` but can be overridden to provide more
|
|
65
68
|
* precise change detection logic. Any dialog on the stack that has its version change will
|
|
@@ -67,7 +70,7 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
67
70
|
* an error will be thrown resulting in the agent error handler logic being run.
|
|
68
71
|
*
|
|
69
72
|
* Returning an empty string will disable version tracking for the component all together.
|
|
70
|
-
*
|
|
73
|
+
*
|
|
71
74
|
*/
|
|
72
75
|
getVersion (): string {
|
|
73
76
|
return this.id
|
|
@@ -96,6 +99,7 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
96
99
|
* When overridden in a derived class, continues the dialog.
|
|
97
100
|
*
|
|
98
101
|
* @param dc The context for the current dialog turn.
|
|
102
|
+
* @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
|
|
99
103
|
*
|
|
100
104
|
* @remarks
|
|
101
105
|
* Derived dialogs that support multiple-turn conversations should override this method.
|
|
@@ -107,7 +111,6 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
107
111
|
* To signal to the dialog context that this dialog has completed, await
|
|
108
112
|
* {@link DialogContext.endDialog} before exiting this method.
|
|
109
113
|
*
|
|
110
|
-
* @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
|
|
111
114
|
*/
|
|
112
115
|
async continueDialog (dc: DialogContext): Promise<DialogTurnResult> {
|
|
113
116
|
// By default just end the current dialog.
|
|
@@ -120,6 +123,7 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
120
123
|
* @param dc The context for the current dialog turn.
|
|
121
124
|
* @param reason The reason the dialog is resuming. This will typically be DialogReason.endCalled
|
|
122
125
|
* @param result Optional. The return value, if any, from the dialog that ended.
|
|
126
|
+
* @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
|
|
123
127
|
*
|
|
124
128
|
* @remarks
|
|
125
129
|
* Derived dialogs that support multiple-turn conversations should override this method.
|
|
@@ -133,7 +137,6 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
133
137
|
* necessarily be the one that started the child dialog.
|
|
134
138
|
* To signal to the dialog context that this dialog has completed, await {@link DialogContext.endDialog} before exiting this method.
|
|
135
139
|
*
|
|
136
|
-
* @returns {Promise<DialogTurnResult>} A promise resolving to the dialog turn result.
|
|
137
140
|
*/
|
|
138
141
|
async resumeDialog (dc: DialogContext, reason: DialogReason, result?: any): Promise<DialogTurnResult> {
|
|
139
142
|
// By default just end the current dialog and return result to parent.
|
|
@@ -205,13 +208,14 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
205
208
|
/**
|
|
206
209
|
* Called before an event is bubbled to its parent.
|
|
207
210
|
*
|
|
211
|
+
* @param _dc The dialog context for the current turn of conversation.
|
|
212
|
+
* @param _e The event being raised.
|
|
213
|
+
* @returns Whether the event is handled by the current dialog and further processing should stop.
|
|
214
|
+
*
|
|
208
215
|
* @remarks
|
|
209
216
|
* This is a good place to perform interception of an event as returning `true` will prevent
|
|
210
217
|
* any further bubbling of the event to the dialogs parents and will also prevent any child
|
|
211
218
|
* dialogs from performing their default processing.
|
|
212
|
-
* @param _dc The dialog context for the current turn of conversation.
|
|
213
|
-
* @param _e The event being raised.
|
|
214
|
-
* @returns Whether the event is handled by the current dialog and further processing should stop.
|
|
215
219
|
*/
|
|
216
220
|
protected async onPreBubbleEvent (_dc: DialogContext, _e: DialogEvent): Promise<boolean> {
|
|
217
221
|
return false
|
|
@@ -220,12 +224,13 @@ export abstract class Dialog<O extends object = {}> extends Configurable {
|
|
|
220
224
|
/**
|
|
221
225
|
* Called after an event was bubbled to all parents and wasn't handled.
|
|
222
226
|
*
|
|
223
|
-
* @remarks
|
|
224
|
-
* This is a good place to perform default processing logic for an event. Returning `true` will
|
|
225
|
-
* prevent any processing of the event by child dialogs.
|
|
226
227
|
* @param _dc The dialog context for the current turn of conversation.
|
|
227
228
|
* @param _e The event being raised.
|
|
228
229
|
* @returns Whether the event is handled by the current dialog and further processing should stop.
|
|
230
|
+
*
|
|
231
|
+
* @remarks
|
|
232
|
+
* This is a good place to perform default processing logic for an event. Returning `true` will
|
|
233
|
+
* prevent any processing of the event by child dialogs.
|
|
229
234
|
*/
|
|
230
235
|
protected async onPostBubbleEvent (_dc: DialogContext, _e: DialogEvent): Promise<boolean> {
|
|
231
236
|
return false
|
package/src/dialogContainer.ts
CHANGED
|
@@ -55,13 +55,14 @@ export abstract class DialogContainer<O extends object = {}> extends Dialog<O> {
|
|
|
55
55
|
/**
|
|
56
56
|
* Returns internal version identifier for this container.
|
|
57
57
|
*
|
|
58
|
+
* @returns Version which represents the change of the internals of this container.
|
|
59
|
+
*
|
|
58
60
|
* @remarks
|
|
59
61
|
* DialogContainers detect changes of all sub-components in the container and map that to a `versionChanged` event.
|
|
60
62
|
* Because they do this, DialogContainers "hide" the internal changes and just have the .id. This isolates changes
|
|
61
63
|
* to the container level unless a container doesn't handle it. To support this DialogContainers define a
|
|
62
64
|
* protected method getInternalVersion() which computes if this dialog or child dialogs have changed
|
|
63
65
|
* which is then examined via calls to checkForVersionChange().
|
|
64
|
-
* @returns Version which represents the change of the internals of this container.
|
|
65
66
|
*/
|
|
66
67
|
protected getInternalVersion (): string {
|
|
67
68
|
return this.dialogs.getVersion()
|
|
@@ -71,9 +72,11 @@ export abstract class DialogContainer<O extends object = {}> extends Dialog<O> {
|
|
|
71
72
|
* Checks to see if a containers child dialogs have changed since the current dialog instance
|
|
72
73
|
* was started.
|
|
73
74
|
*
|
|
75
|
+
* @param dialogContext Current dialog context.
|
|
76
|
+
*
|
|
74
77
|
* @remarks
|
|
75
78
|
* This should be called at the start of `beginDialog()`, `continueDialog()`, and `resumeDialog()`.
|
|
76
|
-
*
|
|
79
|
+
*
|
|
77
80
|
*/
|
|
78
81
|
protected async checkForVersionChange (dialogContext: DialogContext): Promise<void> {
|
|
79
82
|
const current = dialogContext.activeDialog.version
|